Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Oscar Gare

    (@oscargare)

    Hi!
    I’ll keep that in mind for future versions.
    Thank you.

    Hi Oscar,

    This is my big problem also. I have prices in USD$ and CAD$, but when people for example in Seattle, WA see one price in $xxxx, and then travel to Vancouver, Canada and then they see $yyyy, they think that we dropped/incresed the prices. they all think $ is just same currency, when it’s different CAD and USD.

    Please can you help how to add USD or CAD before $ symbol depending on a currency?

    I have found a temporary working solution. I do not recomment it to anyone as direct editing of core woocommerce files is not good.

    I had to edit the following file:
    wp-content/plugins/woocommerce/includes/wc-core-functions.php

    And add code as follows, before:

    function get_woocommerce_currency_symbol( $currency = '' ) {
    	if ( ! $currency ) {
    		$currency = get_woocommerce_currency();
    	}
    
    	switch ( $currency ) {
    		case 'AED' :
    			$currency_symbol = '?.?';
    			break;
    		case 'AUD' :
    		case 'CAD' :
    		case 'CLP' :
    		case 'COP' :
    		case 'HKD' :
    		case 'MXN' :
    		case 'NZD' :
    		case 'SGD' :
    		case 'USD' :
    			$currency_symbol = '$';
    			break;

    After:

    function get_woocommerce_currency_symbol( $currency = '' ) {
    	if ( ! $currency ) {
    		$currency = get_woocommerce_currency();
    	}
    
    	switch ( $currency ) {
    		case 'AED' :
    			$currency_symbol = '?.?';
    			break;
    		case 'AUD' :
    			$currency_symbol = 'AUD$';
    			break;
    		case 'CAD' :
    			$currency_symbol = 'CAD$';
    			break;
    		case 'CLP' :
    		case 'COP' :
    		case 'HKD' :
    		case 'MXN' :
    		case 'NZD' :
    		case 'SGD' :
    		case 'USD' :
    			$currency_symbol = 'USD$';
    			break;

    works good on my end, now people from USA see price with USD$, and people from Canada see price with CAD$.

    If anyone knows how to convert this solution into some function like code to append to themese function.php, that would be great.

    I added CAD to the Canadian Dollar (CAD$) by hooking into the woocommerce_currency_symbol filter.

    In functions.php, I put:

    add_filter('woocommerce_currency_symbol', 'prepend_canadian_currency_symbol', 10, 2);
    function prepend_canadian_currency_symbol($symbol, $currency)
    {
    	return $currency == 'CAD' ? $currency . $symbol : $symbol;
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add currency to price’ is closed to new replies.