Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

Wordpress override a Class Method

I want to override a Class Method in Wordpress.  Here is the class and Method
if( !class_exists( 'Woo_Os_Public' ) ) { // If class not exist
	class Woo_Os_Public {

public function add_hooks() {
			
			// checkout process
			add_action( 'woocommerce_checkout_process', array( $this, 'woo_os_checkout_field_process' ) );

}
}
}

Open in new window


I want to override add_hooks

Here is what I have:
if (!class_exists('Woo_Os_Public')) { // If class not exist

    class Wizard_class extends Woo_Os_Public {

        public function add_hooks() {
// add custom fields to checkout page
            add_action('woocommerce_checkout_after_customer_details', array($this, 'woo_os_checkout_fields'));
        }

    }

}
$wizard_public = Woo_Os_Public();
$wizard_public->wizard = new Wizard_class;

Open in new window


I receive an error: Fatal error: Class 'Woo_Os_Public' not found in wp-content/plugins/nda/nda-plugin.php on line 31
Line 31 is: class Wizard_class extends Woo_Os_Public {
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robert Granlund

ASKER

Thanks Steve.  I appreciate the insight and assistance.