Where to find the selectCallback on the minimal theme

Highlighted
Shopify Partner
10 0 0

Hi everyone,  does anyone has ideas where "selectCallback" is located on the minimal theme? Or do i need to add it?

 

Iv'e been following all the step in : https://help.shopify.com/themes/customization/products/show-inventory-quantities

now im at step 4. I'm using the minimal theme but i can't find  the :

var selectCallback = function(variant, selector) {

It  not in the theme.liquid  or the product.liquid. i event look in the product-template.liquid

Any help would be really appreciate iv'e been looking on many support and forums but i can't find no answer.

 

 

 

 

0 Likes
Shopify Expert
9764 86 1510

First, let's start with a link to your store.

Minimal has made many different versions so seeing your site in action will help with indentification and result in more accurate advice being given.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Shopify Partner
10 0 0

Hi Jason,

 

Thanks for the repply. Here the link to my site: http://bit.ly/2jVT6NO 

 

I am using the "Fashion" version of the Minimal theme. But i can't find the selcetcallback function.Basically, i am trying to show the amount of quantity in each items variant following the Shopify tutorial " Show inventory quantities on product pages " I am able to do all the step beside the Step4 :

4 . Look for the selectCallback function:

If you are using multiple product variants, we'll need to check the inventory for that product, and update quantity accordingly.

Most Shopify themes will already have the selectCallback function. It is usually located towards the bottom of the theme.liquid file, or at the bottom of the product.liquid fileLook for this piece of code: 

var selectCallback = function(variant, selector) {

 

 

If anyone can help me fix this it would be very much appreciated :-) I did look the theme.liquid ,  product.liquid  and product-template.liquid but i can't see it

 

Thanks a lot for any pointer or help.

0 Likes
Shopify Partner
2563 39 583

Hi B,

As it is said at the beginning of that page "This document has not been verified to work with sectioned themes". Well it does not. Unfortunately, Shopify was not very quick updating their manuals to the current level. 

There is no selectCallback function anymore, and you have to look at the productPage function in your theme.js.liquid asset.

And you can basicall put that piece of code right above //Show SKU comment.

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com! My post solved your problem? This is my Paypal too :)
1 Like
Shopify Partner
10 0 0

Hey Tim,

 

Thanks for the heads up! Work perfectly ! Very much appreciated. You ROCK!!! hehe! 

Just one more question :  If i want to show only the quantity when there is less than 5 product left.  I try adding this  :

 if (variant.inventory_quantity <= 5) {

 

But it changes the appearance of my product page and didn't work on all product..

Any ideas? 

 

Thanks 

All the best

 

0 Likes
Shopify Partner
2563 39 583

Hmm, can you share the code and where exactly your're putting it?

Because looking at your site it looks like you've put the code in the ProductVariant function, while it should be in the ProductPage, somewhere around  // Regardless of stock, update the product price, because I can not see the //Show SKU comment I suggested. 

You should not put the selectCallback function, just the code

if (variant) {
  if (variant.inventory_management == "shopify" && variant.inventory_policy != "continue") {
    if (variant.inventory_quantity > 5) {
       jQuery('#variant-inventory').text("Plenty available");
    }
    else if( variant.inventory_quantity > 0){
      jQuery('#variant-inventory').text('Only ' + variant.inventory_quantity + 'left in stock.');
    } 
    else {
      jQuery('#variant-inventory').text("This product is sold out");
    }
  } else {
    jQuery('#variant-inventory').text("This product is available");
  }
} else {
    jQuery('#variant-inventory').text("");
}

 

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com! My post solved your problem? This is my Paypal too :)
0 Likes
Shopify Partner
10 0 0

Hi Tim,

Thanks for the answer. I did put the new code just under the Select callback and it worked out perfectly :-). You are right about the ShowSKU is not there . I did found the Productpage. Im just not sure if i need to put the code above it or leave it where it is because it seem to work just fine.

Your help is really appreciated

 

Wish you all the best

0 Likes
New Member
9 0 0

Hi Tim and others,

Im still quite new to shopify and which files to edit and such. I have searched and tried all ways to show stock quantity on my product page.

So far i am able to show the quantity by putting in the 

 <div id="variant-inventory">
 {% if product.variants.first.inventory_management == "shopify" %}
    {% if product.variants.first.inventory_quantity > 0 %}
       We currently have {{ product.variants.first.inventory_quantity }} in stock.
    {% else %}
       The product is out of stock
    {% endif %}
 {% else %}
    This product is available
 {% endif %}
</div>

as everyone mostly has done but when i change the size of the product it does not change the stock quantity for that said size. My variant size is not dropdown and is a clickable button. I have yet to put the code below to any .js file because i am not able to find a theme.js in my files. I have tried putting it in files like  base.js and button.js but no changes.

if (variant) {
  if (variant.inventory_management == "shopify" && variant.inventory_policy != "continue") {
    if (variant.inventory_quantity > 5) {
       jQuery('#variant-inventory').text("Plenty available");
    }
    else if( variant.inventory_quantity > 0){
      jQuery('#variant-inventory').text('Only ' + variant.inventory_quantity + 'left in stock.');
    } 
    else {
      jQuery('#variant-inventory').text("This product is sold out");
    }
  } else {
    jQuery('#variant-inventory').text("This product is available");
  }
} else {
    jQuery('#variant-inventory').text("");
}

 

 

Could someone please help me out on this as i really have no clue what to do since most of other peoples websites use a dropdown variant selector and not a button one like mine. I have some basic coding knowledge but a step by step would be greatly appreciated. Thanks guys 

 

PS: im currently testing it out on a test copy of the theme so it is not live on my website.

 

- Ethian

0 Likes
Shopify Partner
2563 39 583

Hi Ethian, 

it looks like your theme does not have a place where to put the code, as there is no function which is called upon the variant change ;(

This can be implemented, but will require more code. 

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com! My post solved your problem? This is my Paypal too :)
0 Likes
New Member
9 0 0

Thanks for the hastly reply Tim! 

 

Any idea to what code i should implement? Or if you have come across any other users with this same problem that manage to get a solution.

Any resources will be helpful 

 

Thanks again Tim!

- Ethian

0 Likes