Is there a way to programmatically empty the cart? I know you can by submitting a form with name="empty_cart", but I'd like to do it programmatically between page loads, not requiring a user input.

If it's not possible with native tags, is this something we could build an extension for?

1 Answer 1


It depends what you're trying to achieve. If you want to programmatically empty the cart using PHP, this will do the trick (Store v2):

// load the Store module if you haven't already


In Store v1:


If you want to do it using template tags, I would suggest just making a basic template with the checkout form on it, and using javascript to submit the form as soon as the page loads.

By the time you're doing that though, you may as well just use a small checkout form with an empty_cart button instead of linking to the page in question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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