wordpress - 在 WooCommerce 中删除特定条件下的运费
问题描述
我需要在 WooCommerce 中删除特定条件下的运费。由于条件太具体,我无法使用任何插件。到目前为止,我有这段代码(简化版),它非常适合cart
页面,但我还无法弄清楚checkout
页面。
add_action('woocommerce_before_cart_table', 'discount_when_foo_is_bar');
function discount_when_foo_is_bar() {
if($foo==$bar){
$woocommerce->cart->total -= $woocommerce->cart->shipping_total;
$woocommerce->cart->shipping_total=0;
}
}
解决方案
推荐阅读
- java - 使用apk easy tool更改targetsdkversion后应用程序不断崩溃
- indexeddb - 如何读取“workbox-background-sync”提供的 indexDB 存储中的实际数据?
- python - 在 For 循环中跳过迭代并在 Python 中重复初始化
- typescript - 如何在不使用类型断言的情况下检查字符串是否包含在字符串文字类型中?
- html - Angular 10 编译错误“错误 NG8001:'mat-card-title' 不是已知元素:
- python-3.x - 电报机器人。使用重命名将文件保存在服务器上
- swift - 如何从 Swift 中特定工作日的日期范围中查找日期?
- python - python对象构造函数的问题
- autodesk-forge - Autodesk Forge“查看 BIM 360 和 Fusion 模型”示例
- javascript - webpack-dev-server 不热重载(webpack 5)