例如:我有3个运输区域,A区,B区,C区和3个类别,A类,B类,C类
我只想为A区运送A类,必须不能为B区和C区运送A类。
Add_filter('woocommerce_package_rates','specific_products_shipping_methods',10,2);功能特定产品运送方法($费率,$包裹){
$product_ids = array( 11909, 11907 ); // HERE set the product IDs in the array
$method_id = 'wbs:14:0dd3bc79_weight_based_shipping'; // HERE set the shipping method ID
$found = false;
// Loop through cart items Checking for defined product IDs
foreach( $package['contents'] as $cart_item ) {
if ( in_array( $cart_item['product_id'], $product_ids ) ){
$found = true;
break;
}
}
if ( $found )
unset( $rates[$method_id] );
return $rates;
}
我尝试了这个代码
1条答案
按热度按时间bvhaajcl1#
使用
woocommerce_package_rates
过滤器检查发货区域和产品类别,以删除相应的发货方式