• Exactly one week ago, past Monday, we made a few updates to our website’s plugins. Since then a lot of problems have occured in different aspects of our website’s functionality and after a lot of testing this past week we concluded that most(if not all) of the problems originate by two specific snippets and even isolated the specific parts of the code responsible for the issues from those two. So, we noticed that in both cases we have filters that hook into ‘woocommerce_available_payment_gateways’.

    Some of the issues created are(the most important):
    – Unable to make any changes to existing snippets. We get the message “Could not update snippet. Request failed with status code 500”.
    -Cannot open Elementor Editor in any of my pages. It gets stuck on loading. and a message to activate safe mode appears.

    All of the issues mentioned above get resolved when we deactivate these two snippets. The specific parts that I mentioned already to be exact.
    Eveything was working fine beforehand and did not have any of these issues.

    I wasn’t sure if this was the right place to post my problem but I do not know why it could be happening and any help would be greatly appreciated! If you would like to see the code let me know.

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

    (@bungeshea)

    Very curious! I really appreciate you reporting this and the steps necessary to reproduce it. I’ll see whether I can do so, and work out a fix for this issue. It’s been frustrating having some users be receiving the 500 errors but not knowing how to track down the cause.

    Thread Starter peros

    (@peros)

    I hope you can work out a solution, thank you!

    Plugin Author Shea Bunge

    (@bungeshea)

    Would it be possible to share those two snippets causing issues?

    Hi, we were collaborating with peros, but unfortunately he had to leave the project ! Here are the parts of snippets that dont work together.

    add_filter( 'woocommerce_available_payment_gateways','disable39A');
    function disable39A( $available_gateways ) {
    	global $woocommerce;
    	 if ( ! is_admin() ) {
    	if(bbloomer_check_category_in_cart())
    	{
    		unset(  $available_gateways['pay_later'] );
    	}
    	 }
    		
    	return $available_gateways;
    }
    
    add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_gateway_disable_shipping_326' );
      function bbloomer_gateway_disable_shipping_326( $available_gateways ) {
         
       if ( ! is_admin() && WC()->session ) {
            
          $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
            
          $chosen_shipping = $chosen_methods[0];
          
          if ( isset( $available_gateways['pay_later']) && 0 === strpos( $chosen_shipping, 'flat_rate:5'  )){
             unset( $available_gateways['pay_later'] );
    		   unset( $available_gateways['bacs'] );
    		   unset( $available_gateways['eurobank_gateway'] );
    		    unset( $available_gateways['bank_transfer_1'] );
    		    unset( $available_gateways['bank_transfer_2'] );
    		    unset( $available_gateways['bank_transfer_3'] );
    		    unset( $available_gateways['bank_transfer_4'] );
          }
    	    if ( isset( $available_gateways['pay_later']) && 0 === strpos( $chosen_shipping, 'flat_rate:9'  )){
             unset( $available_gateways['pay_later'] );
    		   unset( $available_gateways['bacs'] );
    		   unset( $available_gateways['eurobank_gateway'] );
    			 unset( $available_gateways['bank_transfer_1'] );
    		    unset( $available_gateways['bank_transfer_2'] );
    		    unset( $available_gateways['bank_transfer_3'] );
    		    unset( $available_gateways['bank_transfer_4'] );
          }
    	    if ( isset( $available_gateways['pay_later']) && 0 === strpos( $chosen_shipping, 'flat_rate:14'  )){
             unset( $available_gateways['pay_later'] );
    		   unset( $available_gateways['bacs'] );
    		   unset( $available_gateways['eurobank_gateway'] );
    			 unset( $available_gateways['bank_transfer_1'] );
    		    unset( $available_gateways['bank_transfer_2'] );
    		    unset( $available_gateways['bank_transfer_3'] );
    		    unset( $available_gateways['bank_transfer_4'] );
          }
    	  
    	    if ($chosen_shipping == 'flat_rate:10'){
    			if (is_checkout() && ! is_wc_endpoint_url()){
    	       unset( $available_gateways['pay_later'] );
    		   unset( $available_gateways['bacs'] );
    		   unset( $available_gateways['eurobank_gateway'] );
    				 unset( $available_gateways['bank_transfer_1'] );
    		    unset( $available_gateways['bank_transfer_2'] );
    		    unset( $available_gateways['bank_transfer_3'] );
    		    unset( $available_gateways['bank_transfer_4'] );
    		   }
    			else {
    			 unset( $available_gateways['other_payment'] );
    			}
    		}
    	   else {
    		    unset( $available_gateways['other_payment'] );
    	   }
    	   
       }
         
       return $available_gateways;
         
    }
    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @peros, just wanted to reach out and check whether our v3.4.1 patch fixed this issue for you?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problematic Snippets’ is closed to new replies.