pricing
This commit is contained in:
@@ -117,3 +117,43 @@ func WithoutVariantChildren(groups []models.Tenantproducts, isChild map[int]bool
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// PricedOnly drops the products a shopper cannot be charged for.
|
||||
//
|
||||
// The companion to InStockOnlyGrouped, and the same argument: being in a shop's
|
||||
// catalogue is not the same as being on sale. A product with no price is not
|
||||
// free, it is unfinished — but ₹0 on a phone reads as free, and a shopper who
|
||||
// taps it either expects to pay nothing or decides the shop is broken.
|
||||
//
|
||||
// ── Where the ₹0 products come from ─────────────────────────────────────────
|
||||
//
|
||||
// Import used to write no price at all, and 159 of the 1,572 catalogue rows
|
||||
// still carry no price for it to copy — loose produce has none by design, and
|
||||
// some scraped rows never had one. So an import lands at ₹0, the merchant adds
|
||||
// stock, and the product goes on sale at nothing. Measured 2026-09-03: Kmart's
|
||||
// entire customer-facing catalogue was five products, every one at ₹0.
|
||||
//
|
||||
// The merchant is not left guessing: the console lists these as "unpriced" with
|
||||
// a Set price button, and pricing one puts it on sale immediately.
|
||||
//
|
||||
// Deliberately NOT applied to the console, for the same reason as the stock
|
||||
// filter — an unpriced product is precisely what a merchant needs to see in
|
||||
// order to fix it.
|
||||
func PricedOnly(groups []models.Tenantproducts) []models.Tenantproducts {
|
||||
out := make([]models.Tenantproducts, 0, len(groups))
|
||||
for _, group := range groups {
|
||||
kept := make([]models.Products, 0, len(group.Products))
|
||||
for _, product := range group.Products {
|
||||
// `Price` is the effective figure the same query computed — the
|
||||
// outlet's own price, falling back to the master. Filtering on the
|
||||
// number that is DISPLAYED means the list and the label cannot
|
||||
// disagree.
|
||||
if product.Price > 0 {
|
||||
kept = append(kept, product)
|
||||
}
|
||||
}
|
||||
group.Products = kept
|
||||
out = append(out, group)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user