【问题标题】:WooCommerce Tax Class on Variable Product PricesWooCommerce 关于可变产品价格的税收类别
【发布时间】:2016-02-02 12:17:10
【问题描述】:

您好,我正在使用此功能对 WooCommerce 产品应用税级并检查用户角色。

/* Apply a different tax rate based on the user role. */
function wc_diff_rate_for_user( $tax_class, $product ) {
    if ( is_user_logged_in() && current_user_can( 'business' ) ) {
        $tax_class = 'Zero Rate';
    }
    return $tax_class;
}
add_filter( 'woocommerce_product_tax_class', 'wc_diff_rate_for_user', 1, 2 );

该功能适用​​于简单产品,但可变产品税不会从产品价格中扣除税款。

关于可变产品的最低和最高价格仍然是含税价格。

寻找可以对可变产品最低和最高价格征税的函数。

提前致谢。

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    这是一个暂时的问题。它不包括税级,所以瞬态不知道税级发生了变化...您可以通过更改瞬态的价格哈希来修复它...将此代码添加到您的functions.php

    function woocommerce_variation_prices_hash($price_hash, $product, $display) {
        if ( $display ) 
            $price_hash[] = $product->get_tax_class();
        return $price_hash;
    }
    add_filter( 'woocommerce_get_variation_prices_hash', 'woocommerce_variation_prices_hash', 10, 3 );
    

    【讨论】:

    • 添加此代码后,刷新前端的可变产品...然后尝试将税类更改为其他内容,然后再次刷新可变产品页面...看看它是否改变..跨度>
    猜你喜欢
    • 2021-05-19
    • 2019-02-12
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 2020-10-29
    • 1970-01-01
    相关资源
    最近更新 更多