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:
1739
LittleShop/Migrations/20251003173458_AddVariantPricing.Designer.cs
generated
Normal file
1739
LittleShop/Migrations/20251003173458_AddVariantPricing.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
59
LittleShop/Migrations/20251003173458_AddVariantPricing.cs
Normal file
59
LittleShop/Migrations/20251003173458_AddVariantPricing.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LittleShop.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddVariantPricing : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "Price",
|
||||
table: "ProductVariants",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ProductVariantId",
|
||||
table: "OrderItems",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderItems_ProductVariantId",
|
||||
table: "OrderItems",
|
||||
column: "ProductVariantId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_OrderItems_ProductVariants_ProductVariantId",
|
||||
table: "OrderItems",
|
||||
column: "ProductVariantId",
|
||||
principalTable: "ProductVariants",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_OrderItems_ProductVariants_ProductVariantId",
|
||||
table: "OrderItems");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_OrderItems_ProductVariantId",
|
||||
table: "OrderItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Price",
|
||||
table: "ProductVariants");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProductVariantId",
|
||||
table: "OrderItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -859,6 +859,9 @@ namespace LittleShop.Migrations
|
||||
b.Property<Guid?>("ProductMultiBuyId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("ProductVariantId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -880,6 +883,8 @@ namespace LittleShop.Migrations
|
||||
|
||||
b.HasIndex("ProductMultiBuyId");
|
||||
|
||||
b.HasIndex("ProductVariantId");
|
||||
|
||||
b.ToTable("OrderItems");
|
||||
});
|
||||
|
||||
@@ -1041,6 +1046,9 @@ namespace LittleShop.Migrations
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal?>("Price")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("ProductId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@@ -1537,11 +1545,17 @@ namespace LittleShop.Migrations
|
||||
.HasForeignKey("ProductMultiBuyId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("LittleShop.Models.ProductVariant", "ProductVariant")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductVariantId");
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("ProductMultiBuy");
|
||||
|
||||
b.Navigation("ProductVariant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LittleShop.Models.Product", b =>
|
||||
|
||||
Reference in New Issue
Block a user