price function global (needs review)

This commit is contained in:
elvira
2026-08-08 15:10:37 +03:00
parent e46276a31b
commit 7677d10821
8 changed files with 65 additions and 7 deletions
@@ -1,4 +1,5 @@
import { Controller } from '@hotwired/stimulus'
import { formatPrice } from '../utils/format-price'
export default class extends Controller {
static targets = ['price', 'image', 'swatch', 'colorName']
@@ -30,7 +31,7 @@ export default class extends Controller {
if (!variant) return
if (this.hasPriceTarget && variant.price !== null) {
this.priceTarget.textContent = '€' + parseFloat(variant.price).toFixed(2)
this.priceTarget.textContent = formatPrice(variant.price)
}
if (this.hasImageTarget && variant.image) {