ZiedDams Posted February 21, 2022 Share Posted February 21, 2022 I want to make the Cart accept only one product in a way that: when i add a product to the cart it erase the old one and put the new product in place , I actually found some content on this topic, But it's so old, And they give a solution that display an error in the front office if a user add more then one product to the cart, Which is not my case . I know that i have to Override controllers/front/CartController.php But i don't know what function i should modify and what to write in place Link to comment Share on other sites More sharing options...
Ress Posted February 21, 2022 Share Posted February 21, 2022 You can use the "actionCartUpdateQuantityBefore" hook, check in parameters which product is added to the cart, and if it is different, you can delete the current product. But I think it would be okay to delete directly through a query, not to use a method, so as not to call that hook again. 1 Link to comment Share on other sites More sharing options...
ZiedDams Posted February 22, 2022 Author Share Posted February 22, 2022 16 hours ago, Ress said: You can use the "actionCartUpdateQuantityBefore" hook, check in parameters which product is added to the cart, and if it is different, you can delete the current product. But I think it would be okay to delete directly through a query, not to use a method, so as not to call that hook again. Thank you for this solution, yeah it's a good idea, without even overriding the CartController.php Great Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now