c_pattle Posted March 27, 2012 Share Posted March 27, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259794-codeigniter-cart-problem/ Share on other sites More sharing options...
sKunKbad Posted March 30, 2012 Share Posted March 30, 2012 It would be a better and easier strategy to leave the price in the cart as full price, but compute the checkout total based on the status of the coupon being applied. Quote Link to comment https://forums.phpfreaks.com/topic/259794-codeigniter-cart-problem/#findComment-1332604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.