Skip to content
CartPops Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

How to disable the add-to-cart trigger

Stop the cart drawer from opening when a shopper adds a product, so it opens only when they click the launcher.

By default, the cart drawer slides open when a shopper adds a product to the cart. If you would rather keep the shopper on the page, you can switch that off. The drawer then opens only when the shopper clicks a launcher.

Turn it off in the settings

In wp-admin, go to WooCommerce > CartPops > Advanced.

On the General tab, find Open drawer on.

Choose Launcher click only, then click Save Changes.

The other choice, Add to cart, is the default.

With Launcher click only, make sure shoppers have a way to reach the cart. Keep the floating launcher on, or add a launcher to your header with a shortcode or a menu item.

Turn it off with code

You can also set the behavior from PHP with the cartpops_add_to_cart_trigger filter. Add this snippet to your child theme’s functions.php file, or to a code snippets plugin:

add_filter( 'cartpops_add_to_cart_trigger', function () {
	return 'launcher';
} );

The filter accepts two values:

  • add_to_cart opens the drawer after a successful add to cart.
  • launcher leaves opening to the launcher and other buttons the shopper clicks.

The filter takes priority over the saved setting. The Open drawer on field in wp-admin still shows what you saved, not what the filter returns, so check your code if the setting and the behavior disagree.

Any other value is treated as launcher. For old code, CartPops also maps the V1 values both, drawer, popup and bar to add_to_cart, and manual and none to launcher. See PHP filters for the full reference.

Keep one button from opening the drawer

You can leave the setting on Add to cart and still stop single buttons from opening the drawer. Add the attribute data-cpops-cart-open="false" to the add to cart button:

<a href="?add-to-cart=123" data-product_id="123" class="button add_to_cart_button ajax_add_to_cart" data-cpops-cart-open="false">
	Add to cart
</a>

The item is still added, and the cart count and totals still update. Only the automatic opening is skipped.

This applies to buttons that add through WooCommerce’s classic AJAX add to cart. The attribute value must be exactly false in lowercase.

Was this page helpful?