Cart API needs some improvement...

  • Posts: 40
  • Thank you received: 2
11 years 6 months ago #106544

Hi guys,

I have been doing some custom development around Hikashop's API's and I came to a point where I need to know exactly which product's removal (or subtraction of quantity) has triggered an

onBeforeCartUpdate

-- or --

onAfterCartUpdate

event.

Unfortunately the product_id that is passed in the parameters, doesn't hold this info. I don't know if this is by design or a bug.

I have found that there is an array ($cartClass->new_quantities) which holds the product_id as the key and the quantity that was modified as the value, but I am not sure how reliable this is, in order to use it. Could you comment on that?

Thanks,
Frank

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 6 months ago #106548

product_id contains the new quantity as value of the table for each product id (keys of the table). And it will be 0 if the product is removed.

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

  • Posts: 40
  • Thank you received: 2
11 years 6 months ago #106549

Yes, but there is no product id. How do I get the product id (and possibly quantity) which was removed?

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 6 months ago #106551

As I said in my message the product ids are the keys of the array.
In fact to be more precise, the keys of the array are the values of the column "cart_product_id" which identify each product line of the cart.

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

  • Posts: 40
  • Thank you received: 2
11 years 6 months ago #106553

Ahh, yes just checked. This works, yes, thank you very much.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum