VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Kuubs on May 26, 2024, 12:01:24 PM

Title: How to remove products from the cart via PHP? Or prevent the adding of products
Post by: Kuubs on May 26, 2024, 12:01:24 PM
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!