Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2015 14:27
What would you like to do?
CodeIgniter Cart Extend for insert to add
class MY_Cart extends CI_Cart {
private function _is_identical($a, $b) {
return $a == $b;
public function insert($data) {
foreach ($this->contents() as $item) {
if ($item['id']==$data['id'] && $this->_is_identical($item['options'],$data['options'])) {
$update_data = array(
'rowid' => $item['rowid'],
'qty' => ($item['qty']+1)
return $item['rowid'];
return parent::insert($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment