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


Using basket rules

The basket rules app allows you to enforce the purchase of a particular product, that you set, when a customer's basket first a particular scenario.

For example, you may want to charge users a £5 fee if they order under £100 worth of goods.

Alternatively you may want to charge a 'setup fee' on orders, for example if you are a printing company.

Free gifts

Because the basket rules app allows you to modify the price of (what is called) a 'default' basket product (i.e. one who's purchase is enforced), you are able to use the basket rules app to give away a free gift with an order under a particular circumstance.

The basket rules app isn't the 'perfect fit' to be used for this purpose and you may find it more appropriate to use a voucher code instead, but if you prefer to use the basket rules app you'll need to make an amendment to your checkout/basket page file on your theme - this is to ensure that customer's don't qualify for the free gift and then remove the products they were ordering (i.e. to get the free gift without spending any money).

Further instructions on how to do this are shown at the bottom of this help guide article.

Setting up default basket products

When an item is added to the basket as a result of a basket rule, we call this a 'default' product.

To setup basket rules select 'settings' from the left menu and then 'basket/checkout'.

1. Select the default product from the drop down (as shown in the example below).

Multiple default products can be added to the rule by clicking the '+add another product' link.

2. If the product is usually for sale on your store at a different price, you can enter the custom price for the product (only applicable when added as a default product) in the 'custom price' field.

3. Next, you'll need to select the scenario under which the default product should be added.

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

4. If you've selected Baskets Over A Fixed Amount or Under A Fixed Amount - then you can enter the amount in the box on the right hand side.

You'll also need to select which order amount we should used from the 'based on' drop down.

5. You'll also need to enter a Valid From and Valid To date.

When setting the valid from date for a basket rule be aware that the time the rule will be valid from is 00:00:00 which is the first time of the new day. So setting a valid from date of 17/12/2016 will mean the rule can be used throughout the day of 17/12/2016.

When setting the expires on date the rule will stop working at 23:59:59 on the expiry date (the last time of the current day). So setting a expires on date of 18/12/2016 will mean the rule can be used throughout the day of 18/12/2016.

In the above example therefore a rule with a valid from date of 17/12/2016 and expires on date of 18/12/2016 will be able to be used throughout the 17th and 18th of December.

Basket rules as free gifts

The way the basket rules app works is that when the shopping basket page is loaded, if the order qualifies for the default product, it will be added to the basket automatically. It is possible for the customer to then delete the paid products from their basket and leave the free gift remaining and checkout with it, essentially getting a free gift product without having to pay any money for their order.

This can be prevented by adding some code to your theme's shopping basket page file. The code will hide the shopping basket's 'proceed to checkout' button if the default product is in the customer's basket and the order amount no longer qualifies.

To add the code you'll need to use the page editor.

1. In the 'views' folder open the 'checkout pages' folder and then open the checkout_basket.twig file.

2. At the top of the file, on the line after the {% block page_content %} code add the code shown below.

{% 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 with the unique ID of your default product. You can get the ID of the product either through the export system or by clicking to edit the product through the management system and then getting the long number from the URL in your browser's address bar. You should now have something that looks like the below:

3. Scroll down to the bottom of the file.

You need to locate the 'proceed to checkout' button and (if you have activated PayPal Express), the PayPal Express button.

You'll need to replace the code the proceed to checkout and PayPal Express buttons with the code shown below. However please be aware that you will need to replace the XXX 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,


Save your changes when you're done.

You should test the basket under a number of different scenarios to ensure that it is working correctly.

If you have multiple free gifts available under different scenarios, you will need to modify the above code accordingly (you may need 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). Whether VAT is included in this variable is dependent on your website's B2B settings. Other variables are available for you to use, see the basket object help guide for more variables.