Feature: Royal Mail shipping integration with weight-based postage

Added:
- Weight field (weightGrams) to Product model for storing item weights
- Shipping fields to Order model (shippingCost, shippingCountry, shippingService)
- Royal Mail shipping service (royalmail-shipping.ts) with:
  * Domestic and international postage calculations
  * Integration ready for Royal Mail API (currently uses estimated rates)
  * Support for multiple shipping services
  * Clear international delivery time warnings
- Shipping quotes API endpoint (/api/checkout/shipping-quotes)
- Checkout integration to calculate and include shipping cost

Weight is stored in grams, displayed to users in kilograms.
Shipping cost is calculated based on total cart weight and destination country.
This commit is contained in:
Andymick
2026-07-19 06:46:35 +01:00
parent 9b9745e6e2
commit e150f2aed9
7 changed files with 296 additions and 12 deletions
+6 -2
View File
@@ -41,6 +41,7 @@ model Product {
printAreaHeightMm Int @default(280) // height of the printable area in millimeters
referenceWidthCm Int? // width of garment/object for ruler reference (cm)
referenceHeightCm Int? // height of garment/object for ruler reference (cm)
weightGrams Int? // weight in grams (used for Royal Mail postage calculation via API)
imageUrl String? // optional real product photo — shown instead of the illustration when set
imageUrlBack String? // optional back-view photo, toggled alongside the front photo
photoRecolorable Boolean @default(false) // if true, the photo is treated as a grayscale
@@ -218,12 +219,15 @@ model Order {
stripeSessionId String? @unique
email String?
shippingAddress String? // JSON — collected by Stripe Checkout, saved once payment completes
shippingCountry String? // ISO 2-letter country code (e.g., 'GB', 'US') for Royal Mail shipping
status String @default("PENDING") // PENDING | PAID | PRINTING | PRINTED | SHIPPED | DELIVERED | FAILED
archived Boolean @default(false)
total Int // cents
total Int // cents (includes shipping cost)
shippingCost Int @default(0) // cents — Royal Mail postage cost
// Shipping & tracking info
carrier String? // e.g. "Royal Mail", "DPD", "Courier"
shippingService String? // e.g. "Royal Mail 24®", "International Signed" — selected by customer at checkout
carrier String? @default("Royal Mail") // e.g. "Royal Mail", "DPD", "Courier"
trackingNumber String? // tracking number from carrier
estimatedDeliveryDate DateTime? // estimated delivery date