mirror of
https://github.com/pretix/pretix.git
synced 2026-08-04 09:47:50 +00:00
Show correct number of currency placed in widget (Z#23241522)
This commit is contained in:
@@ -795,6 +795,7 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
'target_url': eventreverse_absolute(request.event, 'presale:event.index'),
|
||||
'subevent': self.subevent.pk if self.subevent else None,
|
||||
'currency': request.event.currency,
|
||||
'currency_places': settings.CURRENCY_PLACES.get(request.event.currency, 2),
|
||||
'display_net_prices': request.event.settings.display_net_prices,
|
||||
'use_native_spinners': request.event.settings.widget_use_native_spinners,
|
||||
'show_variations_expanded': request.event.settings.show_variations_expanded,
|
||||
|
||||
@@ -380,16 +380,16 @@ Vue.component('pricebox', {
|
||||
},
|
||||
display_price: function () {
|
||||
if (this.$root.display_net_prices) {
|
||||
return floatformat(parseFloat(this.price.net), 2);
|
||||
return floatformat(this.price.net, this.$root.currency_places);
|
||||
} else {
|
||||
return floatformat(parseFloat(this.price.gross), 2);
|
||||
return floatformat(this.price.gross, this.$root.currency_places);
|
||||
}
|
||||
},
|
||||
display_price_nonlocalized: function () {
|
||||
if (this.$root.display_net_prices) {
|
||||
return parseFloat(this.price.net).toFixed(2);
|
||||
return parseFloat(this.price.net).toFixed(this.$root.currency_places);
|
||||
} else {
|
||||
return parseFloat(this.price.gross).toFixed(2);
|
||||
return parseFloat(this.price.gross).toFixed(this.$root.currency_places);
|
||||
}
|
||||
},
|
||||
suggested_price_nonlocalized: function () {
|
||||
@@ -398,9 +398,9 @@ Vue.component('pricebox', {
|
||||
price = this.price;
|
||||
}
|
||||
if (this.$root.display_net_prices) {
|
||||
return parseFloat(price.net).toFixed(2);
|
||||
return parseFloat(price.net).toFixed(this.$root.currency_places);
|
||||
} else {
|
||||
return parseFloat(price.gross).toFixed(2);
|
||||
return parseFloat(price.gross).toFixed(this.$root.currency_places);
|
||||
}
|
||||
},
|
||||
original_price_aria_label: function () {
|
||||
@@ -410,7 +410,7 @@ Vue.component('pricebox', {
|
||||
return django.interpolate(strings.new_price, [this.stripHTML(this.priceline)]);
|
||||
},
|
||||
original_line: function () {
|
||||
return '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + "</span> " + floatformat(parseFloat(this.original_price), 2);
|
||||
return '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + "</span> " + floatformat(this.original_price, this.$root.currency_places);
|
||||
},
|
||||
priceline: function () {
|
||||
if (this.price.gross === "0.00") {
|
||||
@@ -645,19 +645,19 @@ Vue.component('item', {
|
||||
if (this.item.free_price) {
|
||||
return django.interpolate(strings.price_from, {
|
||||
'currency': this.$root.currency,
|
||||
'price': floatformat(this.item.min_price, 2)
|
||||
'price': floatformat(this.item.min_price, this.$root.currency_places)
|
||||
}, true).replace(this.$root.currency, '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + '</span>');
|
||||
} else if (this.item.min_price !== this.item.max_price) {
|
||||
return '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + "</span> "
|
||||
+ floatformat(this.item.min_price, 2) + " – "
|
||||
+ floatformat(this.item.max_price, 2);
|
||||
return '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + "</span> "
|
||||
+ floatformat(this.item.min_price, this.$root.currency_places) + " – "
|
||||
+ floatformat(this.item.max_price, this.$root.currency_places);
|
||||
} else if (this.item.min_price === "0.00" && this.item.max_price === "0.00") {
|
||||
if (this.item.mandatory_priced_addons) {
|
||||
return "\xA0"; // nbsp, because an empty string would cause the HTML element to collapse
|
||||
}
|
||||
return strings.free;
|
||||
} else {
|
||||
return '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + "</span> " + floatformat(this.item.min_price, 2);
|
||||
return '<span class="pretix-widget-pricebox-currency">' + this.$root.currency + "</span> " + floatformat(this.item.min_price, this.$root.currency_places);
|
||||
}
|
||||
},
|
||||
variationsToggleLabel: function () {
|
||||
@@ -1949,6 +1949,7 @@ var shared_root_methods = {
|
||||
root.location = data.location;
|
||||
root.categories = data.items_by_category;
|
||||
root.currency = data.currency;
|
||||
root.currency_places = data.currency_places;
|
||||
root.display_net_prices = data.display_net_prices;
|
||||
root.voucher_explanation_text = data.voucher_explanation_text;
|
||||
root.error = data.error;
|
||||
@@ -1983,6 +1984,7 @@ var shared_root_methods = {
|
||||
}, function (error) {
|
||||
root.categories = [];
|
||||
root.currency = '';
|
||||
root.currency_places = 2;
|
||||
if (error.status === 429) {
|
||||
root.error = strings['loading_error_429'];
|
||||
root.connection_error = true;
|
||||
@@ -2339,6 +2341,7 @@ var create_widget = function (element, html_id=null) {
|
||||
is_button: false,
|
||||
categories: null,
|
||||
currency: null,
|
||||
currency_places: 2,
|
||||
name: null,
|
||||
date_range: null,
|
||||
location: null,
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface ProductListResponse {
|
||||
location?: string
|
||||
items_by_category?: Category[]
|
||||
currency?: string
|
||||
currency_places?: number
|
||||
display_net_prices?: boolean
|
||||
voucher_explanation_text?: string
|
||||
error?: string
|
||||
|
||||
@@ -72,7 +72,7 @@ const pricerange = computed(() => {
|
||||
STRINGS.price_from,
|
||||
{
|
||||
currency: store.currency,
|
||||
price: floatformat(props.item.min_price || '0', 2),
|
||||
price: floatformat(props.item.min_price || '0', store.currency_places),
|
||||
},
|
||||
true
|
||||
).replace(
|
||||
@@ -80,14 +80,14 @@ const pricerange = computed(() => {
|
||||
`<span class="pretix-widget-pricebox-currency">${store.currency}</span>`
|
||||
)
|
||||
} else if (props.item.min_price !== props.item.max_price) {
|
||||
return `<span class="pretix-widget-pricebox-currency">${store.currency}</span> ${floatformat(props.item.min_price || '0', 2)} – ${floatformat(props.item.max_price || '0', 2)}`
|
||||
return `<span class="pretix-widget-pricebox-currency">${store.currency}</span> ${floatformat(props.item.min_price || '0', store.currency_places)} – ${floatformat(props.item.max_price || '0', store.currency_places)}`
|
||||
} else if (props.item.min_price === '0.00' && props.item.max_price === '0.00') {
|
||||
if (props.item.mandatory_priced_addons) {
|
||||
return '\xA0' // nbsp, because an empty string would cause the HTML element to collapse
|
||||
}
|
||||
return STRINGS.free
|
||||
} else {
|
||||
return `<span class="pretix-widget-pricebox-currency">${store.currency}</span> ${floatformat(props.item.min_price || '0', 2)}`
|
||||
return `<span class="pretix-widget-pricebox-currency">${store.currency}</span> ${floatformat(props.item.min_price || '0', store.currency_places)}`
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ const ariaLabelledby = computed(() => `${store.htmlId}-item-label-${props.itemId
|
||||
|
||||
const displayPrice = computed(() => {
|
||||
if (store.displayNetPrices) {
|
||||
return floatformat(parseFloat(props.price.net), 2)
|
||||
return floatformat(props.price.net, store.currency_places)
|
||||
}
|
||||
return floatformat(parseFloat(props.price.gross), 2)
|
||||
return floatformat(props.price.gross, store.currency_places)
|
||||
})
|
||||
|
||||
const displayPriceNonlocalized = computed(() => {
|
||||
@@ -40,15 +40,15 @@ const displayPriceNonlocalized = computed(() => {
|
||||
const suggestedPriceNonlocalized = computed(() => {
|
||||
const price = props.suggestedPrice ?? props.price
|
||||
if (store.displayNetPrices) {
|
||||
return parseFloat(price.net).toFixed(2)
|
||||
return parseFloat(price.net).toFixed(store.currency_places)
|
||||
}
|
||||
return parseFloat(price.gross).toFixed(2)
|
||||
return parseFloat(price.gross).toFixed(store.currency_places)
|
||||
})
|
||||
|
||||
// TODO BAD
|
||||
const originalLine = computed(() => {
|
||||
if (!props.originalPrice) return ''
|
||||
return `<span class="pretix-widget-pricebox-currency">${store.currency}</span> ${floatformat(parseFloat(props.originalPrice), 2)}`
|
||||
return `<span class="pretix-widget-pricebox-currency">${store.currency}</span> ${floatformat(props.originalPrice, store.currency_places)}`
|
||||
})
|
||||
|
||||
// TODO BAD
|
||||
|
||||
@@ -71,6 +71,7 @@ export function createWidgetStore (config: {
|
||||
frontpageText: null as string | null,
|
||||
categories: [] as Category[],
|
||||
currency: '',
|
||||
currency_places: 2,
|
||||
displayNetPrices: false,
|
||||
voucherExplanationText: null as string | null,
|
||||
displayAddToCart: false,
|
||||
@@ -299,6 +300,7 @@ export function createWidgetStore (config: {
|
||||
this.location = data.location ?? null
|
||||
this.categories = data.items_by_category ?? []
|
||||
this.currency = data.currency ?? ''
|
||||
this.currency_places = data.currency_places ?? 2
|
||||
this.displayNetPrices = data.display_net_prices ?? false
|
||||
this.voucherExplanationText = data.voucher_explanation_text ?? null
|
||||
this.error = data.error ?? null
|
||||
@@ -338,6 +340,7 @@ export function createWidgetStore (config: {
|
||||
} catch (e) {
|
||||
this.categories = []
|
||||
this.currency = ''
|
||||
this.currency_places = 2
|
||||
if (e instanceof ApiError && e.status === 429) {
|
||||
this.error = STRINGS.loading_error_429
|
||||
} else {
|
||||
|
||||
@@ -173,6 +173,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
"currency_places": 2,
|
||||
"show_variations_expanded": False,
|
||||
"display_net_prices": False,
|
||||
"use_native_spinners": False,
|
||||
@@ -379,6 +380,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
"currency_places": 2,
|
||||
"show_variations_expanded": False,
|
||||
"display_net_prices": False,
|
||||
"use_native_spinners": False,
|
||||
@@ -439,6 +441,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
"currency_places": 2,
|
||||
"show_variations_expanded": False,
|
||||
"display_net_prices": False,
|
||||
"use_native_spinners": False,
|
||||
@@ -524,6 +527,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
"currency_places": 2,
|
||||
'poweredby': '<a href="https://pretix.eu" target="_blank" rel="noopener">ticketing powered by pretix</a>',
|
||||
"show_variations_expanded": False,
|
||||
"display_net_prices": False,
|
||||
|
||||
Reference in New Issue
Block a user