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

    Product Price Quantity Total
woocommerce_before_cart_contents
× Placeholder image Woo 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

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_before_cart

2. wooommerce_cart_actions

The woocommerce_cart_actions hook is used to add custom actions or buttons placed at specific points you wish under the cart totals on the WooCommerce cart page. This hook is typically used to indicate custom actions such as ‘Update cart’ or ‘Add a coupon’ presented as a link or a button.

wooommerce_cart_actions

3. 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_before_cart_table

4. 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_before_cart_contents

flexi bogo cta banner image


This to the shop owners who are running or planning to run BOGO offers on their WooCommerce store…

BOGO deals are great for increasing your sales, but have you thought about which offers are bringing you more revenue and which offers are not performing that great?

Don’t just set a BOGO deal, track the revenue generated by your deals in real-time with the Flexi BOGO for WooCommerce plugin.

5. woocommerce_cart_contents

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

woocommerce_cart_contents

6. woocommerce_cart_coupon

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

woocommerce_cart_coupon

7. woocommerce_after_cart_contents

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

woocommerce_after_cart_contents

8. woocommerce_after_cart_table

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

woocommerce_after_cart_table

9. woocommerce_cart_collaterals

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

woocommerce_cart_collaterals

10. 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_before_cart_totals

11. 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_totals_before_shipping

12. 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_before_shipping_calculator

13. 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

14. 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.

15. woocommerce_after_shipping_rate

The woocommerce_after_shippping_rate hook is placed in the ‘shipping options’ under the cart totals. This hook will allow you to modify or display information related to shipping rates.

woocommerce_after_shipping_rate

16. 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_totals_before_order_total

17. 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_totals_after_order_total

18. 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_after_cart_totals

19. woocommerce_cart_is_empty

The woocommerce_cart_is_empty hook is placed on the empty cart page. This hook is triggered when the customer visits the cart page and the cart is empty. Using this hook you can 

add additional text below the ‘Your cart is currently empty!’ text.

woocommerce_cart_is_empty

20. 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_proceed_to_checkout

21. woocommerce_after_cart

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

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

Share It:

Subscribe
Notify of
2 Comments
Newest
Oldest
Inline Feedbacks
View all comments
John Pozadzides
5 months ago

Rashmi, no one takes time out to thank people anymore, but wanted to let you know that this guide is UNBELIEVABLY helpful. Seriously. Thank you. I know it must have taken a lot of time to put this together and I see you did it like a year ago. Can’t believe you don’t have 100 thank yous on this post, but it’s the best I’ve ever seen to explain exactly what is going on with inserting snippets in my WooCommerce pages.

Thanks again. – John P.

2
0
Would love your thoughts, please comment.x
()
x