Create your own ecommerce website and start selling successfully with ShopWired today
Adding a re-order feature
Before you proceed: |
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.