How to create Backorder button instead of Add to Cart when item is out of stock?

Tourist
12 0 1

Hi everyone,

I am about to launch my store selling books about sales, success, leadership, entrepreneurship, self-development and so on. My soon-to-be book supplier has a Backordering possibility as well, meaning if the book is out of stock, they will Print it on Demand and it can take up to 2 weeks and then it will get shipped.

So when an item is out of stock, how do I make it so that instead of the Add to Cart button, the button says something like "Out of Stock - Backorder - Item will ship within 2 weeks" and maybe another confirmation in the email or in the form of a pop-up or something.

I tried using this Shopify tutorial: https://help.shopify.com/en/themes/customization/products/add-to-cart/allow-pre-orders#inventory-lev...
but I did not have certain lines of codes in my files that I needed to edit or replace with some other line.

I have the Brooklyn theme. And if you'd like the password to my page just ask as the site is not open to public yet :)


Thank you! :)

0 Likes
Excursionist
32 0 6

Hey, I am not sure which step you weren't able to locate in that guide, but if you are in the product-form.liquid that is likely where the add to cart button is. Then you'd just setup an if statement to change the logic. You would need to make sure that all of your items are set to be able to be purchased when they are out of stock. That is a button next to the inventory on each product. (Allow items to be purchased when out of stock). Then in the product form you would need code such as this:

{% if variant.inventory_quantity > 0 %}
ADD TO CART
{% else %}
BACK ORDER
{% endif %}

 

1 Like
Tourist
12 0 1

Thanks so much Dylan! That was exactly what I needed. Got it working now :)

Edit: I had to change

{% if variant.inventory_quantity > 0 %}

to 

{% if current_variant.inventory_quantity > 0 %}

because otherwise it showed all of my products Backorder instead of Add to Cart for the available ones.

Thanks!

0 Likes
New Member
1 0 0

This partially works for me but I have to refresh the page to have it update backorder vs add to cart when I select the different varient options. It will not change with out refreshing the page..

0 Likes