I need to make a redirect after a customer added something to his cart so I write this:
function MODULE_form_alter(&$form, &$form_state, $form_id) {
array_push($form['#submit'], '_MODULE_redirect_to_products');
}
function _MODULE_redirect_to_products(&$form, &$form_state){
global $language ;
$form_state['redirect'] = url('prodotti', array('language' => $language));
}
but this code redirect me to
/dev/azzurra/?q=it//dev/azzurra/%3Fq%3Dit/prodotti
but I need to redirect to
/dev/azzurra/?q=it/prodotti
according to the language obviously.
How canUPDATE: I'm try to use
$form_state['redirect']
but if I changedisplay this field before modify it I can see this
Array
(
[0] => prodotti
[1] => Array
(
[language] => stdClass Object
(
[language] => it
[name] => Italian
[native] => Italiano
[direction] => 0
[enabled] => 1
[plurals] => 2
[formula] => ($n!=1)
[domain] =>
[prefix] => it
[weight] => 0
[javascript] => a97-0F_JBbaSYaN4XQBbFbhCLCysRpSabTcDmQjB73E
[provider] => locale-url
)
)
[2] => 302
)
but the url callingform redirect me to 'it/testate/name' because the form 'add product' is displayed in a view so I think that the views module override the $form_state['redirect'] after me so the default redirect [and mine one..].
I think I can't use this kind of redirect.. How can I achieve this redirect correctly?