Support » Plugin: WooCommerce » Warning: call_user_func_array() expects parameter 1 to be a valid callback

  • Resolved Tanmoy Biswas

    (@biswas87)


    HI,
    Someone, please suggest to me, how can I fix the following issue.

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Woocommerce_Simple_Features’ does not have a method ‘ci_add_to_cart_bottom_text’ in C:\xampp\htdocs\theme\wp-includes\class-wp-hook.php on line 287.

    I have created only 2 files, here both file codes.
    main file codes here:

    if ( in_array('woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option('active_plugins')))) {
    	if ( ! class_exists( 'Woocommerce_Simple_Features') ) {
    		final class Woocommerce_Simple_Features {
    			
    			public function __construct () {
    				$this->register_hooks();
                                    
    				require ( CI_PATH .'/includes/class-wc-custom-fields.php');
    	
    			}
    
    			public function register_hooks () {
    			   add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'ci_add_to_cart_bottom_text') );
    
    		   }
    		
    		}
    	 }
    
    	$init = new Woocommerce_Simple_Features ();
    
    }

    And here my other file code:

    if ( ! class_exists( 'Woocommerce_Cart_Text' )) {
    	class Woocommerce_Cart_Text {
    		public function ci_add_to_cart_bottom_text () {
    			echo 'Here goes cart bottom text';
    		}
    	}
    }

    Please, someone, suggest to me. how can I fix it
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • ‘ci_add_to_cart_bottom_text’ is a method within the ‘Woocommerce_Cart_Text’ class, but ‘$this’ says it should be in the ‘Woocommerce_Simple_Features’ class, hence the error message.

    The fix would be to move the function ‘ci_add_to_cart_bottom_text’ to inside the ‘Woocommerce_Simple_Features’ class.

    That should fix this error but I can’t say whether the code will then do what you want.

    Thread Starter Tanmoy Biswas

    (@biswas87)

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Warning: call_user_func_array() expects parameter 1 to be a valid callback’ is closed to new replies.