• Resolved dav74

    (@dav74)


    Hello. Can you give me a snippet for removing Klarna from WC checkout for payments above a certain amount? It is rather crazy this is not part of your plugin. With Klarna, somone orders for 500€ then sends it all back. Klarna then charges us a big fee (a % of the order value) even though we made no money. We need to limit people using Klarna for larger orders.

    I had a snippet but it was causing huge server load and errors. I was using this which evidently no longer works:

    add_filter( 'woocommerce_available_payment_gateways', 'disable_klarna_above_250' );
     
    function disable_klarna_above_250( $available_gateways ) {
    $maximum = 250;
    if ( WC()->cart->total > $maximum ) {
    unset( $available_gateways['klarna_payments'] );
    }
    return $available_gateways;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Andreas – Krokedil

    (@boozebrorsan)

    Hi!

    In these cases we usually recommends to test a conditional payment method plugin such as https://woocommerce.com/products/conditional-payment-methods-for-woocommerce/ so you can control it that way.

    I will bring it up with our developers next week and check what possibilities there is.

    Thread Starter dav74

    (@dav74)

    Thank you but the last thing we want is to add more plugins. Most payment processing plugins that compete with Klarna offer this functionaility – to block paments (disable the payment processor) over or under a certain amount. In the case of Klara which does not refund their fees when a customer returns their goods, this is very important.

    Plugin Support Andreas – Krokedil

    (@boozebrorsan)

    Hi @dav74

    Do you have any example of plugins that has this feature so we can have a look at them?

    Thread Starter dav74

    (@dav74)

    Hi @boozebrorsan

    You can check out this plugin for example: Riverty payment gateway for Woocommerce

    Plugin Support Andreas – Krokedil

    (@boozebrorsan)

    @dav74 Thanks!

    I will have a look at it next week.

    Plugin Support Andreas – Krokedil

    (@boozebrorsan)

    Hi! @dav74

    Perhaps you can try this snippet and see how it works? Test it in on your staging site first so your live site is not affected if something happens.

    add_filter( 'woocommerce_available_payment_gateways', 'maybe_disable_kp' );
    function maybe_disable_kp( $available_gateways ) {
    	if ( ! is_checkout() ) {
    		return $available_gateways;
    	}
    
    	$max_amount = 250;
    	$cart_total = WC()->cart->total;
    	if ( $cart_total > $max_amount ) {
    		unset( $available_gateways['klarna_payments'] );
    	}
    
    	return $available_gateways;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Snippet for bloking Klarna for payment above x’ is closed to new replies.