Change checkout order review section in Woocommerce

跟風遠走 提交于 2019-12-01 08:51:54

问题


In Woocommerce, I have successfully moved the payment methods section before he review order table: Change payment methods location before order details table in Woocommerce.

I would like to add an <h3> headline ("Your order") and a <p> paragraph ("I have accepte the terms…") in checkout page, just above the review order table.


回答1:


You will replace in your existing code the following block:

add_action( 'woocommerce_checkout_order_review', 'reordering_checkout_order_review', 1 );
function reordering_checkout_order_review(){
    remove_action('woocommerce_checkout_order_review','woocommerce_checkout_payment', 20 );
    add_action( 'woocommerce_checkout_order_review', 'custom_checkout_payment', 8 );
    add_action( 'woocommerce_checkout_order_review', 'custom_checkout_place_order', 20 );
}

By this code block (keeping the 2 other functions):

add_action( 'woocommerce_checkout_order_review', 'reordering_checkout_order_review', 1 );
function reordering_checkout_order_review(){
    remove_action('woocommerce_checkout_order_review','woocommerce_checkout_payment', 20 );

    add_action( 'woocommerce_checkout_order_review', 'custom_checkout_payment', 8 );
    add_action( 'woocommerce_checkout_order_review', 'after_custom_checkout_payment', 9 );
    add_action( 'woocommerce_checkout_order_review', 'custom_checkout_place_order', 20 );
}

function after_custom_checkout_payment() {
    ?>
    <div id="before-order-table" class="woocommerce-checkout-custom-text">
        <h3><?php _e("Your order", "woocommerce"); ?></h3>
        <p><?php _e("I have accepted the terms and bla bla bla", "woocommerce"); ?></p>
    </div>
    <?php
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.



来源:https://stackoverflow.com/questions/51848171/change-checkout-order-review-section-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!