首页 > 解决方案 > 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;

显示问题的图像

标签: phpwordpresswoocommercehook

解决方案


为什么会匹配?

额外的运费INR 100已添加到购物车中。如果您不打算在您的购物车中发货,请阅读此文档以将您的发货设置为免费。

然后会做。

物品 价格
小计 1575 卢比
船运 INR 0(现在是 0
全部的 1575 卢比

代替

物品 价格
小计 1575 卢比
船运 100 卢比(通过免费送货移除此商品
全部的 1675 卢比

推荐阅读