Viewing 7 replies - 1 through 7 (of 7 total)
  • Limiting by currency would require custom coding solution, since it is not part of WooCommerce Multilingual.
    If you wish you can give a try to WooCommerce Gateways Country Limiter – our plugin that can limit the gateway by country – https://wpml.org/documentation/related-projects/woocommerce-gateways-country-limiter/ – You can assign the USD currency only to specific language and limit by the countries that you expect to use USD and that language.

    In order to limit by currency – it depends on your gateway how to do it, but you will need some code to do it.
    You can take for example the code for the PayPal gateway that is included in WooCommerce and the function: is_valid_for_use()
    https://github.com/woothemes/woocommerce/blob/master/includes/gateways/paypal/class-wc-gateway-paypal.php#L192

    Thread Starter subhada

    (@subhada)

    Thanks for your reply George.

    I have already used WooCommerce Gateways Country Limiter.But it is changing currency based on billing address.

    I will try to use the second solution.

    Is there any way to get total price currency on checkout page? So that based on that I can disable/enable payment gateway.

    I think that you can try and use get_client_currency() function to accomplish that.

    I’m using this solution (in functions.php file):

    add_filter( 'woocommerce_available_payment_gateways', 'hide_dotpay' );
     function hide_dotpay( $gateways ) {
     		global $woocommerce_wpml;
    
     		$get_current_currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
    
     		if( $get_current_currency == 'EUR' or $get_current_currency == 'USD')
    
     				unset( $gateways['your-gateway-1'] );
    
     		elseif ($get_current_currency == 'PLN') {
     			unset( $gateways['your-gateway-2'] );
     		}
    
     		return $gateways;
     }

    Thank you for sharing your code!

    The awesome snippet provided above doesn’t work in newer versions of WC + WCML. It throws a bunch of errors. I found the solution on the WPML forums (actually karolwaszak also provided the solution, so just relaying it here just in case)

    You must change this line:

    $get_current_currency = $woocommerce_wpml->multi_currency_support->get_client_currency();

    to this

    $get_current_currency = $woocommerce_wpml->multi_currency->get_client_currency();

    Plugin Contributor Andreas Panag

    (@andrewp-2)

    Thank you very much for sharing this!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Woocommerce gateways based on currency’ is closed to new replies.