Remove a product automatically

  • Posts: 4
  • Thank you received: 0
10 years 2 months ago #194034

-- 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

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 2 months ago #194038

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:

$products = $cartClass->get($cart->cart_id,true,'cart');
To get all the products of the cart, and then do checks on the $products PHP object.

The following user(s) said Thank You: IanH

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 0
10 years 2 months ago #194304

Thank you - that worked perfectly.

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum