wordpress - 在自定义感谢页面上显示 Woocommerce 订单详细信息

您好,我为 COD(货到付款)付款选项创建了自定义感谢页面。重定向下面的代码。

add_action( 'template_redirect', 'thankyou_custom_payment_redirect');
    function thankyou_custom_payment_redirect(){
    if ( is_wc_endpoint_url( 'order-received' ) ) {
        global $wp;

        // Get the order ID
        $order_id =  intval( str_replace( 'checkout/order-received/', '', $wp->request ) );

        // Get an instance of the WC_Order object
        $order = wc_get_order( $order_id );

        // Set HERE your Payment Gateway ID
        if( $order->get_payment_method() == 'cod' ){

            // Set HERE your custom URL path
            wp_redirect( home_url( '/custom-page/' ) );
            exit(); // always exit
        }
    }
}
现在,在我的 /custom-page/ 中,我想显示与 Woocommerce order-details.php 中相同的详细信息。我创建了 custom-page.php with(/* Template Name: COD Thank you page */) 为我的感谢页面,从原始 Woocommerce order 复制代码-details.php 但只是加载空白页。有人可以帮我正确地做到这一点吗? 谢谢

最佳答案

确保您的新 order-details.php 有一个 URL,并且该 URL 已添加到 WooCommerce > 设置 > 高级 > 已收到订单中。在那里,您将添加新订单详细信息页面的 URL 的 slug。 还有更简单的方法可以使用插件创建自定义感谢页面,例如:https://wordpress.org/plugins/yith-custom-thank-you-page-for-woocommerce/

https://stackoverflow.com/questions/58062597/

相关文章:

java - DynamoDB 排序键的多重比较条件?

angular - 使用 ngx-image-cropper 在单个图像上使用多个裁剪框

reactjs - ThemeProvider/Typescript 错误 : Types of p

angular6 - 无法在 'getUserMedia' : At least one of au

rust - 可以为 Rust 中的元组定义 Ord 吗?

python - 为什么当前模块中没有__dict__?

amazon-web-services - 解码 AWS session token

python - Flask:flask 在 conda 环境中运行不工作 - Windows、Py

python - 如何输入泛型函数?

asp.net - 在 Windows Server 上无法确定重定向的 https 端口,但在 P