What's your biggest current challenge? Have your say in Community Polls along the right column.

Select specific variant option value of a specific option inside product page

Select specific variant option value of a specific option inside product page

kreations
Tourist
5 0 1

Dawn v9

I have two line line item property fields on a product page (buy-buttons-custom.liquid).

 

 

 

<p class="line-item-property__field">
  <label for="length">length</label><br>
  <input required class="required" id="length" type="text" onblur="changeoptionvalue()" name="properties[length]">
</p>
<p class="line-item-property__field">
  <label for="width">width</label><br>
  <input required class="required" id="width" type="text" onblur="changeoptionvalue()" name="properties[width]">
</p>

 

 

 

I created this function (global.js):

 

 

 

  function changeoptionvalue(){
    var length = +(document.getElementById("length").value);
    var width = +(document.getElementById("width").value);
    var total = length + width;
    
    if (total<20) {
      selector.selectVariant("44380039577868", selector); //not working
       //here i want to select option value x of option z 
    } else {
      //here i want to select option value y of option z 
    } 
}

 

 

 

 How can i code to select a specific option value of a specific option inside a product page?

Replies 0 (0)