Menu Close

Get Support From ShopWired Close

All Systems Are Operational

Subscribe To Updates
Prefer To Live Chat? Chat directly with ShopWired support Available 9.00am to 7.00pm Monday to Friday
11.00am to 5.00pm Saturday
Quickest response time

Send A Message
Response within 24 hours

Menu Close

Menu

Back order

By default, customers cannot add items to their basket when the product (or product variation) is out of stock on your website. Both the ShopWired platform, and your theme prevent out of stock items from being added.

You can use the 'back order' extension to allow products to be added to the basket. Activating this extension enables the following functionality on your account:

• The ability to set whether, by default, items are purchasable or not purchasable when out of stock
• The ability to set whether an individual product should be purchasable, or not purchasable, when out of stock
• A global 'out of stock limit' on your account which sets by how much an item's stock can turn negative
• An 'out of stock limit' for an individual product (which overrides any global limit set on your account)

In order for customers to purchase out of stock items, changes to your theme are required.

ShopWired account functionality
Twig variables
Installation instructions (for version 2 themes or earlier)
Installation instructions (for version 3 themes or later)
Using custom fields


ShopWired account functionality

On installation of the extension you'll have access to some new features in your ShopWired account. These new features give you control over which products are allowed to be purchased when out of stock, and by how much (i.e. how negative the stock count for a product can go).


Account level features

Individual products will inherit the settings set on your account unless you set those settings individually for products.

To set your account level settings select 'settings' from the menu and then 'products'.

Scroll to the 'back order settings' section.

The setting 'out of stock products are...' has two options for you to choose from. If you select 'assumed to be purchasable' then all products (and their variations) will be assumed to be purchasable when out of stock. If you select 'assumed not to be purchasable' then all products (and their variations) will be assumed not to be purchasable when out of stock, so you'll have to individually select which products you do want to be purchased (described below).

The setting 'what global quantity limit should apply to out of stock products' sets by how much a product's stock level can go negative. For example, if you enter a value of 10 here and currently your product has 1 in stock, customers will be able to buy 11 (+1 - 11 = 10) of this item before the product can no longer be ordered.


Product level features

You can override the default settings (described above) for individual products when adding/editing the product.

Scroll to the 'stock & delivery management section' and locate the back order settings (shown in the screenshot below).

The Can the product be purchased when out of stock? has 3 settings, selecting the 'default' setting will mean the product inherits the value set on the account level.

The Out Of Stock Quantity Limit setting works in the same way that the account level setting does. If you do not enter a value here, then the product will inherit the value set on the account level setting.


Please note

Setting a value of 0 in the out of stock limit setting (either at the account level or product level) will mean that an unlimited amount of the product can be purchased.


Product variations

The settings described above are set at the product level and cannot be set for individual variations. If you need this control at the variation level you will need to split up your product variations into separate products. All variations on a product will inherit the settings set for the product they belong to.


Product import system

Once the extension is activated, two additional columns are present on the product import template.

Purchasable When Out Of Stock possible values here are default (to use the global account setting), yes and no.

Out Of Stock Quantity Limit which behaves in the same way as the product level setting described above.


Twig variables

Enabling the extension gives access to some new Twig variables that can be used within the page editor.

product.purchasable_when_out_of_stock

This variable will return true if the product is out of stock and can be purchased when out of stock.

product.out_of_stock_quantity_limit

This variable will return the quantity limit set for the product. When product.purchasable_when_out_of_stock returns false, this variable will return as 0.


Other variables

In addition to using the variables above, it will likely be appropriate for any code you implement to also use other variables from the product object.

For example product.stock will return the amount of the product currently in stock, product.in_stock will return as either true or false.


Installation instructions (version 2 themes or earlier)

Once the extension is activated you'll need to change the relevant code to your website's files (described below). Changing the code will enable out of stock products to be purchased. To change the code you'll need to use the page editor, alternatively you can click the 'request installation' button and we'll change the code for you (a small charge will be made for the installation, which is listed on the extension page).

When a product is out of stock, instead of the normal 'add to basket' button your theme will instead display an 'out of stock' button which cannot be clicked. When you activate this extension, you'll need to change the code on your theme that does this.

If you're not using a version 3 (or later) theme, locate the product.twig file (located in /views/product pages/product.twig).

Find the code that shows the out of stock button. The exact code will depend on your theme, e.g.

<div class="button out-of-stock-button">{{ global.theme.settings.button_out_of_stock }}</div>

or

<button disabled="disabled" class="btn full-md button-out-of-stock disabled out-of-stock-button">{{ global.theme.settings.button_out_of_stock }}</button>

You'll need to change the code so that instead of displaying the DIV (as in the first example) or a disabled button, it instead displays an add to basket button, e.g.

<button class="btn full-md button-out-of-stock out-of-stock-button">add to basket</button>

Please note, the exact classes required will depend on your individual theme, where possible you can copy these classes from the normal add to basket button, but you must include the class out-of-stock-button.


Using the product.purchasable_when_out_of_stock variable

If only some of your items will be purchasable when out of stock you should use this variable to surround the newly modified add to basket/out of stock section.

