【问题标题】:Converts shipping costs in the Paypal plugin for Woocommerce在 Woocommerce 的 Paypal 插件中转换运费
【发布时间】:2018-02-26 09:44:16
【问题描述】:

我需要为 Woocommerce 中的 Paypal 插件将货币从 PEN 转换为 USD。

我下面的代码可以转换价格,但不能转换运费:

add_filter('woocommerce_paypal_args', 'convert_bgn_to_eur');
function convert_bgn_to_eur($paypal_args){
    if ( $paypal_args['currency_code'] == 'PEN'){
        $convert_rate = 3.3; //set the converting rate
        $paypal_args['currency_code'] = 'USD'; //change Pen to USD
        $i = 1;

        while (isset($paypal_args['amount_' . $i])) {
            $paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2);
            ++$i;
        }

    }
return $paypal_args;
}

如何换算产品的运费?

【问题讨论】:

    标签: wordpress paypal woocommerce e-commerce


    【解决方案1】:

    只需转到 WooCommerce 设置,然后在 货币选项 下,您就会看到更改货币的选项。

    【讨论】:

      【解决方案2】:

      谢谢!我找到了更多解决方案!税收和折扣

      add_filter('woocommerce_paypal_args', 'convert_bgn_to_eur');
      function convert_bgn_to_eur($paypal_args){
          if ( $paypal_args['currency_code'] == 'PEN'){
              $convert_rate = 3.200; //set the converting rate
              $paypal_args['currency_code'] = 'USD'; //change Pen to USD
              $i = 1;
      
              while (isset($paypal_args['amount_' . $i])) {
                  $paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2);
                  ++$i;
              }
      
                      if (isset($paypal_args['tax_cart'])) {
                  $paypal_args['tax_cart'] = round($paypal_args['tax_cart'] / $convert_rate, 2);
              }
      
              if (isset($paypal_args['shipping_1'])) {
                  $paypal_args['shipping_1'] = round($paypal_args['shipping_1'] / $convert_rate, 2);
              }
      
              if ( $paypal_args['discount_amount_cart'] > 0 ) {
      $paypal_args['discount_amount_cart'] = round( $paypal_args['discount_amount_cart'] / $convert_rate, 2);
      }
      
          }
      return $paypal_args;
      }
      

      【讨论】:

        猜你喜欢
        • 2020-03-21
        • 2016-11-26
        • 2021-07-23
        • 2021-09-24
        • 2021-06-20
        • 1970-01-01
        • 2017-02-01
        • 2022-08-09
        • 2022-11-16
        相关资源
        最近更新 更多