I’m using the Cart class in Codeigniter. What I want to do should (hopefully!) be simple… but i’m struggling.
On the product page, I have a button to ‘add to cart’. What I want to happen is that when the item is already in the cart, the button changes to ‘remove from cart’.
<? //if(**not in cart**) { ?>
<a href="<?=base_url()?>jobs/addjob/<?=$row->id?>">Add to cart</a>
<? } else { ?>
<a href="<?=base_url()?>jobs/removejob/<? /**cart 'rowid'**/ echo $rowid?>">Remove from cart</a>
<? } ?>
How can I query the cart to see if that item is in there or not and get the ‘rowid’ so I can use that for a remove function?
Many thanks!
I had a similar problem – I got round it by extending the CI_Cart library with 2 new functions – in_cart() and all_item_count().