php - Wordpress Woocommerce - 小计和总计不匹配
问题描述
我尝试使用此代码根据购物车总计获取不同的税种,但它没有在“总计”列上更新。
add_filter( 'woocommerce_product_get_tax_class', 'big_apple_get_tax_class', 1, 2 );
function big_apple_get_tax_class( $tax_class, $product ) {
if ( WC()->cart->subtotal < 1000 )
$tax_class = 'Tax-5%';
elseif ( WC()->cart->subtotal >= 1000 )
$tax_class = 'Tax-12%';
return $tax_class;
解决方案
为什么会匹配?
额外的运费INR 100
已添加到购物车中。如果您不打算在您的购物车中发货,请阅读此文档以将您的发货设置为免费。
然后会做。
物品 | 价格 |
---|---|
小计 | 1575 卢比 |
船运 | INR 0(现在是 0) |
全部的 | 1575 卢比 |
代替
物品 | 价格 |
---|---|
小计 | 1575 卢比 |
船运 | 100 卢比(通过免费送货移除此商品) |
全部的 | 1675 卢比 |
推荐阅读
- python - 使用 Docker 在 Google App Engine Flex 上部署 Flask 应用程序
- sql-server - 从字符串转换日期和/或时间转换失败
- python - Python中的部分数据需要更改24:00到23:00的时间
- jenkins-pipeline - 在声明性 Jenkinsfile 中首先运行脚本以使用扩展选择参数插件
- sql - 使用来自不同表的 where 字段更新表
- powershell - 如何使用“Shift + Right Click”以其他用户身份启动 *.ps1 文件?
- html - 如果我没有看到客户出现的错误,如何对 html 电子邮件模板进行故障排除?
- javascript - Express - 无法连接到 MongoDB 服务器
- java - Spring Boot @ControllerAdvice + @Transactional 无法按预期工作
- tensorflow - 如何在 Windows 10 上安装 CUDA 分析工具界面