Table of Contents
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 | |||||
× | Woo T-Shirt | €5,00 |
2
|
€10,00 | |
× | 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 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.
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.
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.
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.
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.
6. woocommerce_cart_coupon
The woocommerce_cart_coupon hook is placed below the ‘Apply Coupon’ button.
7. woocommerce_after_cart_contents
The woocommerce_after_cart_contents hook is placed after the coupon and inside the cart table.
8. woocommerce_after_cart_table
The woocommerce_after_cart_table hook is placed outside the cart table but inside the cart form.
9. woocommerce_cart_collaterals
The woocommerce_cart_collaterals hook is placed below the cart table and above the cart totals.
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.
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.
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.
13. woocommerce_after_shipping_calculator
The woocommerce_after_shipping_calculator hook is placed after the ‘Calculate Shipping’ options and above the total.
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.
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.
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.
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.
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.
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.
21. woocommerce_after_cart
The woocommerce_after_cart hook is placed at the end of the cart, outside the cart table.
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.
Hi John,
Thank you so much for your incredibly kind words! It’s truly heartwarming to receive such positive feedback, and I’m glad to hear that you found the guide so helpful.
I really appreciate you taking the time to share your thoughts.