<p>You're right, this does not seem to clear automatically when you remove all line items, but you could <em>I think</em> just set an extra post value in your form that calls <code>removeAllLineItems</code> to clear the shipping handle at the same time...because in this controller there is a call to <code>$cart-&gt;setContentFromPost('fields');</code> I presume if you set the shipping handle to <code>""</code>, that set content will cause the shipping method to be dropped from the cart.</p>

<p>So basically add <code>&lt;input type="hidden" name="shippingMethod" value=""&gt;</code> to your form &amp; it <em>should</em> work.</p>

CC BY-SA 3.0
2016-12-29T11:50:38.177Z
Hey! Thanks for the answer. Unfortunately it did not work. I tried on the default template code that comes with Commerce as well. Do you have other suggestions? Cheers!
Stian Karlsen
CC BY-SA 3.0
2017-01-05T01:25:10.813Z
Yeah I realised my answer above is not right - it might be setting custom `fields` at that point, but not the `shippingMethod`.

I think your best bet here is to ajax two requests off - one to `updateCart` to clear the shipping method/id, and then a second call to `removeAllLineItems` once that returns.  Hacky, but it will work.
Jeremy Daalder
CC BY-SA 3.0
2017-01-05T12:03:09.123Z
Could you expand on the updateCart form. I don't understand how I can use that to clear the shipping method. I tried simply creating a form and submitting it, but nothing happens. Apologies in advance for being a bother here. Thank you! (The ajax part won't be a problem, no need to expand on that)
Stian Karlsen
CC BY-SA 3.0
2016-12-21T04:04:30.213Z
2016-12-21T04:19:06.757Z
2016-12-21T04:19:06.757Z
Jeremy Daalder
<p>Is it possible without a plugin?</p>

<p>Our client desperately wants the shipping method to be reset (not selected) after an order has been placed or the empty cart button is clicked.</p>

<p>Edit: The shipping method does indeed reset after a completed purchase. Apologies. Regardless, reset on empty cart is still an issue.</p>

<p>Thanks</p>

<plugin-craftcommerce>
Reset shipping method on cart empty and order complete
# Reset shipping method on cart empty and order complete

(Asked by: username_0 on 2016-12-19)

Is it possible without a plugin?

Our client desperately wants the shipping method to be reset (not selected) after an order has been placed or the empty cart button is clicked.

Edit: The shipping method does indeed reset after a completed purchase. Apologies. Regardless, reset on empty cart is still an issue.

Thanks

**Tags:** plugin-craftcommerce


---

## 1 answers

### Answer by username_1 on 2016-12-21. Score: 1

You're right, this does not seem to clear automatically when you remove all line items, but you could *I think* just set an extra post value in your form that calls `removeAllLineItems` to clear the shipping handle at the same time...because in this controller there is a call to `$cart->setContentFromPost('fields');` I presume if you set the shipping handle to `""`, that set content will cause the shipping method to be dropped from the cart.

So basically add  to your form & it *should* work.

> **Comments:**
> **username_0**: Hey! Thanks for the answer. Unfortunately it did not work. I tried on the default template code that comes with Commerce as well. Do you have other suggestions? Cheers!  
> **username_1**: Yeah I realised my answer above is not right - it might be setting custom `fields` at that point, but not the `shippingMethod`.  I think your best bet here is to ajax two requests off - one to `updateCart` to clear the shipping method/id, and then a second call to `removeAllLineItems` once that returns.  Hacky, but it will work.  
> **username_0**: Could you expand on the updateCart form. I don't understand how I can use that to clear the shipping method. I tried simply creating a form and submitting it, but nothing happens. Apologies in advance for being a bother here. Thank you! (The ajax part won't be a problem, no need to expand on that)  

---

