characteristics not processed when added to cart

  • Posts: 73
  • Thank you received: 1
11 years 2 months ago #121519

-- url of the page with the problem -- : exo-l.com/shop2/exo-l
-- HikaShop version -- : 1.6
-- Joomla version -- : 2.5
-- PHP version -- : 5.3.3
-- Browser(s) name and version -- : Firefox 25 or something

If you take a look at my page you see that I have two products on a single page. Everything works great except for the fact that the characteristics of the "rechts" (right) product are not processed when added to the cart. The product always has the same characteristics but the extra field "gravure" does work.

I'm curious where I could be going wrong. I checked the "hikashopUpdateVariant" and all the characteristics are grabbed correctly.

What is the line of processing so I can debug every step and see where the problem lies? As in, when I click the add to cart button, how can I see where/why my characteristic is not added to the product in the cart.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 2 months ago #121570

Hi,

When you click on the add to cart button, it submits the form of the button. Inside it, there is the hidden input with the id hikashop_product_id_main which contains the product id or current variant id if your product has a characteristic.
Your issue is that you have twice that hidden input field on your page (one for each product form) and when you select another characteristic variant for a product, the javascript replaces the id in that hidden input using its id, but since the id is not unique on the page, it's not replacing the correct one and you don't get the id of the variant updated. Which means that you always get the default variant added in the cart in that case.
The solution is to change the javascript function which handle the copying of the id (and the other product data) when you select another characteristic variant so that it copy the data in the correct elements.
That's done by the hikashopUpdateVariant javascripti function call of your color selectors and you will find the JS code of that function in the file administrator/components/com_hikashop/types/characteristic.php

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

  • Posts: 73
  • Thank you received: 1
11 years 2 months ago #121764

which line copies the correct characteristic id to that hidden field? Because I can grab the right "selection" variable. That one is correct.
But apparently the default value is still being submitted. This means that the selection which I grab correctly is not copied into the hidden field of the "right" product. It's in the "left" product. Where is this copying happening? In hikashopUpdateVariantData?
The selection variable arrives correctly there.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 2 months ago #121772

Yes.
As I said, the issue is that the two hidden input fields for the product_id have the same HTML id. So the hikashopUpdateVariantData always copy the data in the first product hidden input.

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

Time to create page: 0.055 seconds
Powered by Kunena Forum