[eluser]tkaw220[/eluser]
Hi,
My shopping cart has 3 type of currencies. When customer change currency while there are items inside the shopping cart, the cart must be able to convert the price according to the new currency. I had came out with below codes, but the prices inside the $this->cart->contents() is not updated as expected. Any help to fix this would be appreciated.
if ($this->cart->contents())
{
foreach ($this->cart->contents() as $items)
{
$rowid = $items[‘rowid’];
$id = $items[‘id’];
// get new price from database
$this->db->select(‘price_usd’);
$this->db->where(‘id’, $id);
$price = $this->db->get(‘products’)->row();
$new_price = $price->price_usd;
$data = array(
‘rowid’ => $rowid,
‘price’ => $new_price
);
$this->cart->update($data);
}
}
Thanks.