Zen Cart Logo
Forums / Currencies & Sales Taxes, VAT, GST, etc. / Showing Products in Canadian Currency

Showing Products in Canadian Currency

Views: 2,691

Results 1 to 16 of 16
5 Mar 2011, 2:12 PM
#1
top_hatt avatar

top_hatt

Zen Follower

Join Date:
Feb 2010
Posts:
237
Plugin Contributions:
0

Showing Products in Canadian Currency

Hi. I'm sure this question has been asked before but I could not find anything doing a search.

I am in Canada but almost all my products come from the U.S.

Is there any way of having the U.S. as default currency but have Canadian be displayed?

Using the U.S. as the default currency and having Zen Cart do the currency correction is great. My only issue is that my market is Canada and having to have the customer change the currency all the time is an inconvenience.

Any help would be appreciated.

Dave

5 Mar 2011, 3:14 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Showing Products in Canadian Currency

My only issue is that my market is Canada and having to have the customer change the currency all the time is an inconvenience.
One must decide the default currency to be displayed

If it is more important for your customers to see their native Canadian currency then do that and you will have to make your correction for the orders manually

5 Mar 2011, 11:46 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing Products in Canadian Currency

You could test this ...

In the currencies class see if changing the last function does anything for you:
/includes/classes/currencies.php

  function display_price($products_price, $products_tax, $quantity = 1) {
    $us_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
    $cad_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity, 'true', 'CAD');

//    return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
    return $us_display_price . ' ' . $cad_display_price;
  }

I have not tested this everywhere and there are some places that are not using the display_price function such as on the subtotal in the shopping_cart but see if this gives you what you are trying to do ...

NOTE: this assumes that the current currency is left are USD ...

If you allow the change of currency on your site, you may want to alter the $us_display_price to be specific to USD ...

6 Mar 2011, 3:56 PM
#4
top_hatt avatar

top_hatt

Zen Follower

Join Date:
Feb 2010
Posts:
237
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Thanks for your reply. I will try this and see if it works for me.

The last sentence you said something about changing currencies?

I would really like to be able to have Canadian display but still be able to change to U.S. currency if a customer is American.

Anyway, thanks for your reply. I will try this and reply back.

Dave

6 Mar 2011, 4:37 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing Products in Canadian Currency

Then change the line for the US currency line to read:

    $us_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity, 'true', 'USD');

so that when the currency gets changed, the two lines do not both read CAD ...

8 Mar 2011, 12:10 AM
#6
top_hatt avatar

top_hatt

Zen Follower

Join Date:
Feb 2010
Posts:
237
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Hi:

Sorry it took so long for me to reply.

I tried the code that you so graciously provided. When I installed the code it displayed BOTH currencies on the the Product Listing and the Product Description page.

When I tried to switch currencies in the sidebox the entire display just went blank.

I am not able to really play with the code. I am not a programmer but just a copier.

Thanks again for the time you spent helping me.

If you have any other suggestions, I would be happy to try them.

Dave

8 Mar 2011, 12:29 AM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing Products in Canadian Currency

I tried both the original code I gave you and the adjusted code to maintain USD and CAD with:

  function display_price($products_price, $products_tax, $quantity = 1) {
    $us_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity, 'true', 'USD');
    $cad_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity, 'true', 'CAD');

//    return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
    return $us_display_price . ' ' . $cad_display_price;
  }

neither one breaks when I change the currencies back and forth ...

Where are when you change the currency and it breaks?

What debug messages do you see in the /cache directory when it breaks?

9 Mar 2011, 12:13 AM
#8
top_hatt avatar

top_hatt

Zen Follower

Join Date:
Feb 2010
Posts:
237
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Hi Ajeh:

Thank you for your time with me. I got the code to work and it works great. Now the currency comes up in Canadian but can be switched to U.S. if the customer chooses.

It is exactly what is was hoping for when I posted the question.

Thanks again, I really appreciated the time and patience with me.

Dave

31 Mar 2011, 10:14 PM
#9
silvermouse avatar

silvermouse

New Zenner

Join Date:
Mar 2011
Posts:
1
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Ajeh, many thanks, I had a similar problem with BGN (Bulgarian Lev). I used your code and replaced the display_price function in currencies.php and oh, miracle, all the zeros turned into prices :clap:

However, both currencies displayed. Then I reviewed the code, uncommented the second last line and commented the last line, and the currencies switched properly upon language selection, wooo hooooo, many thanks for your help :clap:

Ajeh:

I tried both the original code I gave you and the adjusted code to maintain USD and CAD with:

function display_price($products_price, $products_tax, $quantity = 1) {
$us_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity, 'true', 'USD');
$cad_display_price = $this->format(zen_add_tax($products_price, $products_tax) * $quantity, 'true', 'CAD');

// return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
return $us_display_price . ' ' . $cad_display_price;
}

> 
> neither one breaks when I change the currencies back and forth ...
> 
> Where are when you change the currency and it breaks?
> 
> What debug messages do you see in the /cache directory when it breaks?
22 Apr 2011, 2:12 PM
#10
alias_bob avatar

alias_bob

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Hi:

I tried to change the currency to Canadian but could not get it to work.

I replaced the "function display price" with the new code in the catalog/includes/classes/currencies.php but it still comes up in U.S.

I tried changing the admin/includes/classes/currencies.php file also but it did nothing either.

I am using 1.3.9f.

The website is http://www.poolcuesexpress.com

Any help would be appreciated.

22 Apr 2011, 7:08 PM
#11
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Showing Products in Canadian Currency

alias bob:

I tried to change the currency to Canadian but could not get it to work.
Restore all files altered to default and set default currencies in the admin

22 Apr 2011, 8:52 PM
#12
alias_bob avatar

alias_bob

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Yeah, I may have to; it would just be so great if the other way would work.

Thanks for the input.

22 Apr 2011, 11:06 PM
#13
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Showing Products in Canadian Currency

Yeah, I may have to; it would just be so great if the other way would work.
Why hack up the code to gain a builtin feature?

23 Apr 2011, 11:28 PM
#14
alias_bob avatar

alias_bob

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

I can't imagine Ajeh's code being a hack job.

Setting Canadian as the default means every time the exchange rate fluctuates all the prices will need to be adjusted.

That's a lot of changing.

I know, I know, too bad for me.

24 Apr 2011, 2:06 AM
#15
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Showing Products in Canadian Currency

I tried to change the currency to Canadian but could not get it to work.

I can't imagine Ajeh's code being a hack job.
Ajeh's code if for a particular condition the the OP has
NOT just setting the default currency to CAD, which is a builtin function and no need to "hack" the code to attain that

24 Apr 2011, 12:24 PM
#16
alias_bob avatar

alias_bob

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Re: Showing Products in Canadian Currency

Kobra:

I think you and I are talking about different things.

I know how to change the default currency to Canadian in the admin, what I was trying to achieve was to leave it as U.S. but have the display show Canadian.

As the original poster stated, most of my products come from the U.S. and Zen Cart does a great job of converting to different currencies. I would like to keep the U.S. as default but show the products in Canadian dollars on the site.