Empty Cart Button

(BU)Empty cart Button lets a shopper clear their entire WooCommerce cart in one action. Use it as a secondary action on a Bricks Cart page or in a custom mini-cart. You can style it as a button or plain link, ask for confirmation, and choose where the shopper lands afterward.

Before you start: Activate WooCommerce and BricksUltimate, then enable Empty Cart Button under Bricks → BricksUltimate → Woo Elements. Save and reopen the Bricks editor.

Add the Element


  1. Edit your Cart template or mini-cart layout in Bricks. Search for (BU)Empty cart Button.
  2. Place it once, outside the repeated cart-item rows. A good spot is below the product list, separate from Proceed to checkout. Keep it outside other links or buttons.
  3. Set Button Text to a clear label such as Empty cart or Remove all items. Select Button or Plain Link under Button type. Both perform the same action.
  4. Under Link, set a same-site Redirect to URL if needed. For a mini-cart in a header or shared template, set this explicitly to your Cart or Shop page so the destination is predictable.
  5. Save and test on the storefront with at least two line items in the cart. Add the optional confirmation popup before publishing if shoppers should confirm the action.

What Happens When the Cart Is Cleared


The action clears the current shopper's WooCommerce cart, including all quantities and applied cart coupons. It does not delete products, previous orders, or wishlist items. Use a cart item's own remove control when the shopper only wants to remove one row.

The button navigates to a storefront URL, WooCommerce clears the cart on the server, and the shopper is redirected to the clean destination URL. It is not an AJAX-only update and does not keep an open mini-cart drawer in place. Without a popup, clearing starts as soon as the link is followed.

  • Redirect to left blank: The element uses the permalink of its rendering context. On a regular Cart page this can return the shopper to the empty cart. In a shared header, template, or popup, set the URL explicitly rather than relying on that context.
  • Redirect to the Cart page: Use this to show your empty-cart message and a clear link back to the shop.
  • Redirect to the Shop page: Use this when the next step should be browsing products immediately. Choose a normal page on the same WooCommerce site so the clear request reaches the store.

Copy the destination page URL, not the generated Empty Cart action link. Do not add the action link to menus, sitemap links, or URL prefetch and prerender rules; visiting that link performs the clear action.

Build a Confirmation Popup


  1. In the Empty Cart Button element, open Confirmation Popup and enable Enable confirmation modal.
  2. In the Bricks structure panel, nest a small layout inside the Empty Cart Button. Add a heading such as Empty your cart?, a short message, and two ordinary Bricks buttons: Keep items and Empty cart. The nested elements become the popup content.
  3. Give the Keep items button a unique class, such as empty-cart-cancel, and the Empty cart button a class such as empty-cart-confirm. Enter class names without a dot in the Bricks class field. If more than one Empty Cart Button is on the same page, use a distinct pair for each popup.
  4. Set Cancel button selector to .empty-cart-cancel and Confirm button selector to .empty-cart-confirm. Include the leading dots in these selector fields. You do not need to add a separate popup trigger or set a URL on either child button.
  5. Enable Show preview on builder while editing the popup. Use the modal background, border, shadow, width, height, and padding controls, and adjust the backdrop as needed. Let the content size the popup where possible and check it on mobile.
  6. On the storefront, open the popup and click Keep items. Verify the cart is unchanged. Open it again and click Empty cart. Verify the cart is cleared and the redirect reaches the chosen page.

The confirmation is a JavaScript safeguard against accidental clicks. Provide an explicit Cancel button and test keyboard use. Do not rely on clicking the backdrop or pressing Escape to close this popup.

Styling and Empty-State Visibility


  • Button type: Use a plain link for a low-emphasis action, or choose a button size and style with optional outline or circle treatment.
  • Icon: Add a trash icon if it helps shoppers identify the action. Use the icon typography, position, gap, margin, and hover color controls to align it with the label.
  • Button Styles: Set width, spacing, background, typography, border, and shadow. The Hover State controls style hover separately. Keep the action distinct from Checkout and leave the keyboard focus indicator visible.
  • Link attributes: Use Aria label for an icon-only button, for example Empty shopping cart. Title and Rel Attribute are optional link attributes.
  • When the cart is empty: The storefront script uses WooCommerce's cart-items cookie to hide the element and responds to supported classic WooCommerce cart events. Add a separate empty state with a Continue shopping link. To hide an entire toolbar on page render, use the BricksUltimate Is cart empty? condition set to false. Test whether your layout needs the toolbar to reappear after an AJAX add without a full reload.

Test Before Publishing


  • Test with a guest and a signed-in shopper. Clear a cart with multiple items and an applied coupon, then check the Cart page and header counter after navigation.
  • Test an empty cart and add an item again. Confirm the button appears where expected. In a custom mini-cart or AJAX-loaded layout, test the button, popup, and visibility in that exact layout rather than assuming it behaves like a regular Cart page.
  • Use the Bricks element in a Bricks-rendered layout. It is not a replacement block for WooCommerce's Cart Block. If you place it beside a block-based cart, test visibility and the redirect separately, since the button listens for classic cart events.

Troubleshooting

  • The button is missing: Check the feature is enabled and test with a non-empty cart in the same browser. Confirm the layout does not hide the button with a Bricks condition or a stale cart cookie.
  • The popup does not open: Enable the confirmation modal and make sure the Empty Cart Button has nested popup content. Test on the storefront, verify the footer renders, and check that the element script loaded.
  • Cancel or Confirm does nothing: Make sure the selector includes a leading dot for a CSS class, matches the corresponding child button, and is unique on the page. Test after saving the builder changes.
  • It clears the cart but lands on the wrong page: Set a full same-site URL in Redirect to. Verify the destination is not cached with another cart state or redirecting elsewhere.
  • The cart still looks populated: Check the actual Cart page after navigation. Exclude cart and checkout views and the clear-action request from shared caching, and verify any mini-cart fragments or header counters refresh for the active shopper.

For the rest of your cart layout, see Cart Content, Mini Cart Builder, and Cart Counter.

Related BricksUltimate Resources


  • Empty Cart Button: The original BricksUltimate documentation covers enabling the element and placing it on a Cart page, at checkout, or in an off-canvas cart.
  • Miscellaneous Settings: See the Checkout Empty Cart Message section for instructions on assigning a Bricks template to the checkout empty state.