1

我想在我的 WooCommerce 结帐的感谢页面上显示一组订单详细信息。已经有一些了,我在模板中找到了它们thankyou.php。但我需要额外div添加一个名为“Trusted Shops”的工具。

所以我尝试了以下代码:

add_action( 'woocommerce_order_details_before_order_table', 'trusted_shops_thankyou', 15, 1 );
function trusted_shops_thankyou( $order_id ) {

    echo 'tsCheckoutOrderNr: '.$order->get_order_number();
    echo 'tsCheckoutBuyerEmail: '.$order->get_billing_email();
    echo 'tsCheckoutOrderAmount: '.$order->get_formatted_order_total();
    echo 'tsCheckoutOrderCurrency: '.$order->get_order_number();
    echo 'tsCheckoutOrderPaymentType: '.wp_kses_post( $order->get_payment_method_title());
    echo 'tsCheckoutOrderEstDeliveryDate: '.$order->get_order_number();

    // I need to fill the following DIVs
    echo '
        <div id="trustedShopsCheckout" style="display: none;">
            <span id="tsCheckoutOrderNr">2016-05-21-001</span>
            <span id="tsCheckoutBuyerEmail">mein.kunde@mail.de</span>
            <span id="tsCheckoutOrderAmount">4005.95</span>
            <span id="tsCheckoutOrderCurrency">EUR</span>
            <span id="tsCheckoutOrderPaymentType">VORKASSE</span>
            <span id="tsCheckoutOrderEstDeliveryDate">2016-05-24</span>
        </div>
        <div id="customCheckoutDiv"></div>
    ';
}

问题是,我没有从$order. 我收到以下错误:

Fatal error: Uncaught Error: Call to a member function get_order_number() on null in....

我尝试添加此代码,但没有帮助:

global $woocommerce, $post;
$order = new WC_Order($post->ID);

什么不见​​了?我怎么能从中获取数据$order

和奖金:我怎么能得到预计的交货日期?;)

4

1 回答 1

1

我知道了!

我需要改变它:

function trusted_shops_thankyou( $order_id )

对此:

function trusted_shops_thankyou( $order )
于 2018-05-07T19:41:03.397 回答