Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter nenadcvele

    (@nenadcvele)

    Thanx.
    I’ve translated everything, and now traslations are on waiting.

    Forum: Hacks
    In reply to: function override

    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.

    Forum: Hacks
    In reply to: function override

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

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