For example,

{% if product.purchasable_when_out_of_stock %}
	...modified out of stock button code...
{% else %}
	...normal out of stock button code
{% endif %}

Additional messaging

If you'd like to display a message on the product page that gives the customer an expected delivery date or custom lead time you can use the custom fields extension. This process is described below.


Installation instructions (version 3 themes or later)

Once the extension is activated you'll need to change the relevant code to your website's files (described below). Changing the code will enable out of stock products to be purchased. To change the code you'll need to use the page editor, alternatively you can click the 'request installation' button and we'll change the code for you (a small charge will be made for the installation, which is listed on the extension page).

When a product is out of stock, instead of the normal 'add to basket' button your theme will instead display an 'out of stock' button which cannot be clicked. When you activate this extension, you'll need to change the code on your theme that does this.

If you're using a version 3 (or later) theme, locate the product_form.twig file (located in /views/partials/product_form.twig).

Find the code that shows the add to basket and out of stock buttons. The exact code will depend on your theme but will usually be in the format shown below, e.g.

{% if product.in_stock %}
	{{ html.button('cart_button', '', gts.button_add_to_basket, 'button expanded button_add-basket product-add-button ' ~ softClass,'','','','data-nostock="' ~ gts.button_out_of_stock ~ '" data-text="' ~ gts.button_add_to_basket ~ '"') }}
{% else %}
	{{ html.button('cart_button', '', gts.button_out_of_stock, 'button expanded button_add-basket product-add-button disabled ' ~ softClass,'','','','data-nostock="' ~ gts.button_out_of_stock ~ '" data-text="' ~ gts.button_add_to_basket ~ '"') }}
{% endif %}

The simplest change to make is to replace the code in the second part of the IF statement with the same code present in the first part of the IF statement (which renders the add to basket button).

However, you should use the product.purchasable_when_out_of_stock variable when doing so, to retain the normal 'out of stock' functionality to be available when you don't want a product to be purchasable when out of stock, e.g.

{% if product.in_stock %}
	{{ html.button('cart_button', '', gts.button_add_to_basket, 'button expanded button_add-basket product-add-button ' ~ softClass,'','','','data-nostock="' ~ gts.button_out_of_stock ~ '" data-text="' ~ gts.button_add_to_basket ~ '"') }}
{% else %}
	{% if product.purchasable_when_out_of_stock %}
		{{ html.button('cart_button', '', gts.button_add_to_basket, 'button expanded button_add-basket product-add-button ' ~ softClass,'','','','data-nostock="' ~ gts.button_out_of_stock ~ '" data-text="' ~ gts.button_add_to_basket ~ '"') }}
	{% else %}
		{{ html.button('cart_button', '', gts.button_out_of_stock, 'button expanded button_add-basket product-add-button disabled ' ~ softClass,'','','','data-nostock="' ~ gts.button_out_of_stock ~ '" data-text="' ~ gts.button_add_to_basket ~ '"') }}
	{% endif %}
{% endif %}

Please note, the exact code required will depend on your individual theme, the above code example may not work on all themes.


Additional messaging

If you'd like to display a message on the product page that gives the customer an expected delivery date or custom lead time you can use the custom fields extension. This process is described below.


Using custom fields

The custom fields extension can be used in conjunction with the back order extension to allow you to enter text when adding/editing a product that is then displayed on the product page.

For example, you can create a custom field in which you would enter text such as This product is not currently in stock, order now for delivery in 10 days.


Creating and using the custom field

To do so, create a text custom field for a product as described on the help guide. You can give the custom field a name of lead_time.

Going back to the code that you have inserted (as described above) to change the behaviour of the out of stock button, you can output the contents of the custom field that you've added (for which you'll need to add data for, for each product, when adding/editing the product) by using the variable {{ product.custom_fields.lead_time }}.

You'll need to ensure that the code is only shown for products:

- That are out of stock (detected using the product.in_stock variable)
- That can be purchased when out of stock (detected using the product.purchasable_when_out_of_stock variable)

You could also include this code for display on the shopping basket page underneath the item title (by using the variable item.product.custom_fields.lead_time


Other basket page messaging

We'd also recommend placing a text note near to the 'proceed to checkout' button on your shopping basket page, reminding customers that a product in their basket is out of stock.

Within the checkout_basket.twig file, above the block page_content section declare a variable {% set back_order_message = false %}.

Locate the code starting {% for item in basket.items %} and place the code shown below directly below it.

{% set back_order = false %}
	{% set variation_in_stock = false %}
	{% for variation in item.product.variations %}	
		{% if variation.in_stock and variation.id == item.variation_id %}
			{% set variation_in_stock = true %}
		{% endif %}
	{% endfor %}
	{% if (not item.in_stock) and (not variation_in_stock) %}
		{% set back_order = true %}
	{% endif %}

You can then reference this variable and it will only return as true where at least one product in the basket is out of stock, e.g.

{% if back_order_message %}
	At least one item in your basket is currently out of stock. Please check the lead time for these products above.
{% endif %}