Do not include Out of Stock items in dropdown, when using Buy Button

New Member
2 0 0

Hi,

We have configured a Buy Button for one of your collections to display on one of our other sites.

However, when the first variant to be displayed is out of stock, it still shows up in the options and the "Add to Cart" button changes to "Out of Stock", making it look like all of the variants are probably out of stock. But if you do select a variant that is in stock, you can then click the "Add to Cart" button.

Is there something we can add to the javascript code to make the variant drop down not include out of stock options and only include available options, so that "Out of Stock" never appears and only variants that are in stock appear? See attachments for reference.

 

I see in that there is 'variantInStock'  at https://github.com/Shopify/buy-button-js/blob/master/src/components/product.js, but I don't know how use that within the buy button configuration (https://shopify.github.io/buy-button-js/advanced/).

Thank you very much for your help.

-Matt

 

Screen Shot 2020-11-24 at 2.28.33 PM.pngScreen Shot 2020-11-24 at 2.28.44 PM.png

0 Likes
New Member
1 0 0

hide the dropdown option when variant.inventory_quantity=0 ... jQuery(function() { {% if product.variants.size > 1 or product.options.size > 1 %} new Shopify. ... page the Sold Out button still displays, yet I can still add the product/variant to cart normally. ... It may look like you are not offering many sizes.

0 Likes