From e54be98fe97da4f9fde09abf99a700579b2f059a Mon Sep 17 00:00:00 2001 From: kalipso Date: Wed, 5 Mar 2025 12:37:41 +0100 Subject: [PATCH] wip order --- models/cart.go | 30 ++++++++++++++++++++++++++++++ views/additem.html | 36 ------------------------------------ views/checkout.html | 23 ++++++++++------------- 3 files changed, 40 insertions(+), 49 deletions(-) diff --git a/models/cart.go b/models/cart.go index b9bb46b..53c3917 100644 --- a/models/cart.go +++ b/models/cart.go @@ -4,6 +4,35 @@ import ( "gorm.io/gorm" ) +type OrderStatus string + +const ( + Received OrderStatus = "Received" + AwaitingPayment OrderStatus = "AwaitingPayment" + Payed OrderStatus = "Payed" + ReadyForPickup OrderStatus = "ReadyForPickup" + Shipped OrderStatus = "Shipped" + Cancelled OrderStatus = "Cancelled" +) + +type AddressInfo struct { + FirstName string `json:"firstname"` + LastName string `json:"lastname"` + Address string `json:"address"` + PostalCode string `json:"postalcode"` + City string `json:"city"` + Country string `json:"country"` +} + +type Order struct { + gorm.Model + Status OrderStatus `json:"status"` + Token string `json:"token" binding:"required" gorm:"not null"` + CartItems []CartItem `json:"cartitems"` + Email string `json:"email"` + Comment string `json:"comment"` +} + type CartItem struct { gorm.Model SessionId string `json:"sessionid" binding:"required" gorm:"not null"` @@ -12,4 +41,5 @@ type CartItem struct { ItemVariantId uint ItemVariant ItemVariant `json:"itemvariant" gorm:"foreignKey:ItemVariantId"` //gorm one2one Quantity int `json:"quantity" binding:"required"` + OrderId uint } diff --git a/views/additem.html b/views/additem.html index 83a64e6..2f2bac3 100644 --- a/views/additem.html +++ b/views/additem.html @@ -116,40 +116,4 @@ -
- -

- - -

- -

Options

-
- - - -

-
- -
- - - -

-
- -
- - - -

-
- - -
- - {{ template "footer.html" . }} diff --git a/views/checkout.html b/views/checkout.html index 58fdbe0..4f65eed 100644 --- a/views/checkout.html +++ b/views/checkout.html @@ -68,19 +68,16 @@ -
- -
- -
-
+ +
+ + +

{{ .data.error }}