Feature: Add product variant price override support
Enables individual variants to have their own prices, overriding the base product price. **Database Changes:** - Added Price (decimal?, nullable) to ProductVariants table - Added ProductVariantId to OrderItems table with foreign key relationship - Created index on OrderItems.ProductVariantId for performance **API Changes:** - ProductVariantDto: Added Price field - CreateProductVariantDto: Added Price field with validation - UpdateProductVariantDto: Added Price field - OrderItemDto: Added ProductVariantId and ProductVariantName - CreateOrderItemDto: Added ProductVariantId **Business Logic:** - OrderService: Variant price overrides base price (but multi-buy takes precedence) - ProductService: All variant CRUD operations support Price field **Admin UI:** - CreateVariant: Price input with £ symbol and base price placeholder - EditVariant: Price editing with £ symbol - ProductVariants list: Shows variant price or "(base)" indicator **Client Library:** - Updated all DTOs to match server-side changes - Full support for variant pricing in order creation **Migration:** - EF Core migration: 20251003173458_AddVariantPricing - Backward compatible: NULL values supported for existing data **Use Case:** Products with size/color variants can now have different prices: - Small T-shirt: £15.00 (variant override) - Medium T-shirt: £18.00 (uses base price) - Large T-shirt: £20.00 (variant override) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -55,6 +55,16 @@
|
||||
<small class="form-text text-muted">Track inventory for this specific variant (optional)</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="Price" class="form-label"></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">£</span>
|
||||
<input asp-for="Price" type="number" step="0.01" class="form-control" min="0.01" placeholder="@product?.Price.ToString("F2")" />
|
||||
</div>
|
||||
<span asp-validation-for="Price" class="text-danger"></span>
|
||||
<small class="form-text text-muted">Override base price for this variant (optional - defaults to £@product?.Price.ToString("F2"))</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="SortOrder" class="form-label"></label>
|
||||
<input asp-for="SortOrder" type="number" class="form-control" />
|
||||
|
||||
@@ -51,6 +51,16 @@
|
||||
<span asp-validation-for="StockLevel" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="Price" class="form-label"></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">£</span>
|
||||
<input asp-for="Price" type="number" step="0.01" class="form-control" min="0.01" placeholder="@product?.Price.ToString("F2")" />
|
||||
</div>
|
||||
<span asp-validation-for="Price" class="text-danger"></span>
|
||||
<small class="form-text text-muted">Override base price (optional - defaults to £@product?.Price.ToString("F2"))</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="SortOrder" class="form-label"></label>
|
||||
<input asp-for="SortOrder" type="number" class="form-control" />
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Price</th>
|
||||
<th>Stock Level</th>
|
||||
<th>Sort Order</th>
|
||||
<th>Status</th>
|
||||
@@ -49,6 +50,16 @@
|
||||
<td>
|
||||
<span class="badge bg-info">@variant.VariantType</span>
|
||||
</td>
|
||||
<td>
|
||||
@if (variant.Price.HasValue)
|
||||
{
|
||||
<strong>£@variant.Price.Value.ToString("F2")</strong>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-muted">£@product?.Price.ToString("F2") (base)</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (variant.StockLevel > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user