I've found the reason in Tools::redirect. It has a line like this:
$url = Tools::strReplaceFirst('&', '?', $url);
here they are basically excluding any queryvar other than the first one, so you won't find any if you add some. If you have index.php?a=1&b=2
, you'll get index.php?a=1?b=2
. I don't really see the point... Maybe it's a bug.
So I overridden Tools::redirect like this (modded lines are commented):
public static function redirect($url, $base_uri = __PS_BASE_URI__, Link $link = null, $headers = null){
if (!$link) $link = Context::getContext()->link;
$querystring = array_pop(explode('?', $url)); // MOD: Save the original querystring. I take the last item in array because sometimes (i think it's a bug) the $url is like index.php?controller=order.php?step=1, so 2 question marks.
if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link) {
if (strpos($url, $base_uri) === 0) {
$url = substr($url, strlen($base_uri));
}
if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) {
$url = substr($url, strlen('index.php?controller='));
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$url = Tools::strReplaceFirst('&', '?', $url); // ...Don't see the point here...
}
}
$explode = explode('?', $url);
// don't use ssl if url is home page
// used when logout for example
$use_ssl = !empty($url);
$url = $link->getPageLink($explode[0], $use_ssl);
if($querystring) $url .= '?'.$querystring; // MOD: adding full querystring!! Also deleted 3 lines that added $explode[1] instead
}
// Send additional headers
if ($headers) {
if (!is_array($headers)) $headers = array($headers);
foreach ($headers as $header) {
header($header);
}
}
header('Location: '.$url);
exit;
}