WooCommerce override function

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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(
    

    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;
    }