首页 > 解决方案 > 将自定义获取参数添加到 woocomerce 感谢页面

问题描述

如果 order_amount 超过 50 美元,我需要将自定义 get 参数添加到 woocomerce 感谢页面。我需要它来进行跟踪。也许有人有它的功能?标准页面链接:

https://somesite.com/checkout/order-received/1111110/?key=wc_order_C5OOjXBZyAdqx

并带有订单金额参数

https://somesite.com/checkout/order-received/1111110/?key=wc_order_C5OOjXBZyAdqx&order_amount=50

标签: phpwordpress

解决方案


你可以这样做:

add_filter('woocommerce_get_return_url', 'wc_override_thankyou_url', 10, 2 );
function wc_override_thankyou_url( $url, $order ){

    if( $order->get_total() >= 50 ){
        $url = $url . '&order_amount=50';
    }

    return $url;
}

推荐阅读