WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin WooCommerce] Paypal Fees (9 posts)

  1. stooky_1964
    Member
    Posted 1 year ago #

    hello community

    I am using the proffet theme from TF with woocomerce.

    does anybody know if there is a way to add additional payment costs when the customers chooses paypal?

    bare with my english, but ya kbow what I mean?!

    in shops you sometimes see "+ 3%" or a fixed amount when choosing paypal, to assure that the paypal fee goes to customers and not to shop.

    rgds,
    stooky

  2. Keichide
    Member
    Posted 1 year ago #

    I made a VERY dirty hack to the class-wc-gateway-paypal.php in woocommerce/classes/gateways/paypal

    and it just works if you don't use Taxes

    Add to line 228 right after global $woocommerce;:

    $paypalfee = 1;
    $subtotal = number_format($order->get_total() + $order->get_shipping(), 2, '.', '' );
    $order_id = $order->id;
    $fee_percent = '1.9'; // Paypal's percentage rate per transaction (3.4% in UK)
    $fee_cash = '0.40'; // Paypal's set cash amount per transaction (£0.20 in UK)

    // Calculate Fees
    $paypal_fee = ((($sub_total / 100) * $fee_percent) + $fee_cash);

    And replace Fees on line 378 with this:

    // Fees
    if ( $paypalfee == 1 ) {
    $item_loop++;
    $paypal_args[ 'item_name_' . $item_loop ] = __( 'Paypal Gebuehren' );
    $paypal_args[ 'quantity_' . $item_loop ] = '1';
    $paypal_args[ 'amount_' . $item_loop ] = $paypal_fee;

    }

    Like i said.. It's totally garbish but it works pretty well for me, and does what i want. AND it dosen't cost you 25$ which i thing is just scam, because THIS i a function that should't need a damn Plugin -__-

  3. spybubblegum
    Member
    Posted 1 year ago #

    Thanks for the above code! Worked like charm! :)

  4. Licorne
    Member
    Posted 1 year ago #

    Thank you. I was looking for something like this! ^_^

    But it doesn't seem to work for me. The only thing that carries over to the paypal website is the 0.40 amount. The percentage doesn't seem to carry over. I copied and ran this code as is.

    Any idea why the subtotal doesn't work? I'm using the latest version of the paypal gateway: @version 2.0.0

  5. ali malik
    Member
    Posted 11 months ago #

    Hi Keichide i apply this code and it is working for me, but can i do it for specific category??

  6. colibry
    Member
    Posted 10 months ago #

    I have working my paypal gateway but when i use discount cupouns i have problems with currency, on paypal website a have the discount in USD or EUR. But i whant to have that results converted from my currency to USD or EUR , if not i go to give free products:D

    On my currency the discount converted is 3 EUR and on paypal is 8 EUR(the value of my currency RON on the site is 8)
    Sorry for my english i hope someone understand my problem and can give me a solution. Thanks

  7. Cheesemaker
    Member
    Posted 9 months ago #

    Hi Licorn,

    I have the same problem as you.
    Did you manage to solve it?

    Kind Regards
    Cheesemaker

  8. colibry
    Member
    Posted 9 months ago #

    Yes i have pay for a code to solve this problem but now i can give out free is my code:D Try to adapt for your currency

    <?php
    /** Convert and exchange by www.colibry.ro and Aurel Canciu **/
    
    add_filter( 'woocommerce_paypal_supported_currencies', 'add_ron_paypal_valid_currency' );
    function add_ron_paypal_valid_currency( $currencies ) {
    	array_push ( $currencies , 'RON' );
    	return $currencies;
    }
    
    add_filter('woocommerce_paypal_args', 'convert_ron_to_eur');
    function convert_ron_to_eur($paypal_args){
    	if ( $paypal_args['currency_code'] == 'RON'){
    		$response = wp_remote_get('http://openapi.ro/api/exchange/eur.json');
    		$json = wp_remote_retrieve_body($response);
    		$exchange = json_decode($json);
    		$convert_rate = $exchange->rate;
    		$paypal_args['currency_code'] = 'EUR'; //change RON to EUR
    		$i = 1;
    		while (isset($paypal_args['amount_' . $i])) {
    			$paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2);
    			++$i;
    		}
    
    		$discount = $paypal_args['discount_amount_cart'];
    		$paypal_args['discount_amount_cart'] = round($discount / $convert_rate, 2);
    	}
    	return $paypal_args;
    }
  9. tobalsan
    Member
    Posted 9 months ago #

    Check out this nice plugin.

    Apparently it hasn't been added to WordPress plugins repository yet. I tried it out, just does what it says, but does it perfectly.

Topic Closed

This topic has been closed to new replies.

About this Topic