Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to remove classes from a plugin and add theme into to theme?

I need to modify Woocommerce WP_Checkout class but I want to move it to my theme folder so if woocommerce will be updated my changes will not be effected. Is theme some way to make an remove and add action/hook? Or maybe unhook page and add my custom page with the class?

Thanks in advance Patrick

share|improve this question
    
You cannot actually remove a class but you can override it. I think this tutorial may get you up and running. –  Yogi Yang 007 Mar 23 '13 at 5:31
    
There are a ton of hooks/filters depending on what specfically you are trying to change in the WC_Checkout class. You could also try extending the class. –  helgatheviking Mar 23 '13 at 8:20
add comment

1 Answer

The class WC_Checkout is assigned to a member of the class Woocommerce. So maybe something like this could work:

add_action( "plugins_loaded", "wpse_91273_custom_checkout", 999 );

function wpse_91273_custom_checkout()
{
    $GLOBALS['woocommerce']->checkout = new Custom_Checkout;
}
share|improve this answer
    
That didn't work. I tried to put above code in functions.php also included my new class and included exit; in new function. But the process still works. How can I see if it's replaced? –  beitconsulting Mar 18 '13 at 8:14
    
Add die( __CLASS__ ); to one of the called methods. –  toscho Mar 18 '13 at 9:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.