Create your own ecommerce website and start selling successfully with ShopWired today

Create your ecommerce website on ShopWired today.
Start today with 14 days free

Create your own ecommerce website and start selling successfully with ShopWired today

Create your ecommerce website on ShopWired today.
Start today with 14 days free

Adding a re-order feature

Theme Customisations - Coding
26th February 2021

Before you proceed:
The following article contains information that requires you to have some prior knowledge about coding in order to correctly implement the proposed change to your theme. If done incorrectly alterations made to your theme’s code can negatively impact your website causing visual and performance issues. Therefore, we strongly recommend that you only undertake this effort if you are completely confident that you know what you’re doing. If you have no coding experience at all, aren’t entirely comfortable following the instructions in this article or if you simply don’t understand the instructions then we recommend you instead contact our partners, Coding Masters, who will complete the work for you for a set fee.


Pro tip!

If you are using a version 3 or version 4 theme you won't need to add this code to your theme's files as this feature is automatically included.


Adding a re-order feature to your ShopWired website would allow your customers to click a button on a previous order they've placed to automatically add all of the products in that order to the basket.

Please note that a product in an order might not be added to the basket if:

• The product is out of stock
• The selected variation no longer exists
• The product choice or extras no longer exist or have been renamed

This feature does not work for products with variations where the variations use the 'all variants' feature (i.e. where variations are not configured individually).

The re-order function is as simple as the user clicking a button, similar to the example shown above.


Adding the code

The button is a simple button contained in a form.
You have to send a POST request to the order URL with a value of add_to_basket set to true/1.

<form action="{{ order.url }}" method="post">
         <input type="hidden" name="add_to_basket" value="1">
         <button type="submit">
                Re-Order
         </button>
</form>

If you're adding the button to the account home page (which displays all of the orders the customer has placed) then each order will need its own button, so this will need to be included within {% for order in orders %}.

If you're adding the button to the account order page (which displays information about an individual order) then the button will only be displayed once.