显示有关免运费所需金额的信息。喜欢:加 10 美元即可免运费一切正常,并且基于固定金额的免费送货。我现在的问题是,即使优惠券设置免费送货,它也会显示。有什么方法可以检查订单是否已经使用任何免费送货方式?我在这里找到了一些东西:https ://stackoverflow.com/a/32932933/1788961global $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;} }
1 回答
拉丁的传说
TA贡献1789条经验 获得超8个赞
我想我已经解决了:
// Loop though shipping packages
foreach ( WC()->shipping->get_packages() as $key => $package ) {
// Loop through Shipping rates
foreach($package['rates'] as $rate_id => $rate ){
$check_method_shipping = $rate->method_id;
}
}
之后你可以像这样使用它:
if ($check_method_shipping != 'free_shipping') :
- 1 回答
- 0 关注
- 85 浏览
添加回答
举报
0/150
提交
取消