Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // allow BGN for WooCommerce and PayPal
- add_filter( 'woocommerce_paypal_supported_currencies', 'add_bgn_paypal_valid_currency' );
- function add_bgn_paypal_valid_currency( $currencies ) {
- array_push ( $currencies , 'BGN' );
- return $currencies;
- }
- // Convert BGN to EUR for PayPal payments
- add_filter('woocommerce_paypal_args', 'convert_bgn_to_eur');
- function convert_bgn_to_eur($paypal_args){
- if ( $paypal_args['currency_code'] == 'BGN'){
- $convert_rate = 1.955; //set the converting rate
- $paypal_args['currency_code'] = 'EUR'; //change BGN to EUR
- $i = 1;
- while (isset($paypal_args['amount_' . $i])) {
- $paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2);
- ++$i;
- }
- if ( $paypal_args['shipping_1'] > 0 ) {
- $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;
- }
Add Comment
Please, Sign In to add comment