Jump to content

cart global/context problem - information not updating id_currency


Recommended Posts

Hello,

 

I have a strange with cart being from context.

The code below does not work:

 

p($this->context->cart);
echo "before"; // id_currency is 1 before
echo $this->context->cart->getOrderTotal(true, Cart::BOTH);
$this->context->cart->id_currency = 2;
$this->context->cart->update();
$amount = number_format($this->context->cart->getOrderTotal(true, 3), 2, '.', '');
p($this->context->cart);
echo "amount";
p($amount);

 

so the problem is that I try to change the currency in the cart, it gets changed in DB table too - I can see 2 instead of 1 in id_currency field, bet the amount before and after is the same and it does not get transferred to other currency.

 

Is it me here not seeing something, or is there a problem with these two lines

 // Define virtual context to prevent case where the cart is not the in the global context
 $virtual_context = Context::getContext()->cloneContext();
 $virtual_context->cart = $this;

 

in Cart class getOrderTotal method?

Link to comment
Share on other sites

  • 6 months later...
  • 7 months later...
  • 11 months later...
×
×
  • Create New...