【问题标题】:Without coupon = Shipping free, with coupon = with shipping - WooCommerce没有优惠券 = 免运费,有优惠券 = 有运费 - WooCommerce
【发布时间】:2019-07-29 21:17:04
【问题描述】:
【问题讨论】:
标签:
php
wordpress
woocommerce
【解决方案1】:
您可以通过使用简单的代码 sn-p 来实现这一点。
您需要配置一个免费送货,没有任何最低订单金额和统一费率才能显示正常送货。
现在将sn-p下面的内容复制并粘贴到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;
}