Posted on

All the 21 WooCommerce Cart Hooks You Need to Know

This guide lists all the WooCommerce cart hooks and where you can place them on the cart page.

WooCommerce cart hooks

Last updated on February 7, 2023

This blog is part of our WooCommerce visual hook guide. You can view our checkout hooks blog and we’ll soon be adding up the product page hooks blog.

For now, let’s look at all the WooCommerce cart hooks and where you can place them on the cart page to add your content.

The WooCommerce cart hooks

Here are all the cart page hooks in a visual format.

WooCommerce cart hooks visual

Let’s look at each hook in detail, and where it is placed.

  1. woocommerce_before_cart – placed before the cart form. It means that the function we hook into this action will be executed before the start of the cart form.
  2. woocommerce_before_cart_table – placed inside the cart form but before the start of the cart table.
  3. woocommerce_before_cart_contents – placed inside the cart table after the title of the columns. This hook can be used to display any message inside the table.
  4. woocommerce_cart_contents – placed inside the table and above the ‘Update Cart’ button.
  5. woocommerce_cart_coupon – placed below the ‘Apply Coupon’ button.
  6. woocommerce_cart_actions – placed below the ‘Update Cart’ button.
  7. woocommerce_after_cart_contents – placed after the coupon and inside the cart table.
  8. woocommerce_after_cart_table – placed outside the cart table but inside the cart form.
  9. woocommerce_cart_collaterals – placed below the cart table and above the cart totals.
  10. woocommerce_before_cart_totals – placed before the cart subtotal, found in the cart-totals.php file.
  11. woocommerce_cart_totals_before_shipping – placed above the shipping fields in the cart totals. This hook is inside the cart-totals.php file.
  12. woocommerce_after_shipping_rate – placed above the ‘Calculate Shipping’ option in the cart totals and below the shipping options.
  13. woocommerce_before_shipping_calculator – placed above the ‘Calculate Shipping’ option in the cart totals and below the shipping options.
  14. woocommerce_after_shipping_calculator – placed after the ‘Calculate Shipping’ options and above the total.
  15. woocommerce_cart_totals_after_shipping – placed after the shipping fields.
  16. woocommerce_cart_totals_before_order_total – placed just above the totals field in the cart. This hook can be found in cart-totals.php file in WooCommerce.
  17. woocommerce_cart_totals_after_order_total – placed just below the totals field on the cart page. This action hook is also created in cart-totals.php file of WooCommerce.
  18. woocommerce_proceed_to_checkout – can be found in cart-totals.php file in the WooCommerce. The ‘Proceed to Checkout’ button is also placed using this hook inside the ‘wc-template-hooks.php‘ file.
  19. woocommerce_after_cart_totals – placed in the cart-totals.php file in WooCommerce below the ‘Proceed to Checkout’ button.
  20. woocommerce_after_cart – placed at the end of the cart, outside the cart table.
  21. woocommerce_cart_is_empty – this hook is on the empty cart page. You can use it to let your customers visit specific landing pages.

WooCommerce cart default add_actions

// These are the actions you can unhook/remove!
add_action( 'woocommerce_before_cart', 'woocommerce_output_all_notices', 10 );
add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
add_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
add_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );

Cart page plugin to reduce abandonment

The above hooks show how to add some texts with simple code snippets to the WooCommerce cart page.

But what about other cart enhancements that help users checkout faster?

Cashier for WooCommerce plugin provides side cart, skip cart, buy now buttons, one-click checkout, clear cart, cart notices and other features to optimize your checkout.

Final words

I hope this guide helped you cover all the crucial WooCommerce cart hooks.

Use them to make your online store’s cart page better. And for more cart page enhancements, refer to this blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.