Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default currency #42

Open
pnordahl opened this issue Oct 24, 2012 · 2 comments
Open

Default currency #42

pnordahl opened this issue Oct 24, 2012 · 2 comments

Comments

@pnordahl
Copy link

It's not clear from the documentation that the "default currency" is considered to be index 0 of the CURRENCIES list. It might save others a bit of pdb'ing to figure out why they keep getting "exception not provided" when trying to add to cart something that isn't CHF. Perhaps a DEFAULT_CURRENCY setting that takes a 3-character currency string would be more explicit?

I'm also not certain that this error is normal, because even without modifying my CURRENCIES setting, Shouldn't I should by default be able to add products with a price set to be any of the 3-character currency strings provided by the default (CHF, CAD, USD, EUR) to my cart? I have no difficulty creating the product with say, USD as the currency in the admin. However, when I go to add it I get a "No exception supplied" DoesNotExist.

Changing my CURRENCIES setting to put USD as the first one gets me past the error, but it doesn't seem to be working as intended.

Any ideas Matthias?

EDIT: It seems that modifying the CURRENCIES list did not solve the issue. Pdb reveals that "currency" is always None in get_currency() of ProductBase, which does not seem to be intended behavior. Also, orderitem.currency() seems to only return "CHF", despite the product having a price specified in USD. I'm going to clear out .pyc's and the database to see if that solves it.

EDIT: OK, after removing all .pyc and dropping/recreating the database I think the problem seems to be the following: Say I have CURRENCIES = ("USD", "CHF", "EUR", "CAD"), and I create a product with a price in USD. I am able to proceed normally with adding to the cart and completing an order. However, if I create a product with a price in CHF, EUR, or CAD, attempting to add to the cart fails with a DoesNotExist exception.

FINAL EDIT: So it seems that in order to have multiple currencies, you need to override default_currency() on your Shop instance and provide the functionality yourself. Perfectly reasonable now that I know, but the documentation should probably reflect that the first currency listed in CURRENCIES is the only one that will work out-of-the-box without overriding the default implementation of default_currency().

@matthiask
Copy link
Owner

Wow... thanks for the report! As you found out you'll have to modify default_currency.

It should not have to feel like a quest for a hidden treasure though. I'll update the documentation if nobody beats me to it.

@pnordahl
Copy link
Author

Thanks for the great project! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants