Anyone know what to put to empty in the cart before adding the product in the additional processing section?

Comments

WebNewCastle’s picture

Hi,

Sorry for the delay. This question sounds familiar - maybe I encountered something similar on Ubercart.org. Anyway, if you are still looking - or someone else is - I believe you just need the following to first empty the cart:

uc_cart_empty(uc_cart_get_id());

- Matt

brightbold’s picture

A great use case for this (in case other people are looking for such a solution) is to prevent duplicate items getting added to the cart if people use the back button from the cart or checkout to edit the webform. This code will empty the previously added items from the cart before adding them again when the form is submitted. The one caveat is that it won't work with a multi-page form where items are being added on pages other than the last one — items added on earlier pages will get emptied from the cart when the later pages are submitted. But it works beautifully with a single page form!