• Resolved dav74

    (@dav74)


    Hello,

    We have an issue with the snippets plugin. It is creating a very large server load with thousands of error messages (all the same). I already see another user has also spotted this. Screenshot: https://ibb.co/12FZZHY

    We need a fix ASAP. Thank you

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi @dav74,

    This is a bug in one of your snippets, not in the core plugin. It’s not something we can fix on our end.

    You should be able to narrow down which snippet it is by doing a search for total @line:5. Feel free to post the code here if you’d like help fixing the problem.

    Thread Starter dav74

    (@dav74)

    Hi @bungeshea

    many thanks for your reply! Ok that’s interesting. Apologies for jumping to conclusions. Can you tell me how I start narrowing down which snippet it is, if I have like 30 snippets? Are you saying that the snippet in question has “total @ line:5” in it?

    Thread Starter dav74

    (@dav74)

    Hi @bungeshea

    OK I have looked at all of the 23 published snippets we have but none of them contain total @line:5 I am not sure what exactly I am suppose to be looking for. Can you please advise here so I can find out which snippet is causing the issue?

    Plugin Author Shea Bunge

    (@bungeshea)

    @dav74 the snippet itself won’t contain total @line:5 – that’s just a search term you can put in the search box on the Snippets menu to narrow down the list.

    If you’re searching through manually, you should look for a snippet that contains the term total on line 5 of the code.

    Thread Starter dav74

    (@dav74)

    Ah! OK we’re learning with you help 🙂 That is perfect. I straight away narrowed it down to 2 snippets, and only one of them was published. Bingo.

    Plugin Author Shea Bunge

    (@bungeshea)

    Awesome, feel free to post the code here and I’ll do what I can to fix it up.

    Thread Starter dav74

    (@dav74)

    Well if you feel like looking that would be great. Snippet below.

    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;
    }

    Plugin Author Shea Bunge

    (@bungeshea)

    You should be able to fix this by adding an isset check:

    add_filter(
    	'woocommerce_available_payment_gateways',
    	function ( $available_gateways ) {
    		$maximum = 250;
    		if ( isset( WC()->cart->total ) && WC()->cart->total > $maximum ) {
    			unset( $available_gateways['klarna_payments'] );
    		}
    		return $available_gateways;
    	}
    );
    Thread Starter dav74

    (@dav74)

    Great will give that a go!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Code snippets error 582 – Creating big server load’ is closed to new replies.