Support » Plugin: WooCommerce » Want to add a message to Checkout Order Details page

  • Resolved David Borrink

    (@davidborrink)


    I want to add a message between the Order Details and Customer Details section of the checkout page. I have the order-details.php file open and I found the spot where a div could be added between the two sections.

    What I want to add is a line of text and a link to another page to sign up for a newsletter.

    My confusion is if I should edit this file and stick it in my child theme’s WooCommerce folder, or should I create an action or a filter in my functions.php file.

    This line of code…

    <?php do_action( 'woocommerce_order_details_after_order_table', $order ); ?>

    … is this the beginning of the Customer Details section? Or the actual section in full?

    I’m just not sure where I would either place the code in orders-placed.php, or what action or filter I would use to insert a message on functions.php. I have referenced your Hooks list, but it’s unclear if I need to add a new hook or filter an existing hook.

    https://wordpress.org/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Suggest you don’t edit the theme or plugin files as these may be overwritten by later updates.

    This hook in your child theme’s functions.php should do what you want:

    add_action ('woocommerce_checkout_after_customer_details', 'my_func');
    function my_func () {
      print '<p>Message</p>';
    }

    Thread Starter David Borrink

    (@davidborrink)

    That’s what I was leaning towards: using a function for that very reason of forward compatibility.

    I pasted in your code exactly as you entered it above so that I could see where it landed, using the “Message” text. Nothing showed up on my checkout details page. I refreshed a couple times in case the cache wasn’t working. But nothing.

    I also tried woocommerce_checkout_before_customer_details to see if putting it before the customer details would work. But it didn’t.

    A hard-refresh may clear a browser cache but may not always be enough to clear a page from a cache plugin if you have one. If so try deactivating it. If you look at the very bottom of a page’s source there is often an html comment that say’s if its a cached page or not.

    Thread Starter David Borrink

    (@davidborrink)

    Okay it was a cache issue. The code did work, and I was able to add my own message, style it and it’s working fine. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Want to add a message to Checkout Order Details page’ is closed to new replies.