Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无优惠券=免费配送,有优惠券=配送-商务_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 无优惠券=免费配送,有优惠券=配送-商务

Php 无优惠券=免费配送,有优惠券=配送-商务,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我的商店需要帮助。 我们的客户在支付39欧元后可获得免费送货。 如果我们的客户在使用优惠券后获得低于39欧元的价格,则发货不再免费 例如: 客户在购物车上,购物车全额为42欧元=免运费 使用-15%折扣券=购物车金额为38,55=运费您可以通过使用一个简单的代码片段来实现这一点 您需要配置一个免费配送,不包含任何最低订单金额和统一费率,以显示正常配送 现在将下面的代码片段复制并粘贴到functions.php中。如果小计小于39,则隐藏免费送货,否则隐藏统一费率 add_filter( 'woo

我的商店需要帮助。 我们的客户在支付39欧元后可获得免费送货。 如果我们的客户在使用优惠券后获得低于39欧元的价格,则发货不再免费

例如:

客户在购物车上,购物车全额为42欧元=免运费


使用-15%折扣券=购物车金额为38,55=运费您可以通过使用一个简单的代码片段来实现这一点

您需要配置一个免费配送,不包含任何最低订单金额统一费率,以显示正常配送

现在将下面的代码片段复制并粘贴到functions.php中。如果小计小于39,则隐藏免费送货,否则隐藏统一费率

add_filter( 'woocommerce_package_rates',  'modify_shipping_rate', 15, 2 );
function modify_shipping_rate( $available_shipping_methods, $package ){

    global $woocmmerce;
    $total_coast = WC()->cart->get_subtotal();

    if( $total_coast < 39 ){
        unset($available_shipping_methods['free_shipping:4']); // Config the Free Shipping method id properly
    }else{
        unset($available_shipping_methods['flat_rate:1']); //// Config the Flatrate shipping method id properly
    }

    return $available_shipping_methods;
}
add_filter('woocommerce_package_rates','modify_shipping_rate',15,2);
函数修改装运率($available\u shipping\u methods,$package){
全球$Woocmerce;
$total_coast=WC()->cart->get_subtotal();
如果($total_coast<39){
unset($available_shipping_methods['free_shipping:4']);//正确配置免费送货方法id
}否则{
unset($available_shipping_methods['flat_rate:1']);///正确配置Flatrate shipping method id
}
返回$available\u shipping\u方法;
}