Want to overwrite functions written in woocommerce-functions.php file

I want to modify/overwrite functions written in woocommerce-functions.php file but I don't want to modify woocommerce-functions.php file. That is I want to achieve this in plug-in or in my theme.

Answers


It is possible to override woocommerce functions, I did this recently and added all of my woocommerce extended functionality to my theme's functions.php file so that the woocommerce plugin files remained untouched and are safe to update.

This page gives an example of how you can remove their action and replace it with your own - http://wordpress.org/support/topic/overriding-woocommerce_process_registration-in-child-theme-functionsphp

This page gives an example of extending upon their functions without removing their function, as well as using child themes - http://uploadwp.com/customizing-the-woocommerce-checkout-page/

Hope this helps :)


If you have a child theme, you can copy the relevant file to your theme and rewrite the copy. The copy will be used in preference to the WooCommerce version.


WooCommerce provides a templating system. It is possible to override woocommerce functions. great way to customize WooCommerce without modifying core files, is to use hooks -

If you use a hook to add or manipulate code, you can add your custom code to your theme functions.php file.

  • Using action hooks -

To execute your own code, you hook in by using the action hook do_action(‘action_name’);.

See below for a great example on where to place your code:

add_action('action_name', 'your_function_name');

function your_function_name() 
{
// Your code
}
  • Using filter hooks-

Filter hooks are called throughout are code using apply_filter(‘filter_name’, $variable);

To manipulate the passed variable, you can do something like the following:

add_filter('filter_name', 'your_function_name');

function your_function_name( $variable )
 {
// Your code
return $variable;
}

Here you can get WooCommerce Action and Filter Hook - https://docs.woothemes.com/wc-apidocs/hook-docs.html


Need Your Help

Redshift data storage schema

database amazon-web-services amazon-redshift

AWS Redshift is named columnar MPP database.

How to get the total row count for GWT CellTable pagination in

java gwt pagination gwt-celltable

I'm trying to implement paging in a CellTable but it's currently showing "1-10 of 10" records instead of "1-10 of 1000" records. I'm not sure where I can update the total record count. My