My Courses > CustomizeWoo > Module 2 > Lesson 05: Hooks: Actions

Hooks: Actions

MARK LESSON AS COMPLETE

Actions are vital for customizing WooCommerce – if there were no actions, we would have had to edit the plugin core files. Instead, we can “hook” into each template and display custom stuff or run functions.

Video

Please note: English captions are enabled by default (click on “CC” in the video player to disable). Also, you can click on the “gear” icon to manage quality and playback speed. Enjoy!

Sorry, this video is visible to logged in and fully registered students only.
If you already enrolled in this course, please LOG IN
Otherwise, please enroll in the FREE / PRO COURSE
For any other queries, feel free to get in touch

Useful Links

WordPress Action Hooks: https://developer.wordpress.org/plugins/hooks/actions/

WooCommerce Hooks: https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/

8 thoughts on “Hooks: Actions

  1. I created a simple function and it is printing twice on the checkout page. Please tell me why.

    add_action( 'woocommerce_review_order_before_shipping', 'shipping_details', 10, 0 );
    function shipping_details() {
    echo '<p style="color:black;background-color:tan; width:70%;padding-left:20px;"><strong>Mail Innovations</strong> takes 7-10 business days <strong>Standard</strong> takes 3-5 business days</p>';
     }

    Thanks,

    Randal

    1. Hello Randal!

      My guess is that you’ve placed some content inside the “Review Order” section, which is powered by Ajax and possibly is called a couple of times even before interacting with the checkout. Also, if you edit an address field, it’s possible that it prints it again and again.

      The alternative, if you really wanted to show content there, would be to print it as you’ve done BUT set it to display:none. And then when “Ajax completes” (there is a hook for that), you would set it to show() via jQuery

      Does this help?

      1. Yes, thanks for the help. Also, the lessons are great.

  2. I‘m developing about 28 Years now – from Assembler to ColdFusion.
    And i never invested my Money better than in your Courses!
    I just startend and felt in love! Thanx a lot!

  3. Hello Rodolfo!
    I am sure your answer will be positive, and I will have the opportunity to learn later from your examples. But just to be sure, I have 2 questions:
    1. There is the chance to create my PHP function to show on the cart page a different banner/text/ image (doesn’t matter what), based on the product category?
    2. Or to create a PHP function to have different checkout fields based on the product category?
    Thank you!

    1. Hello Marcel, thanks for your question! Yes, of course this is possible. You first need to learn how to show a banner anywhere (module 4) and after that move a step forward and study “conditional logic” (module 5). Let me know how it goes 🙂

Questions? Feedback? Support? Leave your comment now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]

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