Menu Close

Get Support From ShopWired Close

All systems fully operational

Subscribe To Updates
Prefer To Live Chat? Chat directly with ShopWired support Available from 9.00am to 10.00pm Monday to Friday Quickest response time
Send A Message
Response within 24 hours

Menu Close


Basket Rules

The basket rules app allows you to create rules that force products to be placed in a customer’s basket under particular circumstances.

There are multiple ways you can utilise this app, such as to charge a fee if a customer spends under a certain amount, to charge a setup fee on orders or to give a free gift if a customer spends over a certain amount.

To install this app select APPs > Available APPs from the menu. Find and select the ‘Basket Rules’ app and select INSTALL THIS APP.

• Creating a new rule
• Managing existing rules
• Basket rules as free gifts

Creating a new rule

Once you have installed the app you can begin creating basket rules by selecting Settings > Basket/Checkout from the menu. Use the ‘Create A New Default Basket Product(s) Rule’ section to add a new rule:

The product that is added to a customer’s basket as a result of a basket rule is called the ‘default’ product. Select the default product from the selection box under Basket Product(s):

Please note!

Products which have variations cannot be the 'default' product in a basket rule and will therefore not appear in the selection box.

Use the Custom Price field to add a price for the default product if the price is different from how much you usually sell the product for. If the price is the same you can leave this field blank. Select the tick box by ‘free’ if the product should be free.

Add multiple default products to the rule by selecting + add another and configuring the details in the same way as the first product.

Next, use the drop-down menu under Scenario to select the scenario under which the default product should be added to a customer’s basket:

You have three choices:

  • All Baskets - the default product should always be added, regardless of the products in the order
  • Baskets Over A Fixed Amount - the default product should only be added if the order is over a set value
  • Baskets Under A Fixed Amount - the default product should only be added if the order is below a set value

If you select baskets over or under a fixed amount enter the Amount in the box that appears, and also select what the order amount should be Based On by using the drop-down menu that appears:

Finally, enter a Valid From and Expires On date.

The Valid From date will begin at 00:00:00 on the date set. The Expires On date will stop the rule working at 23:59:59 on the date set.

Therefore, creating a rule with the dates 17/12 - 18/12 would mean the rule would be active on the entirety of December 17th and 18th.

If you want the rule to become active as soon as it is created select the tick box beside ‘now’. If you never want the rule to expire select the tick box beside ‘never’.

Managing existing rules

Once you have created a rule it will appear in the ‘Existing Default Basket Product(s) Rules’ section:

You can use this section to manage your rules.

Basket Product tells you the default product that is added to a basket when the specified scenario occurs.

Scenario tells you the scenario where the product would be added to a basket.

Start/End tells you what dates the rule is active on.

Use the tick box under Active to deactivate/reactivate a rule. You should use this feature if you want to keep the details of a rule, but you don’t want it to be able to be used.

Select the Edit button to edit the details of the rule.

Use the bin icon under Delete to delete the rule. When you delete a rule you will lose all data associated with that rule.

Basket rules as free gifts

Because this app allows you to modify the price of a ‘default’ basket product (i.e. a product with an enforced purchase aspect), you can use the app to give a free gift with an order under circumstances which you create. This app is not the perfect solution for this purpose, so it might be more applicable for you to use a voucher code instead.

If you want to use the basket rules app to give free gifts you must make an amendment to your theme’s checkout/basket page file on your live theme to ensure that customers who qualify for the free gift don’t then remove the products they were ordering to get the free gift without spending any money. The code works by hiding the shopping basket’s ‘proceed to checkout’ button if the default product is in the customer’s basket but the order amount no longer qualifies. To add the code select Themes > Installed Themes from the menu. Then select Page Editor on your live theme:

In the left menu that then appears select views > checkout pages and open the checkout_basket.twig file.

Towards the top of the file, you will see a line with the {% block page_content %} code. On a new line, directly after that line, add the following code:

{% set basket_gift = false %}
{% for item in basket.items %}
    {% if == xxx %}
        {% set basket_gift = true %} 
    {% endif %}
{% endfor %}

You'll need to replace the xxx text in the code with the unique ID of your default product. The ID of the product can be obtained either by taking an export of your products or in the URL in your browser's address bar when editing the product through the management system. In the address bar the ID is the long number at the end of the URL:

You should now have something that looks like this:

Next, scroll down to the bottom of the file and locate the 'proceed to checkout' button and (if you have activated PayPal Express) the PayPal Express button.

Replace the code for the proceed to checkout and PayPal Express buttons with the code shown below. However, please note that you must replace the XXX instances within this code with the code already on your theme for these 2 buttons.

{% if basket_gift == true %} <!-- is the free gift in the basket -->
    {% if basket.sub_total > X %} <!-- has the customer spent enough to qualify for the gift -->
    {% else %} <!-- tell the customer they've not spent enough -->
    <p>You need to spend a minimum of &pound;X to qualify for the free gift. 
		Please add more items or remove the free gift.</p>
    {% endif %}
{% else %} <!-- the free gift is not in the basket -->
{% endif %}

You'll also need to replace the value of X with the amount required to qualify for the free gift. (The first occurrence of X should be replaced with a value 1 penny less than the amount required to be spent to qualify for the gift).

For example, this:

would become this:

Save your changes when you're done.

You should then test the basket on your website under a number of different scenarios to ensure that it is working correctly. If you find that something has gone wrong with your basket you should revert to a previous version of the file and try again.

If you have multiple free gifts available under different scenarios you will need to modify the above code accordingly (you may want to contact us for assistance).


The code above uses the variable basket.sub_total which is the order amount excluding delivery charges (but including discounts). Other variables are available for you to use; see the basket object help guide for more variables.