[Skip to main content](#vessel-content)

#   Injecting articles into cart

##

- **[Squashtoppertje](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")**
- [![Squashtoppertje's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile") Topic Author
- [ Offline](/forum/user/39506-squashtoppertje)

Less More

- Posts: 45
- Thank you received: 0
-
-

10 years 8 months ago [\#231981](#231981) by [Squashtoppertje](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")  *[Injecting articles into cart](/forum/31-development/882761-injecting-articles-into-cart#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!")* was created by *[Squashtoppertje](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")*

-- 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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mjc2MS1pbmplY3RpbmctYXJ0aWNsZXMtaW50by1jYXJ0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14296
-
-

10 years 8 months ago [\#231986](#231986) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Injecting articles into cart](/forum/31-development/882761-injecting-articles-into-cart#231986 "-- 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!")*

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](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mjc2MS1pbmplY3RpbmctYXJ0aWNsZXMtaW50by1jYXJ0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Squashtoppertje](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")**
- [![Squashtoppertje's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile") Topic Author
- [ Offline](/forum/user/39506-squashtoppertje)

Less More

- Posts: 45
- Thank you received: 0
-
-

10 years 8 months ago [\#232055](#232055) by [Squashtoppertje](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")  Replied by *[Squashtoppertje](/forum/user/39506-squashtoppertje "View Squashtoppertje's Profile")* on topic *[Injecting articles into cart](/forum/31-development/882761-injecting-articles-into-cart#232055 "-- 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!")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mjc2MS1pbmplY3RpbmctYXJ0aWNsZXMtaW50by1jYXJ0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14296
-
-

10 years 8 months ago [\#232068](#232068) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Injecting articles into cart](/forum/31-development/882761-injecting-articles-into-cart#232068 "-- 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!")*

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](http://www.hikashop.com/forum/2-general-talk-about-hikashop/16216-add-to-cart-link-and-custom-product-fields.html#19192)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mjc2MS1pbmplY3RpbmctYXJ0aWNsZXMtaW50by1jYXJ0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.071 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
