/

How to allow BGN for WooCommerce and PayPal?

WRITTEN BY :
Aless Design Studio
POSTED ON :
06/10/2021
TAGS :

Table of Contents

In this post, we are going to see how to allow BGN for WooCommerce and PayPal. This technique is also usable for other unsupported currencies by PayPal. Great! 

Why do we have to allow BGN for WooCommerce and PayPal?

PayPal is an online payment system that makes paying for things online and sending and receiving money safe and secure. When you link your bank account, credit card, or debit card to your PayPal account, you can use PayPal to make purchases online with participating stores.

PayPal has almost 300 million customers, over 20 million active merchant accounts, and billions of transactions conducted every year.

Even though PayPal doesn’t support all currencies. And when you build your online store with an unsupported one, what do you do? Give up? No!

With one easy step, we will show you how to allow BGN for WooCoomerce and PayPal, but you can use the code for any other currency if it is available in WooCommerce. 

Allow BGN for WooCommerce and PayPal

How to solve this problem?

It may seem very difficult and annoying, but solving this issue is quite easy. You need to follow just one simple step and you will allow BGN for WooCommerce and PayPal and other curacies.

Step 1: Adding the code

Add the following code to your functions.php. Go to Appearance > Theme editor > functions.php > paste the following code:

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

//this runs when a new note is added to the order
add_filter( 'woocommerce_new_order_note_data', 'pbte_fix_order_status', 10, 2 );

//if the note says that the PayPal currencies or amounts do not match, then we will change the status to processing
function pbte_fix_order_status($a_note, $a_order)
{
    //the check is done in two languages
    if ( strpos($a_note['comment_content'],'PayPal валутите не съвпадат') !== false
    || strpos($a_note['comment_content'],'PayPal currencies do not match') !== false
    || strpos($a_note['comment_content'],'PayPal наличността не отговаря') !== false
    || strpos($a_note['comment_content'],'PayPal amounts do not match') !== false )
    {
        //we create the order var
        $order = new WC_Order($a_order['order_id']);
        //if the current status is on-hold - we change it to processing and add an optional note
        if($order->status == 'on-hold')
            $order->update_status('processing', 'The PayPal BGN support plugin did this note.');
    }

    return $a_note;
}

				
			

How to modify the code to allow another unsupported currency?

Actually, it’s pretty simple – change the all BGN with the abbreviation of the desired currency and you are good to go!

In this part of the code change the Bulgarian text with the shop language you are using and leave the English translation underneath. 

				
					    //the check is done in two languages
    if ( strpos($a_note['comment_content'],'PayPal валутите не съвпадат') !== false
    || strpos($a_note['comment_content'],'PayPal currencies do not match') !== false
    || strpos($a_note['comment_content'],'PayPal наличността не отговаря') !== false
    || strpos($a_note['comment_content'],'PayPal amounts do not match') !== false )
    {
       
				
			

As you can see with a few clicks you can let your customers pay for your shop products or services with another payment method. This is very important because all customers are different and prefer different ways to pay!

Good luck!

 913 total views,  1 views today

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on telegram
Share on whatsapp
Share on skype
Share on email

Leave a Reply

Your email address will not be published.

Related Posts.

WordPress 5.9
WordPress

WordPress 5.9 Big Update & Big Changes

WordPress 5.9 is the first major release of 2022, as it was launched on January 25, 2022. This recent version brings new features and enhancements that make full site customization even easier.

 781 total views,  2 views today

Read More »
WRITTEN BY :
Aless Design Studio
POSTED ON :
06/10/2021
TAGS :

Table of Contents

In this post, we are going to see how to allow BGN for WooCommerce and PayPal. This technique is also usable for other unsupported currencies by PayPal. Great! 

Why do we have to allow BGN for WooCommerce and PayPal?

PayPal is an online payment system that makes paying for things online and sending and receiving money safe and secure. When you link your bank account, credit card, or debit card to your PayPal account, you can use PayPal to make purchases online with participating stores.

PayPal has almost 300 million customers, over 20 million active merchant accounts, and billions of transactions conducted every year.

Even though PayPal doesn’t support all currencies. And when you build your online store with an unsupported one, what do you do? Give up? No!

With one easy step, we will show you how to allow BGN for WooCoomerce and PayPal, but you can use the code for any other currency if it is available in WooCommerce. 

Allow BGN for WooCommerce and PayPal

How to solve this problem?

It may seem very difficult and annoying, but solving this issue is quite easy. You need to follow just one simple step and you will allow BGN for WooCommerce and PayPal and other curacies.

Step 1: Adding the code

Add the following code to your functions.php. Go to Appearance > Theme editor > functions.php > paste the following code:

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

//this runs when a new note is added to the order
add_filter( 'woocommerce_new_order_note_data', 'pbte_fix_order_status', 10, 2 );

//if the note says that the PayPal currencies or amounts do not match, then we will change the status to processing
function pbte_fix_order_status($a_note, $a_order)
{
    //the check is done in two languages
    if ( strpos($a_note['comment_content'],'PayPal валутите не съвпадат') !== false
    || strpos($a_note['comment_content'],'PayPal currencies do not match') !== false
    || strpos($a_note['comment_content'],'PayPal наличността не отговаря') !== false
    || strpos($a_note['comment_content'],'PayPal amounts do not match') !== false )
    {
        //we create the order var
        $order = new WC_Order($a_order['order_id']);
        //if the current status is on-hold - we change it to processing and add an optional note
        if($order->status == 'on-hold')
            $order->update_status('processing', 'The PayPal BGN support plugin did this note.');
    }

    return $a_note;
}

				
			

How to modify the code to allow another unsupported currency?

Actually, it’s pretty simple – change the all BGN with the abbreviation of the desired currency and you are good to go!

In this part of the code change the Bulgarian text with the shop language you are using and leave the English translation underneath. 

				
					    //the check is done in two languages
    if ( strpos($a_note['comment_content'],'PayPal валутите не съвпадат') !== false
    || strpos($a_note['comment_content'],'PayPal currencies do not match') !== false
    || strpos($a_note['comment_content'],'PayPal наличността не отговаря') !== false
    || strpos($a_note['comment_content'],'PayPal amounts do not match') !== false )
    {
       
				
			

As you can see with a few clicks you can let your customers pay for your shop products or services with another payment method. This is very important because all customers are different and prefer different ways to pay!

Good luck!

 914 total views,  2 views today

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on telegram
Share on whatsapp
Share on skype
Share on email

Leave a Reply

Your email address will not be published.

Related Posts.

WordPress 5.9
WordPress

WordPress 5.9 Big Update & Big Changes

WordPress 5.9 is the first major release of 2022, as it was launched on January 25, 2022. This recent version brings new features and enhancements that make full site customization even easier.

 781 total views,  2 views today

Read More »