php - 如何在 WooCommerce 中隐藏某个类别的运输区域?
问题描述
本质上,我试图隐藏某个类别的一些运输区域。任何帮助将不胜感激。
示例 - 有5个运输区,当披萨类别选择时,必须隐藏2个运输区域
也许有帮助-如果在某个类别上启用了免费送货,我使用此代码隐藏其他送货方式
add_filter( 'woocommerce_package_rates', 'bbloomer_unset_shipping_when_free_is_available_in_zone', 10, 2 );
function bbloomer_unset_shipping_when_free_is_available_in_zone( $rates, $package ) {
// Only unset rates if free_shipping is available
if ( isset( $rates['advanced_free_shipping'] ) ) {
unset( $rates['shipping_method_0_flat_rate2'] );
}
return $rates;
}
解决方案
推荐阅读
- r - tidymodels:具有交叉验证的游侠
- flutter - 获取布尔列表中第一个真值的索引
- java - 如何断言 AssertionError java?
- node.js - 使用无服务器部署 AWS Lambda 函数在需要外部模块时不会部署
- firebase - Flutter Firebase ListView - 缓慢刷新
- github - 如何检索一个人的所有固定 github 存储库的列表?
- c++ - nlohmann json 将一个数组插入另一个数组
- mysql - 如何选择包含非 ascii 字符的列名?
- c - 在c中运行多个命令
- scala - ApplicationLoader 内部是否存在隐式执行上下文