Title: function override
Last modified: August 21, 2016

---

# function override

 *  [easyp](https://wordpress.org/support/users/easyp/)
 * (@easyp)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/function-override/)
 * I’d like to override a function in woocommerce, specifically –
    woocommerce/includes/
   wc-cart-functions.php (the wc_cart_totals_order_total_html function).
 * I could edit the function directly (it outputs html that needs to be changed),
   but I’d prefer not to as I’ll lose changes on updates.
 * I’m sure it’s a common thing, I’m just not quite sure how to go about doing that.
   If I copy the function to functions.php in my theme, I get an error about re-
   declaring the function.
 * thanks.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [gaissa](https://wordpress.org/support/users/khat/)
 * (@khat)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/function-override/#post-5155510)
 * Maybe you could try to wrap your overriding function with the function_exists().
 * Something like this: [link](http://wordpress.org/support/topic/how-to-override-a-function?replies=17)
 *  Thread Starter [easyp](https://wordpress.org/support/users/easyp/)
 * (@easyp)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/function-override/#post-5155609)
 * Thanks. I tried that, but it just ignores it… I guess because it already exists,
   so doesn’t look at it.
 *  [irenem](https://wordpress.org/support/users/irenem/)
 * (@irenem)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/function-override/#post-5155689)
 * You can’t override any existing function. But you can check the code inside the
   function if it uses some hooks then use it to change the result of that function.
 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/function-override/#post-5155711)
 * OR you may be able to establish a filter which can transform the html as it “
   goes past”.
 *  [respectyoda](https://wordpress.org/support/users/respectyoda/)
 * (@respectyoda)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/function-override/#post-5155725)
 * Here’s one alternative to explore (be sure to be using a child theme):
 * First, find which WooCommerce template file you want to deal with and override
   it. Here’s documentation on this: [Overriding WooCommerce Templates Safely](http://docs.woothemes.com/document/template-structure/)
 * Then, create your own function in functions.php similar to that of the WooCommerce
   function you want to modify and call it in your custom template file.
 *  [nenadcvele](https://wordpress.org/support/users/nenadcvele/)
 * (@nenadcvele)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/function-override/#post-5155853)
 * It’s an old topic, but maybe I could help a bit. I had similar problem. I wanted
   to override currencies, and add a custom currency. The functions are in woocommerce/
   includes/wc-core-functions.php
 *     ```
       function get_woocommerce_currencies() {
       	return array_unique(
       		apply_filters( 'woocommerce_currencies',
       			array(
       ```
   
 *  … and so on
    The other function is:
 *     ```
       function get_woocommerce_currency_symbol( $currency = '' ) {
       	if ( ! $currency ) {
       		$currency = get_woocommerce_currency();
       	}
   
       	switch ( $currency ) {
               ...
               return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency );
       ```
   
 * This is the code I’ve put in functions.php of my child theme:
 *     ```
       add_filter( 'woocommerce_currencies', 'add_my_currency' );
   
       function add_my_currency( $currencies ) {
       $currencies['RSD'] = __( 'Serbian dinar', 'woocommerce' );
       return $currencies;
       }
   
       add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
   
       function add_my_currency_symbol( $currency_symbol, $currency ) {
       switch( $currency ) {
       case 'RSD': $currency_symbol = 'RSD'; break;
       }
       return $currency_symbol;
       }
       ```
   
 *  [nenadcvele](https://wordpress.org/support/users/nenadcvele/)
 * (@nenadcvele)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/function-override/#post-5155854)
 * This would be the code for changing wc_cart_totals_order_total_html function (
   to be placed in child theme functions.php):
 *     ```
       add_filter('woocommerce_cart_totals_order_total_html','test_func');
       function test_func() {
           $value = '<strong>Test' . WC()->cart->get_total() . '</strong> ';
           return $value;
       }
       ```
   
 * It adds ‘Test’ to total amount.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘function override’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 7 replies
 * 6 participants
 * Last reply from: [nenadcvele](https://wordpress.org/support/users/nenadcvele/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/function-override/#post-5155854)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
