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.
Let’s look at each hook in detail, and where it is placed.
- 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.
- woocommerce_before_cart_table – placed inside the cart form but before the start of the cart table.
- 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.
- woocommerce_cart_contents – placed inside the table and above the ‘Update Cart’ button.
- woocommerce_cart_coupon – placed below the ‘Apply Coupon’ button.
- woocommerce_cart_actions – placed below the ‘Update Cart’ button.
- woocommerce_after_cart_contents – placed after the coupon and inside the cart table.
- woocommerce_after_cart_table – placed outside the cart table but inside the cart form.
- woocommerce_cart_collaterals – placed below the cart table and above the cart totals.
- woocommerce_before_cart_totals – placed before the cart subtotal, found in the cart-totals.php file.
- woocommerce_cart_totals_before_shipping – placed above the shipping fields in the cart totals. This hook is inside the cart-totals.php file.
- woocommerce_after_shipping_rate – placed above the ‘Calculate Shipping’ option in the cart totals and below the shipping options.
- woocommerce_before_shipping_calculator – placed above the ‘Calculate Shipping’ option in the cart totals and below the shipping options.
- woocommerce_after_shipping_calculator – placed after the ‘Calculate Shipping’ options and above the total.
- woocommerce_cart_totals_after_shipping – placed after the shipping fields.
- 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.
- 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.
- 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.
- woocommerce_after_cart_totals – placed in the cart-totals.php file in WooCommerce below the ‘Proceed to Checkout’ button.
- woocommerce_after_cart – placed at the end of the cart, outside the cart table.
- 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.