- Posts: 4
- Thank you received: 0
Remove a product automatically
11 years 6 months ago #194034
by IanH
Remove a product automatically was created by IanH
-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4.31
Hi,
I would like to check if there is just one product left in the cart and if it is a particular product id, remove it automatically.
I have tried using "onBeforeCartUpdate()" to inspect the cart but both the cart and cartClass parameters always have zero products in them regardless of the cart contents. Anyone know of any example code other than that on the developer documentation section of the help pages that could point me in the right direction ?
many thanks,
I
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4.31
Hi,
I would like to check if there is just one product left in the cart and if it is a particular product id, remove it automatically.
I have tried using "onBeforeCartUpdate()" to inspect the cart but both the cart and cartClass parameters always have zero products in them regardless of the cart contents. Anyone know of any example code other than that on the developer documentation section of the help pages that could point me in the right direction ?
many thanks,
I
Please Log in or Create an account to join the conversation.
11 years 6 months ago #194038
by Xavier
Replied by Xavier on topic Remove a product automatically
Hi,
First of all, I think that you should use the onAfterCartUpdate() this way you have the cart content after the previous operation.
Then you can use such kind of code:
To get all the products of the cart, and then do checks on the $products PHP object.
First of all, I think that you should use the onAfterCartUpdate() this way you have the cart content after the previous operation.
Then you can use such kind of code:
Code:
$products = $cartClass->get($cart->cart_id,true,'cart');
The following user(s) said Thank You: IanH
Please Log in or Create an account to join the conversation.
11 years 6 months ago #194304
by IanH
Replied by IanH on topic Remove a product automatically
Thank you - that worked perfectly.
Please Log in or Create an account to join the conversation.
Time to create page: 0.451 seconds