1

I want to have a button on order information page when clicked the same order should be repeated. How can I put the same products again in the cart or simply re-order again?

1

This would probably require a plugin with a controller which you could post the order id to when clicking the button. Within the controller you could then query the database to get each line item and add it to the cart within a service if it is in stock and still enabled. The final step would then be to redirect to the basket or posted url.

The docs here should help you get started: https://craftcms.com/docs/plugins/controllers

| improve this answer | |
  • Well i know that, even i tried had created a plugin for the same, but i wasn't able to create a controller where i could put the same items of the order back into cart, maybe because i'm not so expert developer. If you could help in creating one, then i would be thankful to you. – hashtagerrors Apr 14 '17 at 8:07
  • Apologies for the very late response on this but I've made a plugin to do this now as part of one of our own projects needs. I completely forgot about this stack exchange post if I'm honest but I'll post a link to the plugin as a separate answer in case you are still needing this. – Matt Shearing Nov 17 '17 at 13:48
1

I've made a plugin to do this now and it has stock checks to display messages if the quantity has been adjusted due to availability of a variant.

https://github.com/a-digital/repeatorder

| improve this answer | |
1

Another approach here is to use MultiAdd (https://github.com/verbb/multi-add) to build a repeat order form rather than just a button to repeat the whole order.

Depends entirely on what you want, but this can be a bit more flexible as it allows them to repeat the same items but potentially change quantities or notes etc., and means you can display stock issue messages and so on before they get to the cart screen, which is perhaps handier for the customer.

It's easy to do - just loop through the old order as your're building your MultiAdd form and give each item a unique index, check for stock and display appropriate warnings at that point, etc.

(You can also use MultiAdd to create the one button approach of course, just using hidden fields instead of inputs, and that might be handy if you happen to be using MultiAdd anyway and want to keep your plugin numbers down, and/or want those stock messages on show before they go through the add to cart process).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.