Stock on back order
Visitors to your website cannot add products to their basket that are out of stock. This restriction is enforced by both your website's theme and the ShopWired platform.
You can use the stock on back order app to allow products to be added to the basket that are out of stock. Installing this app 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)
To install the app:
- Navigate to Apps
- Locate the Stock on back order app
- Select
install this app
ShopWired account functionality
ShopWired account functionality
Once you've installed the app, you'll be able to control the products that can be purchased when out of stock, and the quantity that can be purchased (i.e. how negative the stock count for a product can go).
Global back order settings
Global back order settings
You can set global back order settings within your ShopWired account that are inherited by all products unless back order settings are specified for them individually.
- Navigate to Products > Settings
- Navigate to the Back order settings section
- Use the Configure out of stock products to be setting to determine the default status of out of stock products:
Assumed to be purchasable
means that all products, unless specified otherwise, are assumed to be purchasable when out of stockAssumed not to be purchasable
means that all products, unless specified otherwise, are assumed not to be purchasable when out of stock
- Use the Global quantity limit for out of stock products setting to determine the quantity of a product that can be sold when out of stock:
- Enter only a number in this field
- For example, configuring a value of
10
means a product's stock can go to-10
before it can no longer be added to the basket - The global quantity limit setting applies to all products, unless specified for a product individually
Product back order settings
Product back order settings
You can override the global back order settings described above for each individual product, either when creating or editing the product or using the product import system.
When creating or editing the product:
- Navigate to the product in your ShopWired account
- Navigate to the Stock & delivery section
- Select the Stock on back order options tab
- Use the The product can be purchased when out of stock setting to determine whether the product can be purchased when out of stock:
Default
means the product inherits the global settingYes
means the product is purchasable when out of stockNo
means the product is not purchasable when out of stock
- Use the Out of stock quantity limit setting to determine the quantity of the product that can be sold when out of stock:
- Enter only a number in this field
- For example, configuring a value of
10
means the product's stock can go to-10
before it can no longer be added to the basket
Product import/export system
On the product import/export system:
- Use the column
Purchasable When Out Of Stock
to set the back order status with values of eitherdefault
,Yes
orNo
- Use the column
Out Of Stock Quantity Limit
to set the quantity limit
Item ID | ... | Purchasable When Out Of Stock | Out Of Stock Quantity Limit |
---|---|---|---|
123456 | ... | default | 10 |
123457 | ... | Yes | 0 |
123458 | ... | No |
Theme installation
Theme installation
Code for this app needs to be added to your ShopWired theme:
- To change your theme's default behaviour which prevents out of stock products from being added to the basket
- To modify a visitor's quantity selection to ensure they do not attempt to add more to the basket than the quantity limit allows
- To modify the display of the back in stock notification request form
- To display additional messaging on product pages and your shopping basket page
- To inform visitors the product is out of stock and on back order
- To inform visitors of a lead time (when they can expect to receive the product)
- To add this information to both product pages and your shopping basket page
Twig variables
product.purchasable_when_out_of_stock
Returns true
if the product can be purchased when out of stock.
product.out_of_stock_quantity_limit
Returns the stock quantity limit. When product.purchasable_when_out_of_stock
is false
, product.out_of_stock_quantity_limit
returns 0
.
product.raw_stock
Will return the current stock of the product, including a negative value.
variation.raw_quantity
Will return the current stock of the product variation, including a negative value.
The AJAX endpoint
The AJAX endpoint now includes a rawQuantity
property for the product / selected variation.
Other variables from the product object can also be used.
Example code
Example code
- Locate the
product_form.twig
template - Find the code that generates the display of the "add to basket" and "out of stock" buttons. The code will usually be in the following format:
{% 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 %}
- Surround this code with an
if
statement so that it only renders if the product is not purchasable when out of stock.{% if product.purchasable_when_out_of_stock %}
{% else %}
{% 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 %}
{% endif %}
- Next, add code that runs if the product is purchasable when out of stock. Copy the code that renders the "add to basket" button, and place it within the first
if
statement. Within this code, locate theproduct-add-button
class and remove it.{% if product.purchasable_when_out_of_stock %}
{{ html.button('cart_button', '', gts.button_add_to_basket, 'button expanded button_add-basket ' ~ softClass,'','','','data-nostock="' ~ gts.button_out_of_stock ~ '" data-text="' ~ gts.button_add_to_basket ~ '"') }}
{% else %}
{% 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 %}
{% endif %}
- By default, when a product (or variation) is out of stock, the quantity selection is hidden. The code that renders the quantity selection will be nearby to the "add to basket" button. Locate this code and find a class of
product-quantity
. Change this code so that theproduct-quantity
class only renders if the product is not purchasable when out of stock. - Replace
product-quantity
with{{ product.purchasable_when_out_of_stock ? '' : 'product-quantity' }}
. - If you have the "Back in Stock Notifications" app installed, it will render a form on the product page if the product or its variations are out of stock. Locate this code and surround it with an
if
statement so that it only renders if the product is not purchasable when out of stock.- For themes that render a button to click:
{% if not product.purchasable_when_out_of_stock %}
{% if global.features.extensions.back_in_stock and not modal %}
{{ html.button('', '', gts.button_out_of_stock, 'button large advance expanded stock-requests-container' , '', 'button', '', 'data-open="stockRequestsModal"','button_out_of_stock') }}
{% endif %}
{% endif %}
- For themes that render a form:
{% if not product.purchasable_when_out_of_stock %}
{% if global.features.extensions.back_in_stock %}
<div class="stock-requests-container">
<label class="field-label">Your Name</label>
<input type="text" name="stock_request_name" class="required">
<label class="field-label">Your Email Address</label>
<input name="stock_request_email" type="email" class="required jsv_email">
<button class="button" name="stock_request" value="1" type="submit">Send Your Request</button>
</div>
{% endif %}
{% endif %}
- For themes that render a button to click:
Custom fields and onsite messaging
Custom fields and onsite messaging
You can use the custom fields app to display messaging on your website about products on back order, for example to display a lead time for each product.
When adding custom field variables to the product page, ensure that the lead time only displays when a product is out of stock by using the product.in_stock
variable (which returns true
if the product is in stock).
It is also helpful to include messaging on the shopping basket page. The example code below (when placed just beneath {% for item in basket.items %}
) sets a back_order
variable to true
if at least one product in the order is out of stock and therefore on 'back order'.
{% set back_order_message = 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_message = 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 %}