【问题标题】:Get woocommerce tax percentage by address programmatically以编程方式通过地址获取 woocommerce 税收百分比
【发布时间】:2020-01-31 04:35:18
【问题描述】:

我正在为 woocommerce 商店构建 Android 应用程序。

该网站为不同的送货区域定义了税率。
以下是 woocommerce 税收部分中定义的一些采样率:

我需要显示为客户购物车中的送货区域计算的税款。

因此,如果客户输入送货地址,我将对同一服务器中的 API 后端进行 ajax 调用,获取税率(6%、7% 或 7.5%,具体取决于位置),并更新购物车数据显示在应用程序中。

我已经搜索了论坛,但没有得到关于如何获取给定区域的税率的答案。

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    兄弟你可以试试这个。 条件内的逻辑方法你可以做你自己的代码和逻辑的

    /* Remove tax from cart for FOB orders */
    function change_tax_for_fob( $cart ) {
        $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
        $chosen_shipping = $chosen_methods[0]; 
        if($chosen_shipping =='FOB') {
            // Do your Code
            //$cart->remove_taxes();
        }
        return $cart;
    }
    add_action( 'woocommerce_calculate_totals', 'change_tax_for_fob' );
    

    add_action( 'woocommerce_review_order_before_submit','custom_review_order_before_submit');
    function custom_review_order_before_submit() {
        $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
        $chosen_shipping = $chosen_methods[0];
        if( "FOB" == $chosen_shipping ) {
            <!-- Do Your Code -->
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      • 2019-06-20
      • 2021-05-03
      • 1970-01-01
      相关资源
      最近更新 更多