Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix locale-aware formatting for variants price inputs (admin) (#13455)
Dimitrios Panagkasidis77f648d4cf3c
diff --git a/admin/app/javascript/spree/admin/controllers/variants_form_controller.js b/admin/app/javascript/spree/admin/controllers/variants_form_controller.jsindex f424fdd14d..c6318fc575 100644--- a/admin/app/javascript/spree/admin/controllers/variants_form_controller.js+++ b/admin/app/javascript/spree/admin/controllers/variants_form_controller.js@@ -416,7 +416,7 @@ export default class extends CheckboxSelectAll {pricesVariation.delete(null)if (pricesVariation.size === 0) {- parentPriceEl.value = this.priceForVariant(variantName, currency).amount?.toLocaleString(this.localeValue) || ''+ parentPriceEl.value = this.formatNumber(this.priceForVariant(variantName, currency).amount)parentPriceEl.placeholder = ''return}@@ -425,9 +425,10 @@ export default class extends CheckboxSelectAll {if (minPrice !== maxPrice) {parentPriceEl.value = null- parentPriceEl.placeholder = `${minPrice} - ${maxPrice}`+ parentPriceEl.placeholder = `${this.formatNumber(minPrice)} - ${this.formatNumber(maxPrice)}`} else {- parentPriceEl.value = minPrice+ parentPriceEl.value = this.formatNumber(minPrice)+ parentPriceEl.placeholder = ''}}@@ -712,7 +713,7 @@ export default class extends CheckboxSelectAll {}const existingPrice = this.priceForVariant(internalName, currency)- priceInput.value = existingPrice.amount?.toLocaleString(this.localeValue) || ''+ priceInput.value = this.formatNumber(existingPrice.amount)currencyInput.value = currencyif (existingPrice.id) {idInput.value = existingPrice.id@@ -1132,4 +1133,14 @@ export default class extends CheckboxSelectAll {el.classList.add('hidden')}}++ formatNumber(value) {+ if (value === null) return ''+ if (typeof value === 'string' && value.trim() === '') return ''++ const number = Number(value)+ if (!Number.isFinite(number)) return ''++ return number.toLocaleString(this.localeValue)+ }}