Store: prix barré par produit via champ Item.store_regular_price

Affiché barré (gris) si > prix de vente (Item Price), sur produits simples + variantes
(les bundles gardent barré=somme des composants). Catalogue lit le champ; page rend <s>.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
louispaulb 2026-06-03 21:55:57 -04:00
parent 5807d58913
commit a855e11476

View File

@ -166,8 +166,8 @@ a{color:inherit}
<div class=cname>{{ p.name }}</div> <div class=cname>{{ p.name }}</div>
<div class=cprice> <div class=cprice>
<template v-if="p.bundle"><s>{{ money(p.sum) }}</s>{{ money(p.price) }}</template> <template v-if="p.bundle"><s>{{ money(p.sum) }}</s>{{ money(p.price) }}</template>
<template v-else-if="p.options"><span class=from>dès </span>{{ money(fromPrice(p)) }}</template> <template v-else-if="p.options"><s v-if="p.reg">{{ money(p.reg) }}</s> <span class=from>dès </span>{{ money(fromPrice(p)) }}</template>
<template v-else>{{ money(p.base) }}</template> <template v-else><s v-if="p.reg">{{ money(p.reg) }}</s> {{ money(p.base) }}</template>
</div> </div>
</div> </div>
</div> </div>
@ -189,7 +189,7 @@ a{color:inherit}
<div class=mdesc>{{ sel.desc }}</div> <div class=mdesc>{{ sel.desc }}</div>
<div class=mprice> <div class=mprice>
<s v-if="sel.bundle">{{ money(sel.sum) }}</s>{{ money(curPrice) }} <s v-if="sel.bundle">{{ money(sel.sum) }}</s><s v-else-if="sel.reg && sel.reg > curPrice">{{ money(sel.reg) }}</s> {{ money(curPrice) }}
</div> </div>
<div class=stock :class="stockClass">{{ stockLabel }}</div> <div class=stock :class="stockClass">{{ stockLabel }}</div>
@ -402,7 +402,7 @@ async function nameOf (code) {
async function buildCatalog () { async function buildCatalog () {
const items = await erp.list('Item', { const items = await erp.list('Item', {
filters: [['show_in_store', '=', 1], ['disabled', '=', 0]], filters: [['show_in_store', '=', 1], ['disabled', '=', 0]],
fields: ['name', 'item_name', 'item_group', 'image', 'description', 'standard_rate', 'has_variants', 'variant_of'], fields: ['name', 'item_name', 'item_group', 'image', 'description', 'standard_rate', 'has_variants', 'variant_of', 'store_regular_price'],
limit: 200, limit: 200,
}) })
const bundles = await erp.list('Product Bundle', { fields: ['name'], limit: 200 }) const bundles = await erp.list('Product Bundle', { fields: ['name'], limit: 200 })
@ -434,6 +434,7 @@ async function buildCatalog () {
const prices = info.map(v => v.price).filter(n => n > 0) const prices = info.map(v => v.price).filter(n => n > 0)
const baseP = prices.length ? Math.min(...prices) : (round2(it.standard_rate) || 0) const baseP = prices.length ? Math.min(...prices) : (round2(it.standard_rate) || 0)
p.base = baseP p.base = baseP
const rg = round2(it.store_regular_price); if (rg > baseP) p.reg = rg
const attrNames = [...new Set(info.flatMap(v => v.attrs.map(a => a.attribute)))] const attrNames = [...new Set(info.flatMap(v => v.attrs.map(a => a.attribute)))]
p.options = attrNames.map(an => { p.options = attrNames.map(an => {
const isColor = /couleur|color/i.test(an) const isColor = /couleur|color/i.test(an)
@ -452,6 +453,7 @@ async function buildCatalog () {
} else { } else {
p.base = (await priceOf(it.name)) || round2(it.standard_rate) || 0 p.base = (await priceOf(it.name)) || round2(it.standard_rate) || 0
p.stock = await stockOf(it.name) p.stock = await stockOf(it.name)
const rg = round2(it.store_regular_price); if (rg > p.base) p.reg = rg
} }
out.push(p) out.push(p)
} }