Page 1 of 1

When changing currency it do not stay in the same page...

Posted: Wed Mar 25, 2009 10:55 am
by lepe
For those who use more than one currency, you may find useful this small patch in order to make it stay in the same page (even in checkout):

Modify 2 lines in: catalog/controller/module/currency.php:

(on the top)
From:
$this->redirect($this->url->http('common/home'));
To:
$this->redirect($this->request->server['HTTP_REFERER']);

(on the middle)
From:
$this->data['action'] = $this->url->http('common/home');
To:
$this->data['action'] = $this->request->server['REQUEST_URI'];

It worked for me...

Re: When changing currency it do not stay in the same page...

Posted: Thu Mar 26, 2009 11:46 am
by lepe
At the "Basket" section, the currency was not changing with the approach I posted.

So, I notice that in "catalog/controller/checkout/cart.php" was blocking my change.

I think it is not good to use the condition like this:

if ($this->request->server['REQUEST_METHOD'] == 'POST') {

better this way: (this is the solution to enable currency-change also in the "Basket")

if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['quantity'])) {

The reason is: If any other "plugin/extension" uses "POST" in the cart section, it will redirect again to "checkout/cart" without even accessing the "plugin/extension" code. I haven't checked in other codes, but I feel that every POST must be defined so it will only ignore the POST when do not belongs to it.

Done.

Re: When changing currency it do not stay in the same page...

Posted: Thu Mar 26, 2009 5:20 pm
by Qphoria
lepe wrote: if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['quantity'])) {

The reason is: If any other "plugin/extension" uses "POST" in the cart section, it will redirect again to "checkout/cart" without even accessing the "plugin/extension" code. I haven't checked in other codes, but I feel that every POST must be defined so it will only ignore the POST when do not belongs to it.
You hit the nail on the head :)
We did exactly this for 0.7.9 Final to get the "stay on same page" stuff working. Was worth it :)

Re: When changing currency it do not stay in the same page...

Posted: Thu Mar 26, 2009 8:10 pm
by Daniel
I tried doing this myself, but found certain pages buggy.

I sopose I could do it with a redirect.