Customizing WooCommerce review-order.php checkout template

11,174

Checkout review-order table load first one time and then ajax is making a 2nd loading (for update purposes is suppose), so you have to use a little condition to avoid that:

<?php if(!defined( 'DOING_AJAX' )): ?>
<h2>Purchase Disclaimer</h2>
<?php endif; ?>

You should avoid <h2> tag as it's already use for <h3 id="order_review_heading">Your order</h3>

Alternatively you can use instead a hooked function in woocommerce_checkout_before_order_review hook this way:

add_action('woocommerce_checkout_before_order_review', 'my_custom_funtion');
function my_custom_funtion(){
    ?>
        <h2>Purchase Disclaimer2</h2>
    <?php
}

This code goes in function.php file of your active child theme (or theme) or also in any plugin php files.

Share:
11,174
Justin
Author by

Justin

SOreadytohelp

Updated on June 13, 2022

Comments

  • Justin
    Justin almost 2 years

    So I am working on WooCommerce with a Child-theme. I have created my structure,

    /themes/child/woocommerce/checkout/review-order.php
    

    My goal is just to add some 'static text' to the page. So for example, <h2>Purchase Disclaimer</h2>

    Inside review-order.php

    <?php
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    ?>
    <h2>Purchase Disclaimer</h2>
    

    My problem is, when I view the page, it then goes,

    <h2>Purchase Disclaimer</h2>
    <h2>Purchase Disclaimer</h2>
    

    I don't know why it seems to load it 2 times. Is this a glitch, or am I loading it weird? Perhaps someone could help clarify this issue for me.

    Thanks in advance

  • Justin
    Justin over 7 years
    That's perfect, thank you. Yeah, I was just using that as an example, sorry. I am going to try the hook. Thanks