Different Checkout Page’s based on countries

Im trying to base my checkout page in WooCommerce to different payment methods on different countries.

If I sit in Norway and buy a product, I want the checkout page choose PayPal as payment method. And If I sit in Sweden and buy I product I want the checkout page choose Klarna/DIBS as payment method.

Read More

Is this impossible? I tried this code.

<?php if ( shortcode_exists( 'woocommerce_checkout' ) ) {
    <php echo do_shortcode('[woocommerce_checkout]'); ?>
} elseif ( shortcode_exists('woocommerce_klarna_checkout') ) {
    <?php echo do_shortcode('[woocommerce_klarna_checkout]'); ?>
} ?>

But dosen’t work. I have even tried to hide payment method with this.

function payment_gateway_disable_country( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() <> 'SE' ) {
    unset(  $available_gateways['paypal'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );

Related posts

Leave a Reply