News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How to remove products from the cart via PHP? Or prevent the adding of products

Started by Kuubs, May 26, 2024, 12:01:24 PM

Previous topic - Next topic

Kuubs

How can I remove products from cart via php? Or prevent the adding of products via PHP? I tried returning false in the cart.php but it's not working, the product is still being added.

Okay I found the following:

unset($cart->cartProductsData[$k]);
$cart->setCartIntoSession();
$cart->prepareCartData();

i have coded this into the main cart file, but that is a core chagne which isn't a good practice. So now I need to use a plugin and probably use one of the hooks, but i', not sure which one yet so i need to keep reseraching to find the answer, if anyone knows, I'll be advised!