1. click on a Product Attribute link in the cart (like http://example.com/en/node/225?line_item_id=68)
  2. change language of the node with the language switcher block to another language

The URL parameter is lost. The translation link is http://example.com/de/node/230.
Instead it should be http://example.com/de/node/230?line_item_id=68, if possible.

Those translations reference the same product (entity).

Comments

olafkarsten’s picture

I'm not sure if I understand this. After 1) your are on the page /node/255 - right? Than you click the language switcher Block - that reloads the page and you are in /node/230 right?. In between the ?parameter is lost - right?

no2e’s picture

Exactly, olafkarsten.

rv0’s picture

This is a "problem" with core.

Can be fixed with

/**
 * Implementation of hook_language_switch_links_alter().
 */
function YOURCUSTOMMODULE_language_switch_links_alter(&$links, $type, $path) {
  $get = $_GET;
  unset($get['q']);
  foreach ($links as &$link) {
    $link['query'] = $get;
  }
}
wiifm’s picture

Or slightly more elegantly:

/**
 * Implementation of hook_language_switch_links_alter().
 */
function YOURCUSTOMMODULE_language_switch_links_alter(&$links, $type, $path) {
  $params = drupal_get_query_parameters();
  foreach ($links as &$link) {
    $link['query'] = $params;
  }
}

Thanks for the code!

wiifm’s picture

Issue summary: View changes

clarified

janroche’s picture

Issue summary: View changes

It worked! Thank you.

janroche’s picture

It worked! Thank you.

janroche’s picture

It worked! Thank you.
sorry for duplicates.

prajila.v.p’s picture

I have tried this code in my custom module and nothing works. Query parameters are appending correctly to the Query field.

[query] => Array
                (
                    [field_office_location_tid] => All
                    [field_job_category_tid] => 8168
                )

But the url still not contains these query parameters. Please help me if I miss anything.