Posted on

WooCommerce Visual Hook Guide: Cart Page

Hi there!

I’ve put together a visual (yet, you can copy/paste!) hook guide for the WooCommerce Cart Page. If you like this and it is helpful to you, let me know in the comments and I’ll create another one for the checkout, single product page and my account page.

You can find WooCommerce Cart hooks quickly and easily by seeing their actual locations. Great thing is – all you need to do in your functions.php is “add_action(‘place-hook-here’,’your-PHP-function-here’);” and you can place your custom functions anywhere on the WooCommerce Cart Page!

Hope this guide is helpful to you – if you want me to add anything or edit a particular area of this, feel free to contact me via the comments. Enjoy!

WooCommerce Cart Page [Visual Hook Guide]

Cart

woocommerce_before_cart

woocommerce_before_cart_table

    Product Price Quantity Total
woocommerce_before_cart_contents
× Ciara Bow Earrings Gold Test 6 €5,00
2
€10,00
× Isla ring Test product €1,00
1
€1,00
woocommerce_cart_contents

woocommerce_cart_coupon

woocommerce_after_cart_contents

woocommerce_after_cart_table

woocommerce_cart_collaterals

You may be interested in…

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

WooCommerce Cart Default add_actions


// These are actions you can unhook/remove!

add_action( 'wp_loaded', array( WC_Cart, 'init' ) );
add_action( 'wp', array( WC_Cart, 'maybe_set_cart_cookies' ), 99 );
add_action( 'shutdown', array( WC_Cart, 'maybe_set_cart_cookies' ), 0 );
add_action( 'woocommerce_add_to_cart', array( WC_Cart, 'calculate_totals' ), 20, 0 );
add_action( 'woocommerce_applied_coupon', array( WC_Cart, 'calculate_totals' ), 20, 0 );
add_action( 'woocommerce_check_cart_items', array( WC_Cart, 'check_cart_items' ), 1 );
add_action( 'woocommerce_check_cart_items', array( WC_Cart, 'check_cart_coupons' ), 1 );
add_action( 'woocommerce_after_checkout_validation', array( WC_Cart, 'check_customer_coupons' ), 1 );

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 );

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file before "?>" (CSS goes in your child theme style.css file). Make sure to edit such files with an FTP software and not via the WP Editor - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance 🙂

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert, WordCamp speaker and Internet marketer, Rodolfo Melogli has worked as a WooCommerce freelancer since 2011. He helps entrepreneurs and developers overcoming their WooCommerce nightmares 🙂 Rodolfo is the organiser of WordCamp Dublin, the Dublin WooCommerce Meetup, the Dublin Ecommerce Meetup and the Dublin WordPress Meetup. He enjoys interacting with people, travelling and chasing tennis & soccer balls. Of course, he loves pizza too.

