• Hi,

    I have a code snippet provided by a plugin support to impeach their commission system to create commissions over Sub-orders in Woocommerce.

    Here is the code

    if ( class_exists( 'YITH_Stripe_Connect' ) ) {
     if ( ! function_exists( 'yith_wcsc_process_order_commissions_custom' ) ) {
     function yith_wcsc_process_order_commissions_custom( $value, $order_id
     ) {
     $is_suborder  = wp_get_post_parent_id( absint( $order_id ) );
     if ( $is_suborder ) {
     $value = false;
     }
     return $value;
    
     }
    
          add_filter( 'yith_wcsc_process_order_commissions', 'yith_wcsc_process_order_commissions_custom', 10, 2 );
     }
    }

    It works fine if I set it in functions.php but does not run in the snippet plugin. I guess this is because the snippet runs before the theme loading or something. Any clue?

    Thanks a lot for your help and your time.

    • This topic was modified 5 years, 6 months ago by Imagewilliam333.
Viewing 2 replies - 1 through 2 (of 2 total)
  • @william333,

    Did you try your snippet with a Priority of 0 or 1?

    Did you try your snippet running in the back-end, front-end, and everywhere?

    Cheers!

    Plugin Author ImageShea Bunge

    (@bungeshea)

    Hi @william333,

    Rewriting the code like this should reduce any incompatibilities to do with load order or name collisions:

    add_filter( 'yith_wcsc_process_order_commissions', function ( $value, $order_id ) {
    	$is_suborder = wp_get_post_parent_id( absint( $order_id ) );
    	if ( $is_suborder ) {
    		$value = false;
    	}
    	return $value;
    
    }, 10, 2 );
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Snippet runs in functions.php but not in the Snippet plugin’ is closed to new replies.