Hi, I wonder if anyone can help me with this. The intention is, if a product/variant has 0 inventory quantity and the “continue to sell when out of stock” option for that product/variant is checked, then display “Pre-order Now” on the buy button instead of the default “Add to Cart”
I make some changes to the “buy buttons” block in main-product.liquid file, inside the add to cart button, the code basically says if select variant is available and inventory is not greater than 0, then buy button label is “Pre-Order Now”, if the select variant is available and inventory is greater than 0, then show the default label “Add to Cart”:
To test the function, I created a sample product with 3 variants with all the variants enabled continue to sell when out of stock. After implementing this, upon visiting the product page, the buy button did display “Pre-Order Now” if requirements are met as shown in the screenshot below as desired:
However, the above is the only situation in which the button label is “Pre-Order Now”. Once other variants are selected, the “Pre-Order Now” will not show, even when I set all variants to “continue to sell when out of stock”, shown as screenshots below.
Even when selecting the first variant again, the button label shows “Add to Cart” instead of “Pre-Order Now”.
Can anyone help with why this is happening and possible solutions?
Website url: https://rug-rug-australia.myshopify.com/products/test-product-2?variant=41018292273358
password: owcowg