-- 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
<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...