56 thoughts on “WooCommerce Visual Hook Guide: Cart Page

  1. Worked great! Thak you 🙂 🙂

  2. Hi Rodolfo,
    I want to remove the link on the product thumbnail and the product name in the cart page. I used one of your snippets for the same purpose on the shop page, which worked fine, but still don’t understand how to adjust this one to work on the cart page as well. Any suggestions?
    Kind regards, Johan

    1. Hey Johan, thanks for your comment! Unfortunately this is custom work – however you can use this as inspiration: https://businessbloomer.com/woocommerce-remove-permalink-product-order-table/

  3. Hi

    I have tried to add visual hook php code but that isn’t working in storefront child theme i cant see any change in it also it the same case when i trying to add php code cart and checkout page it the same problem

    1. Pankaj, thanks for your comment! What code did you use?

  4. How would I move the Coupon field and button to ‘woocommerce_cart_totals_before_order_total’?
    Thanks, will

    1. Will, thanks for your comment! Have you watched the Cart Customization tutorial? https://businessbloomer.com/woocommerce-visual-hook-guide-cart-page/#comment-25415

  5. It is probably me but I don’t understand.
    What do you mean with ,’your-PHP-function-here’);” ?

    I want to make my cart page a bit more professional looking.

    1. Hey Patrick, thanks for your comment! I recommend you watch this video lesson, it should help: https://businessbloomer.com/customize-cart-page-woocommerce/

  6. Hi, Rodolfo

    I used remove_action( ‘woocommerce_cart_collaterals’, ‘woocommerce_cart_totals’, 10 ); to remove cart totals but nothings happen. I would like to remove that and place below the cart_content same cart layout you use in the video tutorial.

    1. Hey, thanks for your comment! It could be that your theme is already overriding that call, so I’m afraid this is custom work and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R

  7. Rodolfo, your visual hook guides have been a life saver for me. I have a question though. I’m using these hooks to add content above the cart, however I notice that it doesn’t work if the cart is empty. Are there hooks specifically for empty carts?

    1. That’s an awesome question Jason! So good that I decided to write a tutorial about it: https://businessbloomer.com/woocommerce-add-content-empty-cart-page/ Hope this helps!

  8. WOW!!! are you The best woo commerce Teacher Ever.
    Can help with a custom checkout gateway ?
    That will be A great Piece

    1. Ahah thanks Paulem, your feedback is much appreciated! Cool, I will put “custom gateway” on my to-do list 🙂 Thank you!

  9. thank you so much

    1. You’re welcome Rahim! 🙂

  10. great guide,, i have questionshow to fix the pay button ?

    1. Hello Arya, thanks for your comment. I’m not sure I entirely understand your point, maybe send me a screenshot to explain. Cheers!

    2. where i send screenshot Mr. rodolfo ?
      cannot post image this here
      thanks for the reply,,i’m very happy

    3. Hey Arya, you can upload screenshots to Dropbox, Screencast.com or similar websites. Then, they’ll give you a link you can paste in a blog comment. Hope this helps!

  11. Thank you so so much. I find myself returning to your site time after time to refer to your guides. Thank you so so much

    1. This is excellent feedback, much appreciated Ewan! Thank you 🙂

  12. Thank you soo much! This guide is soo usefull!

    1. Thank you so much Mick! 🙂

  13. how to remove x(Remove this item) and that column from cart page and replace it under product name in woocommerece cart page

    1. Thanks for your comment Amit! I have an article that might partially help you: http://businessbloomer.com/woocommerce-hide-column-cart-table/.

      In regard to adding the “X” under the product title, unfortunately this is custom development work and I cannot provide this solution on the blog right now. I will add it to my to-write list but I cannot guarantee I will be publishing this before 2-3 months.

      If you would like to get a quote for the fix, feel free to go here to get in touch.

      Thanks for your understanding!

      ~R

  14. This is great, thanks!

    1. You’re welcome Jason 🙂

  15. Hi Rodolfo,

    Great articles you have released for everyone. They helped me a lot in my projects. I also attended your last webinar. Waiting for the next one. Thanks.

    1. Awesome! Thank you so much Manas 🙂

  16. So useful – thankyou 🙂

  17. Thank you so much man, this type of visual presentation really helpful for every one. Thank you so much again.

    1. Thank you Vishal 🙂

  18. very very nice

    Thank you !

    1. You’re very welcome Curtis – thanks for sharing your feedback 🙂

  19. A huge THANKS! 🙂
    (I’ve figured out, I wish I could find this before…)

    1. Awesome 🙂 Thank you so much TeeCee!

  20. Please do this for the checkout page aswell 🙂

    1. Thank you Jan! Working on it 🙂

  21. […] visual display in the post provides the hook names, shown in the spots where they apply. Not only is it visual, […]

  22. Awesome resource, you filled a special need! Single Product pretty please with sugar on it!

    1. Ahah thanks again Pam, really appreciate your feedback! Single Product (variable product) will be published tomorrow. Feel free to join the newsletter so that I can notify you when the other pages are published as well. Talk soon 🙂 ~R

  23. […] visual display in the post provides the hook names, shown in the spots where they apply. Not only is it visual, […]

  24. This is a terrific guide! Thank you so much!!!!

    1. Awesome Patty 🙂 Thanks so much for your feedback!

  25. Nice! Excellent job!
    Especially because it’s visual, it’s becomes much more clear where the hooks show up.

    Looking forward to the single page 🙂

    1. Brilliant! Thanks so much for your comment 🙂

  26. Well done Rodolfo, this is a fantastic resource for woo lovers 😀

    1. Thank you Mikel! Your feedback is invaluable 🙂

  27. Love this guide! Can’t wait for the entire suite 😀

    1. Thanks so much Meagan! Glad to know people loved this. I’m so happy 🙂 I’ll keep in touch!

  28. Great guide, feel free to do more of these 🙂

    1. Thank you so much Jan! Keep in touch, as more visual guides will come in the following days! ~R

Questions? Feedback? Support? Leave your Comment Now!
If you're writing code, please wrap it between: [php] code_here [/php]

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