"codeigniter 4" cart code example
Example 1: "codeigniter 4" cart
$cart = cart();
$cart->insert(array(
'id' => 'sku_1234ABCD',
'qty' => 1,
'price' => '19.56',
'name' => 'T-Shirt',
'options' => array('Size' => 'L', 'Color' => 'Red')
));
$cart->update(array(
'rowid' => '4166b0e7fc8446e81e16883e9a812db8',
'id' => 'sku_1234ABCD',
'qty' => 3,
'price' => '24.89',
'name' => 'T-Shirt',
'options' => array('Size' => 'L', 'Color' => 'Red')
));
$cart->totalItems();
$cart->remove('4166b0e7fc8446e81e16883e9a812db8');
$cart->destroy();
$cart->contents();
Example 2: "codeigniter 4" cart
function cart(bool $getShared = true)
{
return \Config\Services::cart($getShared);
}
Example 3: "codeigniter 4" cart
public static function cart($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('cart');
}
return new \App\Libraries\Cart();
}