If there is many repeated order of same product by the customer than you should add an app that enable customer to reorder their past order or there is an alternate way to enable customers to reorder the past purchase or product
Required things for customer and store owners
1 . Code must put carefully(Store owner)
2. Customer must have store account
Now we are ready to put the code
1. Login into your store
2. Go to Online Store and select theme
3. There is 3 dots ( . . . ) Click on the button and click on Edit HTML/CSS
4. Click on snippets folder and Add a new snippets
Name of snippets :repeat-order.liquid
5. Paste this Gist hosted on github
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if order.line_items.size > 0 %} | |
<p> | |
<button class="btn place-same-order">Add order to cart</button> | |
<script> | |
(function(){ | |
/* Check for the button */ | |
var buttonOrder = document.getElementsByClassName('place-same-order') || false; | |
if(!buttonOrder){ return } | |
/* Setup the order object. Extend this as needed. */ | |
var order = { | |
items:[ | |
{% for line_item in order.line_items %} | |
{ | |
variant_id: {{ line_item.variant.id | json }}, | |
product_id: {{ line_item.product.id | json }}, | |
properties: {{ line_item.properties | json }}, | |
available: {{ line_item.variant.available | json }} | |
}{% unless forloop.last %},{% endunless %} | |
{% endfor %} | |
] | |
}; | |
/* Simple function to check the queue */ | |
var checkQueue = function(){ | |
order.items.shift(); | |
if(order.items.length){ | |
orderItems() | |
}else{ | |
window.location.href = '/cart'; | |
} | |
}; | |
/* Simple function add to cart */ | |
var orderItems = function(){ | |
if(!order.items.length){ return } | |
if(!order.items[0].available){ | |
checkQueue(); | |
} | |
var request = new XMLHttpRequest(); | |
request.open('post', '/cart/add.js', true); | |
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); | |
request.onload = function() { | |
var resp = request.responseText; | |
if (request.status >= 200 && request.status < 400) { | |
checkQueue(); | |
} else { /* add your error handling in here */ } | |
}; | |
request.onerror = function() { | |
/* add your error handling in here */ | |
}; | |
request.send(JSON.stringify({ | |
'quantity':order.items[0].quantity, | |
'id':order.items[0].variant_id | |
})); | |
}; | |
buttonOrder[0].addEventListener("click", function (event) { | |
event.preventDefault(); | |
/* Get the button we just clicked */ | |
var t = event.target || event.srcElement; | |
/* Very simple method to stop a double click. You should make something fancier. */ | |
t.setAttribute('disabled','disabled'); | |
t.innerHTML = 'Adding to cart...'; | |
/* Fire the function that adds to cart */ | |
orderItems(); | |
}); | |
})(); | |
</script> | |
</p> | |
{% endif %} |
6 . And include {% include 'repeat-order' %} where you want
Recomended : include this in : Templates/custmers/account.liquid
Note : Don't expect it to work in your own theme without some minor changes.
Try Shopify for free, and explore all the tools and services you need to start, run, and grow your business.
How to add Reorder Code for Repeated order
Reviewed by Navjeet Singh
on
September 06, 2016
Rating:

No comments: