显示有关免运费所需金额的信息。
喜欢:
加 10 美元即可免运费
一切正常,并且基于固定金额的免费送货。我现在的问题是,即使优惠券设置免费送货,它也会显示。有什么方法可以检查订单是否已经使用任何免费送货方式?
我在这里找到了一些东西:https ://stackoverflow.com/a/32932933/1788961
global $woocommerce;
$shipping_methods = $woocommerce->shipping->load_shipping_methods();
if($shipping_methods['free_shipping']->enabled == "yes")
但这没有帮助。
我还在这里发现了一个有趣的片段:https ://www.businessbloomer.com/woocommerce-hide-shipping-options-free-shipping-available/
$all_free_rates = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$all_free_rates[ $rate_id ] = $rate;
break;
}
}
if ( empty( $all_free_rates )) {
return $rates;
} else {
return $all_free_rates;
}
}
拉丁的传说