Skip to main content

hikashopUpdateVariant()

More
11 years 5 months ago - 11 years 5 months ago #199302 by bonzomedia
-- HikaShop version -- : 2.4.0
-- Joomla version -- : 2.5

Hi,

I am trying to make a feature in my store which is a "shop by fragrance". In this mode the visitor selects the fragrance that they are interested in and is then presented with products that are available in that fragrance and when they get to the product page that fragrance is automatically selected (and the characteristic option is hidden).

This allows me to have only one product (with variants) and to have two modes of shopping, one where the visitors selects the product and then chooses their fragrance and one where they select the fragrance up front.

So, I've developed some code which knows which fragrance they have selected and when the product detail page is loaded it sets the characteristic option box to select that fragrance. I noticed however, that when the Add to Cart button is clicked that it wasn't picking up the pre-selected fragrance. So, I added a call to hikashopUpdateVariant passing the select object for that characteristic. However, it's still not working.

Although I appreciate that this may be tending towards developer support, I'd really appreciate some help!

Here's my code in show_default.php
Code:
<script type="text/javascript"> document.addEventListener("DOMContentLoaded", function() { DoSetFragrance(); }); function DoSetFragrance(){ var CurrentFragrance = document.getElementById("Fragrance").innerHTML; var FragranceSelector = document.getElementById("hikashop_product_characteristics"); //FragranceSelector.style.display = "none"; window.alert("called with "+CurrentFragrance); var SetFragrance = document.getElementById("hikashop_product_characteristic_5"); var i; for (i = 0; i < SetFragrance.length; i++) { if (SetFragrance.options[i].text == CurrentFragrance) { SetFragrance.value = SetFragrance.options[i].value; } } } hikashopUpdateVariant(document.getElementById("hikashop_product_characteristic_5")); </script>

I know that the code is being called as it correctly sets the selected fragrance, it's just the hikashopUpdateVariant() function I'm having trouble with...
Last edit: 11 years 5 months ago by bonzomedia. Reason: specified view function name

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

More
11 years 5 months ago #199343 by bonzomedia
Replied by bonzomedia on topic hikashopUpdateVariant()
Darn, Just noticed I posted this in the wrong category - please move to product/display. Sorry!

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

More
11 years 5 months ago #199322 by nicolas
Replied by nicolas on topic hikashopUpdateVariant()
Hi,

As far as I can see, the issue is that you put the call to hikashopUpdateVariant outside of the DoSetFragrance.
This means that the hikashopUpdateVariant call is made when the page is parsed, before the call to the DoSetFragrance function which sets the correct value in the dropdown and thus the id of the variant currently selected is not updated after you change the characteristic dropdown selection.

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

More
11 years 5 months ago #199407 by bonzomedia
Replied by bonzomedia on topic hikashopUpdateVariant()
Nicolas - thanks very much. I am considering slapping myself around the head!

Working perfectly now, thanks!!

:)

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

Time to create page: 0.167 seconds
Powered by Kunena Forum