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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.