【发布时间】:2020-01-30 20:44:12
【问题描述】:
在我的 woocommerce 购物车中,运费仍由以下代码正确计算。但是现在没有更新运输标签。我找不到原因;可能是最近的 woocommerce 3.7 更新?感谢您的帮助!
/**
* Add different price for shipping based on products quantity
*/
function mx_shop_shipping_price( $rates, $package ) {
//Shipping Mode 1
if ( WC()->cart->cart_contents_count < 4 ) {
return array_filter($rates, function (WC_Shipping_Rate $rate) {
return $rate->get_label() === 'Shipping Mode 1'; // Shipping Mode 1
});
}
//Shipping Mode 2
if ( WC()->cart->cart_contents_count < 13 ) {
return array_filter($rates, function (WC_Shipping_Rate $rate) {
return $rate->get_label() === 'Shipping Mode 2';
});
}
//Shipping Mode 3
return array_filter($rates, function (WC_Shipping_Rate $rate) {
return $rate->get_label() === 'Shipping Mode 3';
});
}
add_filter( 'woocommerce_package_rates', 'mx_shop_shipping_price', 10, 2 );
/** End
Cart detail with Shipping label not updated. Note Order Total is correctly updated
【问题讨论】:
-
请对答案提供一些反馈。
标签: php wordpress woocommerce cart shipping-method