hikashopUpdateVariant not setting the variant!

  • Posts: 131
  • Thank you received: 7
7 years 4 months ago #273501

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.1
-- PHP version -- : 7.1.2
-- Browser(s) name and version -- : chrome/safari latest on mac
-- Error-message(debug-mod must be tuned on) -- : no error

I have a customised view (which is working fine on a live hikashop 2.x site).

In this view I am automatically setting a variant's value via a Javascript call (depending on where the user is in the site).

Basically, I use the following logic:-

1. I check to see if the page is in the section of the site where I need to set the variant.
2. If it is:-
I get the specific characteristic element (hikashop_product_characteristic_5)

var SetFragrance = document.getElementById("hikashop_product_characteristic_5");
I get the specific characteristic container and hide it (as I'm setting it automatically)
I set the variant using:-
SetFragrance.value = the_characteristic_option_id;
And then call hikashopupdatevariant with the SetFragrance option
hikashopUpdateVariant(SetFragrance);

I have checked and double checked my logic (which is working on 2.5) but when I click the Add to Cart button the variant is not set, and it adds the product with the last variant option in the list.

I've convinced myself that there has been a change in the way that the Hikashop add to cart code works!

Any help or pointers you can provide would be useful! Have shared the front end URL in private - happy to provide back end access.

Thanks!

Last edit: 7 years 4 months ago by bonzomedia.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
7 years 4 months ago #273528

Hi,

The problem is not with that code.
We didn't change anything regarding that since HikaShop 2.5 and your code still works.
The problem is that the hidden variants data is inside the form of the page on your link while it should normally be outside. So because of that, regardless of what you select in the dropdowns, the last variant listed in the hidden data is the one added to the cart when you use the add to cart button.

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

Time to create page: 0.055 seconds
Powered by Kunena Forum