Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Odd; this code returns data, it does not load gateways or change anything.

    Where are you calling this? How early?

    Thread Starter mpbm23

    (@mpbm23)

    I have reduced it to to files with minimal code and the results are the same.

    class Pay4Pay {
    	private static $_instance = null;
    	public static function instance(){
    		if ( is_null(self::$_instance) )
    			self::$_instance = new self();
    		return self::$_instance;
    	}
    
    	private function __construct() {
    	}
    }
    Pay4Pay::instance();
    if ( is_admin() )
    	require_once plugin_dir_path(__FILE__) . '/admin/class-pay4pay-admin.php';

    Admin file

    if ( ! class_exists( 'Pay4Pay_Admin' ) ) :
    
    class Pay4Pay_Admin {
    
    	private static $_instance = null;
    
    	public static function instance(){
    		if ( is_null(self::$_instance) )
    			self::$_instance = new self();
    		return self::$_instance;
    	}
    
    	private function __construct() {
    		// handle options
    		add_action( 'woocommerce_init' , array( &$this , 'add_payment_options'), 99 );
    		add_action( 'woocommerce_update_options_checkout' , array( &$this , 'add_payment_options') );
    
    	}
    
    	function add_payment_options( ) {
    	var_dump(WC()->payment_gateways()->payment_gateways() );
    	}
    
    }
    
    Pay4Pay_Admin::instance();
    
    endif;

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    That may be too early, before gateways have hooked themselves in. Does it work on a later hook, such as ‘wp’?

    Thread Starter mpbm23

    (@mpbm23)

    I believe wp_loaded instead of woocommerce_init did the trick.
    Thanks for the help

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Calling $payment_gateways = WC()->payment_gateways->payment_gateways(); problem’ is closed to new replies.