In light of the recent UI improvement to replace the "remove" checkboxes with remove buttons, I would like to add a "Clear Cart" button to make it easier to get rid of product kits that are set "As individual products". The problem we have is our product kits might have 20+ products in them, and it only takes 1 click to add the whole thing to the cart. If the customer changes their mind, it now takes them 20 click-waits to get the one kit out of their cart. That seems a bit ridiculous, even for the most sales-conversion oriented website. Furthermore, it might be nice to have it show up optionally for those sites that would rather make it difficult to remove a lot of products from a cart in an effort to increase sales conversion rate / ticket size.

A confirmation for the "Clear Cart" button ("Are you sure?") should also be implemented, to prevent accidental clearing of the cart.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SeanA’s picture

It's possible to empty the cart (with confirmation) using Cart Links... for all the gory details on that, see the discussion at #881752: Cart Links - Missing code for "Empty cart" function. Or I suppose you could do a form_alter on the cart form and use uc_cart_empty().

bancarddata’s picture

Status: Active » Closed (duplicate)

Thanks for the input, SeanA. I am just going to close this as a duplicate based on the thread you linked to, and perhaps take your 2nd approach. I don't need all the links (and security debate) that Cart Links provides. When/if I come up with my solution, I will post it back here for any who are requiring just a simple empty cart link on the cart page and none of the rest.

bancarddata’s picture

FileSize
836 bytes

Attached is a basic module to add an Empty cart link to the cart page in UC 7.x-3.x.

longwave’s picture

Status: Closed (duplicate) » Active

No problem with leaving this open; an "empty cart" button on the cart page is a different feature to cart links and would not present a security risk.

bancarddata’s picture

FileSize
807 bytes

Here is a cleaned up version of the module that better conforms to recommended conventions.

drupalycious’s picture

hello,

does your module work with the latest dev version?
I am asking because your latest message is more than one year old.

Thank you

longwave’s picture

Status: Active » Needs review
FileSize
4.33 KB

This patch adds an optional empty cart button, with confirmation page and test cases. Enable it at /admin/store/settings/cart.

Status: Needs review » Needs work

The last submitted patch, 1258982-empty-cart-button.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review

Strange testbot failure; failed in catalog module testing, with message: exception 'DatabaseSchemaObjectExistsException' with message 'Table variable already exists.' in /var/lib/drupaltestbot/sites/default/files/checkout/includes/database/schema.inc:657

#7: 1258982-empty-cart-button.patch queued for re-testing.

drupalycious’s picture

thanks !!!

so far I didn't noticed any bug.

longwave’s picture

Status: Needs review » Fixed

Committed #7

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.