2017-09-17 2 views
-1

Woocommerce에서 Paypal 플러그인의 통화를 PEN에서 USD로 변환해야합니다. 아래Woocommerce 용 Paypal 플러그인의 배송비를 변환합니다.

내 코드는 가격을 변환 작동하지만 운송 비용하지 :

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; 
} 

어떻게 또한 제품의 배송 비용을 변환합니까?

답변

1

고마워요! 나는 더 많은 해결책을 찾는다! 세금 및 할인

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; 
} 
0

단순히 WooCommerce 설정로 이동하고 통화를 변경할 수있는 옵션이 표시됩니다통화 옵션에서.

WooCommerce Currency Options

관련 문제