Injecting articles into cart

  • Posts: 45
  • Thank you received: 0
8 years 8 months ago #231981

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8

Hi,

For a customer I build a form to inject products in the cart from another page, outside Hikashop. It works fine for the most part, products are being added to the cart correctly.

There is only one problem:
If someone does not have a cart yet, before the injection, people only see the added products if they log out and log back in again. So if they do not logout first, they do not see the cart with the added products.

So if someone already had a cart, the products are visible right away in the cart.

Can you advise me how to show the (new) cart without requiring the user to log out first?

Thanks for your help!

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 8 months ago #231986

Hi,

That's probably because of the wayt the cart is initialized when you add the products to it.
Normally, you're supposed to call the update function of class.cart in order to add your products to the cart and in that function, the cart is initialized with a call to the initCart function of the same class.

The following user(s) said Thank You: Squashtoppertje

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

  • Posts: 45
  • Thank you received: 0
8 years 8 months ago #232055

HI Nicolas,

Thanks for your reply.

At this moment I use a regular sql update or import function to get the data into the hikashop_cart and hikashop_cart_product tables.

Should I use the initCart function in some way to make sure the user does not need to login to see the updated cart? Can you give a hint how to go about it?

Thanks.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 8 months ago #232068

Hi,

If you do it with SQL, then that's normal. The cart needs to be referenced in the user session of the user. That is done either when you add a product to the cart with the update function of class.cart, or when the user logs in.

I would recommend to use the update function to add the products. It's way easier.
www.hikashop.com/forum/2-general-talk-ab...ct-fields.html#19192

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

Time to create page: 0.063 seconds
Powered by Kunena Forum