【问题标题】:Show Woocommerce order details on custom thank you page在自定义感谢页面上显示 Woocommerce 订单详细信息
【发布时间】:2019-09-23 12:35:57
【问题描述】:

您好,我为我的 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 和(/* Template Name: COD Thank you page */),从原始 Woocommerce order-details.php 复制了代码,但只加载了空白页面。有人可以帮我正确地做到这一点。 谢谢

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

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

    【讨论】:

    • 嗨,标准 woocomerce 订单已收到我用于信用卡/借记卡付款选项的页面。货到付款是带有自定义感谢页面的额外付款选项。据我了解,我不能在 WooCommerce > Settings > Advanced > Order Received 中使用多个“slug”?
    • 您可以根据购买的产品或付款方式进行重定向。在此处查看更多信息:rudrastyh.com/woocommerce/thank-you-page.html#redirects
    • 嗨,是的,我知道我的重定向完全没有问题。我只想在我的自定义感谢页面上显示订单详细信息,不知道如何实现。
    猜你喜欢
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    相关资源
    最近更新 更多