Allow backorders > How to create Backorder option when item is out of stock?

DoubleTap_8522
New Member
1 0 0

I am creating custom code for my client who wants to allow backorders in case the quantity of the stock drops below 1.

I noticed some weird behaviour in case I check the "continue selling when out of stock" option.

 

My first issue is that Shopify automatically:

- Disables the button. (which is opposite from the idea)

- Adds "Sold Out" label to the button. (you can change the text of sold out in "language settings" but that doesnt solve the previous issue..)

I found a lot of topics around backorders here but none really offered a straightforward solution from a developers point of view.

I find it hard to believe this simple features are simple implemented backwards in Shopify.

 

My inelegant solution for this here below.

My Code:

 

 

 

{% if current_variant.inventory_quantity > 0 %}
             <button type="submit" name="add" id="AddToCart" class="btn btnAddToCart">
                <i class="icons icon-handbag"></i>
                  <span id="AddToCartText">   {{ 'products.product.add_to_cart' | t }} </span>
               </button>
 {% else %}
        <button type="submit" name="add" id="AddToCart" class="btn btnAddToCart">
                <i class="icons icon-handbag"></i>
                <span id="AddToCartText">   {{ 'products.product.add_to_cart' | t }} </span>
               </button>
             <div class="backorder-div">
                    <p class="backorder-text">
                      <span><i class="fa fa-warning fa-sm"></i>  Available On Backorder</span>
                     <p>
             </div>
{% endif %}

 

 

 

 

Hope this helps someone who has the same issue and doesn't want to lose time.

0 Likes