• Resolved tristanmason

    (@tristanmason)


    We would like to use the Payfast gateway in a multicurrency setup with WPML. WPML support says their multi-currency mode should work with any gateway that works in WooCommerce. The problem is that our main store currency is USD, and when we try to enable the Payfast gateway plugin, we get the error message:
    Gateway Disabled Choose South African Rands as your store currency in General Settings to enable the PayFast Gateway.

    We need our main store currency to remain USD. Is it possible to bypass this check so we can enable the gateway? Is there a different way to get Payfast working with WPML?

    Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @tristanmason!

    There’s no way you can override that as far as I know. Your base currency will need to be set to ZAR

    Cheers!

    Thread Starter tristanmason

    (@tristanmason)

    @rynald0s Thanks, how would I go about submitting this as a feature request? We can’t be the only organization out there that wants to use Payfast with a multi-currency setup through WPML. At very least there should be a setting or a wp-config environment variable that would override this.

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @tristanmason!

    If you look at the code for Payfast, you’ll see that only ZAR is accepted as a currency (https://github.com/woocommerce/woocommerce-gateway-payfast/blob/master/includes/class-wc-gateway-payfast.php#L39).

    You could possibly use the woocommerce_gateway_payfast_available_currencies filter and add USD to the array — that will “bypass” the check, but I cannot guarantee that it wouldn’t cause some other issues down the line. If however, your multicurrency passes the value in ZAR, you should be fine. Please do double check with them

    Cheers!

    Thread Starter tristanmason

    (@tristanmason)

    @rynald0s Excellent, thanks! We will try this and also reach out to WPML multicurrency to double check with them.

    So if I understand correctly, would we add something like one of the following code snippets to our site-specific plugin?

    Example 1

    add_filter( 'woocommerce_gateway_payfast_available_currencies', 'tdz_payfast_currencies' );
    function tdz_payfast_currencies( $currencies )
    {
        $currencies = array( 'ZAR','USD' );
        return $currencies
    }

    Example 2
    add_filter( 'woocommerce_gateway_payfast_available_currencies', array( 'ZAR', 'USD' ) );

    If I’m misunderstanding, please let me know.

    Also, I’m assuming we would need unset payfast as a gateway unless the customer has selected ZAR as a currency.
    Is ‘payfast’ the correct identifier for the Payfast gateway in WooCommerce? As in

     // if currency is not ZAR
    unset( $gateways['payfast'] );

    Thanks again.

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @tristanmason!

    Yes, the code looks good ?? (first one)

    Would add that to your child themes’ functions.php file or via something like https://www.ads-software.com/plugins/code-snippets/

    Cheers!

    Thread Starter tristanmason

    (@tristanmason)

    @rynald0s Great, thanks so much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Payfast and WPML multicurrency’ is closed to new replies.