kenwarr
kenwarr

Reputation: 85

Prestashop 1.4 Issue on cart update (currency conversion)

I have a weird issue when I do the $cart->update(); after changing the currency

e.g. in pounds the total amount from the cart is £896.32 with the current conversion rate 1.388889 (to EUR)

so, in EUR it should be 896.32 * 1.388889 = 1244.89 (rounded 2)

BUT If I'm on checkout and on payment module I do:

$cookie->id_currency = 1; //1 for EUR
$cart->id_currency = $cookie->id_currency;
$cart->update();
//and then...
$amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');

it goes completely wrong... the final $total variable is wrong.

DEBUG CONSOLE: BEFORE $cart->update();

$cart   Smarty_Variable Object (3)
->value = Cart Object (14)
   ->id = 2899
   ->id_address_delivery = "5"
   ->id_address_invoice = "5"
   ->id_currency = "3"
   ->id_customer = "3"
   ->id_guest = "998683"
   ->id_lang = "1"
   ->id_carrier = "14"
   ->recyclable = "1"
   ->gift = "0"
   ->gift_message = ""
   ->date_add = "2015-12-09 10:08:27"
   ->secure_key = "5b5c81dbecc7b7e1d9603752071321b7"
   ->date_upd = "2015-12-09 17:17:15"
->nocache = false
->scope = "Smarty root"


$total  Smarty_Variable Object (3)
->value = "£896.32"
->nocache = false
->scope = "Smarty root"

AFTER $cart->update();

$cart   Smarty_Variable Object (3)
->value = Cart Object (14)
   ->id = 2899
   ->id_address_delivery = "5"
   ->id_address_invoice = "5"
   ->id_currency = 1
   ->id_customer = "3"
   ->id_guest = "998683"
   ->id_lang = "1"
   ->id_carrier = "14"
   ->recyclable = "1"
   ->gift = "0"
   ->gift_message = ""
   ->date_add = "2015-12-09 10:08:27"
   ->secure_key = "5b5c81dbecc7b7e1d9603752071321b7"
   ->date_upd = "2015-12-09 17:19:41"
->nocache = false
->scope = "Smarty root"

$total  Smarty_Variable Object (3)
->value = "1 239,67 €"
->nocache = false
->scope = "Smarty root"

as you can see, that 1 239,67 € is wrong and should be 1 244,89 €, instead.

Please, Where is the error? I'm going crazy for that. Thank you very much for your help.

Upvotes: 0

Views: 264

Answers (1)

kenwarr
kenwarr

Reputation: 85

FOUND the issue

there is the additional_shipping_cost field on database which is not updated when you change currency. I don't know if in the latest PS versions the behavior is different, but that is an oversight by developers for sure.

Upvotes: 0

Related Questions