Product not added to cart, cookies

  • Posts: 7
  • Thank you received: 0
3 years 1 month ago #330265

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.20
-- PHP version -- : 7.2.34
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : Product not added to the cart
This operation can only work if you accept the use of cookies

Hello, I am allowing one of my hikamarket vendors to embed their vendor category on their own website. If you view the link I provided you'll see that it's working pretty nice (white section on homepage below main showcase area of site). However when I click on a product and then click the add to cart button from this site where it's embedded, the product cannot be added to the cart and it shows the message. Product not added to the cart. This operation can only work if you accept the use of cookies. I have added an attachment showing a screenshot of this. Why is this message showing up? My browser has cookies enabled and the message is clearly a system type message from hikashop.

Attachments:

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

  • Posts: 81483
  • Thank you received: 13062
  • MODERATOR
3 years 1 month ago #330267

Hi,

That's because to be able to maintain a cart across different pages of the website, HikaShop needs to link the cart to the current PHP user session. That way, as long as the user session's lifetime is not finished, the cart is accessible.
And for PHP / Joomla to maintain the user session, it needs to set some cookies.
However, when you embed a website page in another website page using an iframe, cookies are blocked by browsers:
codethatcounts.com/setting-cookie-in-ifr...in-different-domain/
And thus, the session cannot be maintained by PHP and because of that the cart will be lost from one page to the other.
This normally happens when cookies are disabled by the customer, which is why HikaShop displays that error message.
Now apparently, since PHP 7.3, there is a setting in php.ini to circumvent that:
stackoverflow.com/questions/59534999/how...r-cross-site-cookies
Now I'm not sure if you need to do that in the php.ini of your website or the one of your vendor or both.

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

Time to create page: 0.065 seconds
Powered by Kunena Forum