variant and price

This commit is contained in:
2026-08-28 16:54:55 +05:30
parent 6c1ad472f2
commit 40500f936a
3 changed files with 101 additions and 21 deletions

View File

@@ -177,13 +177,27 @@ func (s *productService) GetProductByVariant(tenantid, variantid, locationid, pr
return nil, err
}
// Same rule as the browse list: you can only order what the shop has.
// NOT filtered by stock, and that is the opposite of the browse list on
// purpose.
//
// Applied here too so the two screens cannot disagree. Without it a variant
// group would offer every size on the order sheet while the list that led
// there showed only the stocked ones, and a shopper could pick a size the
// branch has none of. Unscoped calls are left alone — see InStockOnly.
return InStockOnly(result, locationid), nil
// This endpoint backs the product screen — the one a shopper reaches by
// tapping something. It must always return what they tapped, plus every
// member of its variant group, whatever the shelf holds. Filtered, it
// produced two failures a shopper would meet immediately: an out-of-stock
// product answered with ZERO rows, leaving the screen with nothing to draw;
// and tapping "Apple" in a family where only Pineapple was stocked returned
// Pineapple, so the page showed something the shopper had not asked for.
//
// The rule the business wants — only order what we have — is still kept,
// in the two places that actually enforce it. The browse list offers only
// stocked products, and CreateOrder independently refuses a line it cannot
// fill (assertStockAvailable). So showing an empty size here cannot sell
// one; it only lets the app grey it out, the way every storefront does.
//
// `productstock` on each row is what the app disables on. A single ungrouped
// product comes back as a one-member group, so the app has one code path:
// count the rows, and skip the picker when there is only one.
return result, nil
}