Jump to content

Empty shopping cart from code


gbir

Recommended Posts

Hi

 

Can anybody give me a hint on how to completely empty the shopping cart from code (even if more products are in the cart)? Is there already a method that can do that?

My goal is that the user can only have products of one manufacturer in his cart. Therefore, as soon as he adds a product of another manufacturer, I would empty the cart before adding the last product.

 

Thank you in advance, bye

Giorgio

Link to comment
Share on other sites

the Cart class would be used for most of this. i don't see an "empty" function. you could override the Cart class and add a function.

 

i would start by getting the current list of products in the cart

$cart->getProducts(true)

 

that would return an array of products, so then you would iterate through the array using a foreach statement, and call the delete function for each product

$cart->deleteProduct($id_product, $id_product_attribute, $id_customization);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...