Showcase Oscar application with multi-currency support.
It allows to switch basket currency and do purchases in any allowed currency.
Implementation described in the blog post on Metaclass website - https://metaclass.co/django_multicurrency.html
Multi-currency support for Django-Oscar
Home Page: https://metaclass.co/django_multicurrency.html
Showcase Oscar application with multi-currency support.
It allows to switch basket currency and do purchases in any allowed currency.
Implementation described in the blog post on Metaclass website - https://metaclass.co/django_multicurrency.html
If left this code as it is the dashboard start complaining about not filled values for Stock and pricing. This happens in my case because the default choice field widget has no empty value. This is why an empty extra form always change initial value for price_currency
from None to first value from settings.OSCAR_CURRENCIES
.
Just setting initial should help in this case.
price_currency = forms.ChoiceField(initial=settings.OSCAR_CURRENCIES[0], choices=CURRENCY_CHOICES)
Hi,
I have found uncovered case. When add a product to a basket and then change its price next time you open a basket you will see a warning about changing in price. The price will be in the wrong currency. This happens because the method get_warning
doesn't take into account the line currency and asummes it always default.
The solution is to override the method and pass correct currency.
# apps/basket/models.py
class Line(AbstractLine):
def get_warning(self):
"""
Return a warning message about this basket line if one is applicable
This could be things like the price has changed
"""
if isinstance(self.purchase_info.availability, Unavailable):
msg = "'%(product)s' is no longer available"
return _(msg) % {'product': self.product.get_title()}
if not self.price_incl_tax:
return
if not self.purchase_info.price.is_tax_known:
return
# Compare current price to price when added to basket
current_price_incl_tax = self.purchase_info.price.incl_tax
if current_price_incl_tax != self.price_incl_tax:
product_prices = {
'product': self.product.get_title(),
'old_price': currency(self.price_incl_tax, self.price_currency), # pass the line price currency
'new_price': currency(current_price_incl_tax, self.price_currency) # pass the line price currency
}
if current_price_incl_tax > self.price_incl_tax:
warning = _("The price of '%(product)s' has increased from"
" %(old_price)s to %(new_price)s since you added"
" it to your basket")
return warning % product_prices
else:
warning = _("The price of '%(product)s' has decreased from"
" %(old_price)s to %(new_price)s since you added"
" it to your basket")
return warning % product_prices
Getting error after running a command:
./manage.py rebuild_index --noinput
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.