Jump to content

Codeigniter cart problem


c_pattle

Recommended Posts

I have a checkout section of my website where the user can apply coupons code to certain items in the cart.  When the user enters a coupon code it changes the price of the item in the cart.  Because you can't just update the price I am deleting the old cart item and then re inserting it.  However when I do this some of the items don't seem to get re-inserted.  I think it's the items with things like brackets in the product name.  My code is below

 

//Create an array of product details
$newItem = array(
    'id' => $items['id'],
    'name' => $items['name'],
    'qty' => $items['qty'],
    'price' => number_format($newPrice, 2),
    'supplier' => $items['supplier'],
    'coupon' => $coupon,
    'full_price' => $items['price'],
     'type' => $items['type']
);

//Create an array to remove the item from the cart
$data = array(
    'rowid' => $items['rowid'],
    'qty'   => '0'
);
                                    
$this->cart->product_name_rules = '[:print:]';

//Remove the item then re-insert it
$this->cart->insert($newItem);
$this->cart->update($data);

 

Can anyone see what I'm doing wrong?  Thanks for any help

Link to comment
https://forums.phpfreaks.com/topic/259794-codeigniter-cart-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.