Answers.Body: <p>Using the <a href="https://github.com/engram-design/MultiAdd" rel="nofollow noreferrer">MultiAdd</a> plugin, you can do the following on the order page:</p>
  
  <pre><code>&lt;form method="POST"&gt;
      &lt;input type="hidden" name="action" value="multiAdd/multiAdd"&gt;
      &lt;input type="hidden" name="redirect" value="commerce/cart"&gt;
      {{ getCsrfInput() }}
      {% for item in order.lineItems %}
          {% set itemNumber = loop.index %}
          &lt;input type="hidden" name="items[{{ itemNumber }}][qty]" value="{{ item.qty }}"&gt;
          &lt;input type="hidden" name="items[{{ itemNumber }}][note]" value="{{ item.note }}"&gt;
          &lt;input type="hidden" name="items[{{ itemNumber }}][purchasableId]" value="{{ item.purchasableId }}"&gt;
          {% for key, option in item.options %}
              &lt;input type="hidden" name="items[{{ itemNumber }}][options][{{ key }}]" value="{{ option }}"&gt;
          {% endfor %}
      {% endfor %}
      &lt;input type="submit" value="Order Again" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This adds a "Order Again" button with the same products and quantities, but options may be bit more difficult to sort out.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T11:04:41.737Z
Answers.Text: Getting the options duplicated are essential for this, unfortunately. I'll go from this and see where I get. Thanks! Update to follow...
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T11:32:18.107Z
Answers.Text: @MattWilcox I've updated my answer to include options and notes from the original order, that should now do what you need.
Answers.UserDisplayName: Stephen Hamilton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T12:14:02.020Z
Answers.Text: Thanks! There was a slight bug in your code because you were nesting loops. I've corrected the code above.
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T12:26:49.897Z
Answers.Text: @MattWilcox Ah, thanks, only tested with 1 option per lineItem so didn't catch that!
Answers.UserDisplayName: Stephen Hamilton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T10:41:36.827Z
Answers.LastActivityDate: 2016-11-02T12:13:58.227Z
Answers.LastEditDate: 2016-11-02T12:13:58.227Z
Answers.UserDisplayName: Stephen Hamilton
Answers.Body: <p>Re-ordering could be possible by building a cart update form on the front-end that is populated by a previous order.</p>
  
  <p>You would need to use the <a href="https://github.com/engram-design/MultiAdd" rel="nofollow noreferrer">Multi-Add plugin</a> to submit more than one purchasableId at once, but everything else should work as expected.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T11:03:57.940Z
Answers.Text: Oh. To be clear, what you're saying it essentially - use the existing cart template as the basis, but populate it from the Order. It's a Twig thing, not a plugin thing?
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-02T10:45:47.157Z
Answers.LastActivityDate: 2016-11-02T10:45:47.157Z
Answers.UserDisplayName: Luke Holder
Answers.Body: <p>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 the current availability of a variant. All previous options will be carried forward into the new cart also.</p>
  
  <p>The benefit of using this plugin is that you don't need to loop through each line item of the order in the template to populate a form. This should speed things up on large orders for you as all you have to do now is submit the order id to the plugin controller and it will handle the rest.</p>
  
  <p>I've used this on production sites with large numbers of variants and up to 12 custom options in a nested array where it's run without any issue for about 7 months. I thought I'd drop the link on here for anyone still attempting to create this functionality. I hope it helps.</p>
  
  <p><a href="https://github.com/a-digital/repeatorder" rel="nofollow noreferrer">https://github.com/a-digital/repeatorder</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-20T13:32:17.153Z
Answers.LastActivityDate: 2017-11-20T13:32:17.153Z
Answers.UserDisplayName: Matt Shearing
Body: <p>Orders can not be edited in Commerce. Makes sense. </p>
  
  <p>What we want to do however is make it very easy for someone to re-order a previous order. So for example they've had an order that contains "two pairs of socks, two pairs of pants, toothpaste, and soap" but they need all of that again as a new order.</p>
  
  <p>Rather than manually having to do so, we want to offer a "re-order" button.</p>
  
  <p>Given that an order is just a cart that's been marked complete, we're thinking it should just clone the order into a new cart, so they can review it and make any amends they need to, then just continue as normal with the checkout process.</p>
  
  <p>I can not figure out how to do this though. Getting the Order is simple enough, and there's an existing cart set up too. But how would I punt that old Order into the new cart?</p>
  
