Forum
Delete Cart item using ajax
Hi there,
Is there any chance to delete an item from the cart using ajax? I can see in cart view i have the product ID however there is no perch function that allow me to delete that single item from my cart.
Any help is appreciated.
Thanks, Vince.
You can use
perch_shop_remove_from_cart(123)
Thanks Drew,
I could not find that function.
Vince.
Are you getting an error?
No all good, it works.
Thanks, Vince.
Actually Drew i noticed something strange...
Now i have in my cart.php page
i call this page via ajax passing the idProduct as parameter and append the new result that i get from perch_shop_cart();
It seems working indeed i can see that when i append the new cart i cannot see the product deleted anymore. However if i try to add the same product which i deleted before it will be added twice in the cart.
Any thoughts?
Thanks.
Presuming that
$_REQUEST['idProduct']
is accurate for your context, you'll want to use: