My Courses > CustomizeWoo > Module 4 > Lesson 09: Checkout Page: ADD Content

Checkout Page: ADD Content

MARK LESSON AS COMPLETE

This is how to add content to the checkout page by using the visual hook guide. Always start from displaying some simple “TEXT” in the correct position, and then make your functions more complex. A little win is better than hours spent troubleshooting.

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

WooCommerce Visual Hook Guide: Checkout Page

Related Snippets

WooCommerce: Add Upsell Area @ Checkout Page

WooCommerce: How to Add Scripts to the Checkout Page

WooCommerce: Add Shipping Notices on Checkout Page

WooCommerce: Add Content Under โ€œPlace Orderโ€ Button @ Checkout

WooCommerce: Display Order Delivery Date @ Checkout

WooCommerce: Display Product-Specific T&C @ Checkout

WooCommerce: Display Weight @ Cart & Checkout

WooCommerce: Add Privacy Policy Checkbox @ Checkout

8 thoughts on “Checkout Page: ADD Content

  1. Hello, Rodolfo!
    I would like the “Submit order” button in the checkout page to have a different text depending on which product category is already in the cart. For example: If the product in the cart belongs to the “Albums” category, the “Submit Order” button in checkout should have the text “Submit Albums”. If the product in the cart belongs to the “Music” product category, the “Submit Order” button should have the text “Submit Music”. These are just examples so you can understand what I want. If there are multiple categories in the cart, the button with the text “Submit Order” does not change. Please give me a hint how to start this customization.

    1. Hello Marcel, great question! You would start with https://www.businessbloomer.com/woocommerce-rename-place-order-button-checkout/, see if that works in the first place. After that, you can use some of the https://www.businessbloomer.com/woocommerce-check-product-category-cart/ code to see if there is a specific category in the Cart. Good luck!

      1. Hi, Rodolfo. Here is the code I wrote and it works partially.
        I mean if in the cart are only products from the category “Music”, I have the text “Submit music” – as I want.
        If in the cart are only products from the category “Albums”, I have the text “Submit albums” – as I want.
        If in the cart are only products from any other category, BUT NOT “Music” or “Albums”, I have the text “Submit Order” – as I want.
        The problem is when I mix them.

        What to do when I have products from different categories in the cart to have the button with the text “Submit Order”?

        /**
         * Change the โ€œSubmit Orderโ€ text in the WooCommerce checkout product category
         */
        add_filter('woocommerce_order_button_text', 'change_submit_order_text' );
        function change_submit_order_text( $order_button_text ) {
        
        // set our flag to be false until we find a product in that category
        $cat_in_cart = false;
        
        // Loop through all products in the Cart        
        foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
          
            // If Cart has categories "albums" and "music" , set $cat_in_cart to true
        if ( has_term( 'albums', 'product_cat', $cart_item['product_id'] ) ) {
           $albums_in_cart = true;
           break;
        } elseif ( has_term( 'music', 'product_cat', $cart_item['product_id'] ) ) {
           $music_in_cart = true;
           break;
        } 
        
            
        }
        
        // if a product in the cart is in our categories, do something
        if ( $albums_in_cart ) {
                $order_button_text = 'SUBMIT ALBUMS';
            } 
        elseif ( $music_in_cart ) {
                $order_button_text = 'SUBMIT MUSIC';
            } 
        
        	else {
                $order_button_text = 'SUBMIT ORDER';
            }
            return $order_button_text;
        }
        1. Hi Marcel!

          1) in the foreach you’re using “break”, which exits from the foreach in case one category is returned. Remove both.
          2) in the following if/elseif/else you should check first if both categories are in the cart, so that should become if/elseif/elseif/else

          Hope this helps!

          1. Stucked here: “check first if both categories are in the cart”.
            How exactly should I write a statement if 2 or more categories are in the cart?
            I know how to do it for one, but for more?
            Thank you!

            1. Like this:

              if ( statementA == true && statementB == true ) { ... 
              1. Perfect. Thank you. I’d like to go a little further and add one more condition, this time for a specific product from a category other than “Albums” or “Music”.

                How do I write this statement to include verification of both a product category and a product ID?

                For checking a product category in the cart I use:

                 foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {โ€ฆ
                } 

                To verify a product ID in the cart I use

                 $product_id = 4072; // CHANGE THIS WITH YOUR PRODUCT ID
                $product_cart_id = WC()->cart->generate_cart_id( $product_id );
                $in_cart = WC()->cart->find_product_in_cart( $product_cart_id ); 
                1. Hey Marcel!

                  If I understand well, you’d use e.g.:

                   if ( $music_in_cart && $in_cart ) { } 
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 *