Quantity Left Div and Limit Quantity Selector for multiple variants in Reach Theme

SPW
New Member
2 0 0

Hi all,

Hoping you can help me out here - I realise there are quite a few posts on this/these subjects, but none have got me there.

The main issue I'm having is finding where in the theme.js (reach by pixleunion) to edit.

For the "Quantity Left" div - I've got the following, located in quantity.liquid:

{% comment %} Inventory Quantity {% endcomment %}
<div id="variant-inventory">
 {% if product.variants.first.inventory_management == "shopify" %}
    {% if product.variants.first.inventory_quantity == 1 %}
       Only one left!
    {% else %}
       
    {% endif %}
 {% else %}
    
 {% endif %}
</div>
{% comment %} END Inventory Quantity {% endcomment %}

 

And for limiting the quantity selector:

max="{{ product.selected_or_first_available_variant.inventory_quantity}}"

 

These work fine if there is only one variant - but for multiple variants they're based on the "first" variant, and need some javascript to switch depending on the selected variant.  Given the first code above has "product.variants.first.inventory_management" this will need to be changed too.

Many of the other posts on this subject mention finding "if (variant", or the selectCallback etc.  I'm unable to locate anything in the theme.js file that is remotely related to the variants, inventory and quantities.  Can anybody point me in the right direction?

I do have a tiny bit of knowledge of JS, and have successfully adapted and edited stuff in the past - i'm just really struggling with this theme.js (reach.js) file for some reason.

Many thanks for any help / direction!

Simon

 

 

0 Likes
SPW
New Member
2 0 0

Anybody?! 

0 Likes