• Resolved roef2000

    (@roef2000)


    Hello, I got different Payment Gateways to different countrys, the country is set with GeoIP but is a few cases the customer must change that. What I need is a preselected default payment gateway based on country, because of this issue:

    Example:
    Country Netherlands has 2 payment options: Klarna Checkout(default) and PayPal
    Country Spain has 1 option: PayPal

    So if a customer checks out with Spain selected, PayPal will be preselected, this is correct,
    but when the customer changes the country to Netherlands, it will still have PayPal selected while showing Klarna Checkout as an option to select.
    But what I need is Klarna Checkout to be preselected once you choose Netherlands (since that’s a iframe payment window)
    Note, the checkout is reloading when changing shipping country, as I use Aelia Currency Switcher to set the correct currency aswell, so I got the country selector on top.

    I did try this snippet:

    add_action( 'template_redirect', 'define_default_payment_gateway' );
    function define_default_payment_gateway(){
        if( is_checkout() && ! is_wc_endpoint_url() ) {
      
            $default_payment_id = 'kco';
    
            WC()->session->set( 'chosen_payment_method', $default_payment_id );
        }
    }

    This only work halfway, it sets the Klarna Checkout as default if present, but when trying to select PayPal then it reloads the page setting Klarna Checkout as default again.

    Any input and help would be great. Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey there, @roef2000! Thanks for contacting us.

    While we can’t provide support for code customization as per our support policy, we do our best to offer advice and direct you to appropriate resources.

    You can visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there too.

    I’m going to leave it open for a bit to see if anyone is able to chime in and help you out further.

    Please let us know if there’s anything else we can do to help or if you have any questions.

    Have a wonderful day!

    Thread Starter roef2000

    (@roef2000)

    Ok understand, thanks anyway. I think the problem is that the whole checkout is reloading when you choose to leave Klarna Checkout for another payment method. So guessing this is a job for jQuery

    Hey @roef2000 ??

    Just to add, while reading your messages in this thread, it sounds like the current customer journey needs to be rethought for the store — from discovering a product, until payment for an order.

    From what I gather, while geography-related, currency, and payment option, signals are there, the system “breaks” when a different option is selected from a customer.

    In the spirit of continuous improvement, feel free to consider the following questions, internally, with the store’s team:

    • Spain and the Netherlands have the same currency (euro). Why a currency switcher is needed?
    • Two payment options are available for the Netherlands, and one for Spain. How many times a customer required to change country, to a different from the one geolocation selected for them, before checking out?
    • From the times the country changed by customer input, how much easier (or more difficult, or costly) did customer checkout became, based on the default payment option selected for that country?
    • When switching to a different country, do we offer different selection among products and services, apart from payment and currency options? How about implementing different stores per geographic location? There are plugins, like this one, that make it possible.
    • With each plugin that is added, starting with only core WooCommerce, did we make absolutely sure it does not break needed functionality already in place at the store?

    I hope this helps!

    Thread Starter roef2000

    (@roef2000)

    Hi, thanks for the feedback. We sell to 20+ countries with 8 different currencies, that Spain/Netherlands was just a example ??
    GeoIP works for about 95% of the cases, showing correct currency and tax for the specific country,
    the fix I’m looking at is to make the remaining 5% to have a better checkout experience, as some local payment method is crucial for a specific country, I would like that to be the default one that selects for that country.
    An example that happend more than once: Customer from Norway are on vaccation in Italy and wants to make a purchase, in the checkout Italy is preselected and has let’s say Stripe as default payment, so customer changes shipping country to Norway, that’s the first step in the checkout so no problem at all. But now Stripe is still the selected payment, even though both Klarna or Vipps payment methods are now visible and above Stripe in the payment method list.
    Not a really big deal but still something that’s not a complete good user experience, and yes it looks like all goes down to that some payment methods uses iframe that hides part of the checkout and reloades the pages to hide it, so the snippet trick above won’t work.
    Anyway, think I can get to work as I want with jQuery

    Hey, @roef2000!

    Thanks for the explanation ??

    I hope you are able to solve this soon. Please feel free to reach out to our community devs on Slack or Facebook, as they might be able to help.

    I’ll close this thread now, okay? Please let us know if there’s anything else we can do to help or if you have any questions.

    Have a wonderful day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.