I'm new to cartthrob and want to know how can a product be automatically deleted if that product has been purchased from current logged in user. Let's see it as a scenario I'm logged out and I add that product into cart and while checkout I get asked to login and After I login that product gets added to cart even if I've already purchased that product to cart....so please tell me how can I remove that product automatically in Expressionengine cartthrob?
1 Answer
You'll need to create an extension on the cartthrob_add_to_cart_start
hook. This hook runs right before the process of adding an item to the cart so you can check if the member has purchased said product and then apply the end_script
value and stop execution to meet your needs
-
Can you explain a bit more I mean where can I find this hook? Is it in Cartthrob addon file?– RamCommented Nov 30, 2023 at 10:25
-
Yeah, it's within the CartThrob Add-on. There are 2 calls to it, the Tag and Action. If you're using the add_to_cart_form tag already, you'll want the Action one located at
cartthrob/src/Actions/AddToCartAction.php
Commented Dec 2, 2023 at 2:36