【问题标题】:WooCommerce output product tax rate (WC 3.0+)WooCommerce 产出品税率(WC 3.0+)
【发布时间】:2023-03-20 00:07:01
【问题描述】:

我需要在单个产品页面上输出一个产品的产品税率(以百分比为单位)。 我已经尝试了几个代码 sn-ps,但到目前为止,我只得到了税类名称或文本值“数组”。

有人知道如何获得这个值吗? 我的商店销售食品(6% 增值税)和非食品(21% 增值税)产品。 所有价格均显示不包括。增值税,但税级和税率已正确设置并适用于所有产品。

当客户查看产品页面时,我必须(根据法律)向他们展示该产品适用的增值税。

到目前为止,我有以下 sn-p。 这将“数组”显示为输出。

// For WooCommerce Version 3.0+ (only)
add_action( 'woocommerce_before_add_to_cart_form', 'exbtw_melding', 20 );

function exbtw_melding(){
    global $product;
    $tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
    echo 'Alle vermelde prijzen zijn excl. <b>'. $tax_rates . ' BTW</b> / 
    Tous les prix indiqués sont hors <b> '. $tax_rates . ' TVA</b>';
}

有什么帮助吗?

谢谢!

法比奥

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    这是我用过的:

    function woocommerce_template_display_tax() {
        global $product;
        $tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
        if (!empty($tax_rates)) {
            $tax_rate = reset($tax_rates);
            echo sprintf(_x('Inclusive %.2f %% tax', 'Text for tax rate. %.2f = tax rate', 'wptheme.foundation'), $tax_rate['rate']);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 2019-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-12
      相关资源
      最近更新 更多