Tags: <plugin-development><plugin-craftcommerce>
Title: Duplicate an existing Order as a new Cart in Commerce
ThreadText: # Duplicate an existing Order as a new Cart in Commerce
  
  (Asked by: username_0 on 2016-11-02)
  
  Orders can not be edited in Commerce. Makes sense.
  
  What we want to do however is make it very easy for someone to re-order a previous order. So for example they've had an order that contains "two pairs of socks, two pairs of pants, toothpaste, and soap" but they need all of that again as a new order.
  
  Rather than manually having to do so, we want to offer a "re-order" button.
  
  Given that an order is just a cart that's been marked complete, we're thinking it should just clone the order into a new cart, so they can review it and make any amends they need to, then just continue as normal with the checkout process.
  
  I can not figure out how to do this though. Getting the Order is simple enough, and there's an existing cart set up too. But how would I punt that old Order into the new cart?
  
  **Tags:** plugin-development, plugin-craftcommerce
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2016-11-02. Score: 3 | Accepted answer
  
  Using the [MultiAdd](https://github.com/engram-design/MultiAdd) plugin, you can do the following on the order page:
  
  ```
  <form method="POST">
      <input type="hidden" name="action" value="multiAdd/multiAdd">
      <input type="hidden" name="redirect" value="commerce/cart">
      {{ getCsrfInput() }}
      {% for item in order.lineItems %}
          {% set itemNumber = loop.index %}
          <input type="hidden" name="items[{{ itemNumber }}][qty]" value="{{ item.qty }}">
          <input type="hidden" name="items[{{ itemNumber }}][note]" value="{{ item.note }}">
          <input type="hidden" name="items[{{ itemNumber }}][purchasableId]" value="{{ item.purchasableId }}">
          {% for key, option in item.options %}
              <input type="hidden" name="items[{{ itemNumber }}][options][{{ key }}]" value="{{ option }}">
          {% endfor %}
      {% endfor %}
      <input type="submit" value="Order Again" />
  </form>
  
  ```
  
  This adds a "Order Again" button with the same products and quantities, but options may be bit more difficult to sort out.
  
  > **Comments:**
  > **username_0**: Getting the options duplicated are essential for this, unfortunately. I'll go from this and see where I get. Thanks! Update to follow...  
  > **username_1**: @username_0 I've updated my answer to include options and notes from the original order, that should now do what you need.  
  > **username_0**: Thanks! There was a slight bug in your code because you were nesting loops. I've corrected the code above.  
  > **username_1**: @username_0 Ah, thanks, only tested with 1 option per lineItem so didn't catch that!  
  
  ---
  
  ### Answer by username_2 on 2016-11-02. Score: 2
  
  Re-ordering could be possible by building a cart update form on the front-end that is populated by a previous order.
  
  You would need to use the [Multi-Add plugin](https://github.com/engram-design/MultiAdd) to submit more than one purchasableId at once, but everything else should work as expected.
  
  > **Comments:**
  > **username_0**: Oh. To be clear, what you're saying it essentially - use the existing cart template as the basis, but populate it from the Order. It's a Twig thing, not a plugin thing?  
  
  ---
  
  ### Answer by username_3 on 2017-11-20. Score: 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 the current availability of a variant. All previous options will be carried forward into the new cart also.
  
  The benefit of using this plugin is that you don't need to loop through each line item of the order in the template to populate a form. This should speed things up on large orders for you as all you have to do now is submit the order id to the plugin controller and it will handle the rest.
  
  I've used this on production sites with large numbers of variants and up to 12 custom options in a nested array where it's run without any issue for about 7 months. I thought I'd drop the link on here for anyone still attempting to create this functionality. I hope it helps.
  
  <https://github.com/a-digital/repeatorder>
  
  
  ---
  
  