Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets

WooCommerce has made it really easy to customize our shop with the help of various hooks. WooCommerce has placed different hooks on the product page, cart page & checkout page so that we can add our content on those pages.

In this post, we will look at the various WooCommerce cart page hooks. Different hooks can be used based on the position of the content you want to place on the cart page.

Cart

woocommerce_before_cart

woocommerce_before_cart_table

ProductPriceQuantityTotal
woocommerce_before_cart_contents
×Placeholder imageWoo T-Shirt €5,00
2
€10,00
×Placeholder image Woo Sticker€1,00
1
€1,00
woocommerce_cart_contents

woocommerce_cart_coupon

woocommerce_after_cart_contents

woocommerce_after_cart_table

woocommerce_cart_collaterals

woocommerce_before_cart_totals

Cart Totals

Subtotal€11,00
woocommerce_cart_totals_before_shipping
Shipping

woocommerce_before_shipping_calculator

Calculate Shipping

woocommerce_after_shipping_calculator

woocommerce_cart_totals_after_shipping
woocommerce_cart_totals_before_order_total
Total€18,00
woocommerce_cart_totals_after_order_total

woocommerce_proceed_to_checkout Proceed to Checkout

woocommerce_after_cart_totals

woocommerce_after_cart

The following are the cart page hooks-

  1. woocommerce_before_cart
  2. woocommerce_before_cart_table
  3. woocommerce_before_cart_contents
  4. woocommerce_cart_contents
  5. woocommerce_cart_coupon
  6. woocommerce_after_cart_contents
  7. woocommerce_after_cart_table
  8. woocommerce_cart_collaterals
  9. woocommerce_before_cart_totals
  10. woocommerce_cart_totals_before_shipping
  11. woocommerce_before_shipping_calculator
  12. woocommerce_after_shipping_calculator
  13. woocommerce_cart_totals_after_shipping
  14. woocommerce_cart_totals_before_order_total
  15. woocommerce_cart_totals_after_order_total
  16. woocommerce_proceed_to_checkout
  17. woocommerce_after_cart_totals
  18. woocommerce_after_cart

 

1. woocommerce_before_cart

The woocommerce_before_cart hook is 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 Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

2. woocommerce_before_cart_table

The woocommerce_before_cart_table hook is placed inside the cart form but before the start of the cart table.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

3. woocommerce_before_cart_contents

The woocommerce_before_cart_contents hook is placed inside the cart table after the title of the columns. This hook can be used if you want to display any message inside the table.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

4. woocommerce_cart_contents

The woocommerce_cart_contents hook is placed inside the table and above the ‘Update Cart’ button.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

5. woocommerce_cart_coupon

The woocommerce_cart_coupon hook is placed below the ‘Apply Coupon’ button.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

6. woocommerce_after_cart_contents

The woocommerce_after_cart_contents hook is placed after the coupon and inside the cart table.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

7. woocommerce_after_cart_table

The woocommerce_after_cart_table hook is placed outside the cart table but inside the cart form.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

 

8. woocommerce_cart_collaterals

The woocommerce_cart_collaterals hook is placed below the cart table and above the cart totals.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

9. woocommerce_before_cart_totals

The woocommerce_before_cart_totals hook can be found in the file cart-totals.php. It is placed before the cart subtotal.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

10. woocommerce_cart_totals_before_shipping

The woocommerce_cart_totals_before_shipping hook is inside the cart-totals.php file. It is placed above the shipping fields in the cart totals. If we add our function to this hook, it will get executed if the cart has shipping enabled.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

11. woocommerce_before_shipping_calculator

The woocommerce_before_shipping_calculator hook is placed above the ‘Calculate Shipping’ option in the cart totals and below the shipping options.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

12. woocommerce_after_shipping_calculator

The woocommerce_after_shipping_calculator hook is placed after the ‘Calculate Shipping’ options and above the total.
WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

13. woocommerce_cart_totals_after_shipping

The woocommerce_cart_totals_after_shipping hook is similar to woocommerce_cart_totals_before_shipping but it is placed after the shipping fields.

 

14. woocommerce_cart_totals_before_order_total

The woocommerce_cart_totals_before_order_total hook can be found in cart-totals.php file in WooCommerce. It is placed just above the totals field in the cart.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

15. woocommerce_cart_totals_after_order_total

The woocommerce_cart_totals_after_order_total action hook is also created in cart-totals.php file of WooCommerce. It is placed just below the totals field on the cart page.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

16. woocommerce_after_cart_totals

The woocommerce_after_cart_totals hook is placed in the cart-totals.php file in WooCommerce below the ‘Proceed to Checkout’ button.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

17. woocommerce_proceed_to_checkout

The woocommerce_proceed_to_checkout hook 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 Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

18. woocommerce_after_cart

The woocommerce_after_cart hook is placed at the end of the cart, outside the cart table.

WooCommerce Cart Page Hooks: Visual Guide with Code Snippets - Tyche Softwares

Browse more in: WooCommerce Tutorials, Code Snippets, WooCommerce Guide, WooCommerce How Tos

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x