wip order

This commit is contained in:
2025-03-05 12:37:41 +01:00
parent 56035bb32f
commit e54be98fe9
3 changed files with 40 additions and 49 deletions

View File

@@ -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
}

View File

@@ -116,40 +116,4 @@
</div>
</div>
<form action="/submit-product" method="POST">
<label for="product-name">Product Name:</label>
<input type="text" id="product-name" name="product-name" required><br><br>
<label for="product-type">Product Type:</label>
<select id="product-type" name="product-type" required>
<option value="magazine">Magazine</option>
<option value="t-shirt">T-Shirt</option>
</select><br><br>
<h3>Options</h3>
<div class="option-group">
<label for="option-name-1">Option Name:</label>
<input type="text" id="option-name-1" name="option-name[]" required>
<label for="option-price-1">Price:</label>
<input type="number" id="option-price-1" name="option-price[]" required><br><br>
</div>
<div class="option-group">
<label for="option-name-2">Option Name:</label>
<input type="text" id="option-name-2" name="option-name[]" required>
<label for="option-price-2">Price:</label>
<input type="number" id="option-price-2" name="option-price[]" required><br><br>
</div>
<div class="option-group">
<label for="option-name-3">Option Name:</label>
<input type="text" id="option-name-3" name="option-name[]" required>
<label for="option-price-3">Price:</label>
<input type="number" id="option-price-3" name="option-price[]" required><br><br>
</div>
<input type="submit" value="Add Product">
</form>
{{ template "footer.html" . }}

View File

@@ -68,18 +68,15 @@
<textarea id="description" name="description" type="textarea" class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"></textarea>
</div>
<div class="mb-4">
<label class="block text-sm/6 text-gray-900">Shipping</label>
<div class="space-y-2">
<label class="flex text-sm/6 items-center">
<input type="checkbox" class="form-checkbox h-4 w-4 text-gray-900" value="{{ .ID }}" name="shipping">
<span class="ml-2 text-sm/6 text-gray-900">Germany</span>
<input type="checkbox" class="form-checkbox h-4 w-4 text-gray-900" value="{{ .ID }}" name="shipping">
<span class="ml-2 text-sm/6 text-gray-900">International</span>
<input type="checkbox" class="form-checkbox h-4 w-4 text-gray-900" value="{{ .ID }}" name="shipping">
<span class="ml-2 text-sm/6 text-gray-900">Pickup</span>
</label>
</div>
<div class="flex mb-4">
<label for="DeliveryMethod" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white"></label>
<select name="DeliveryMethod" id="DeliveryMethod" required class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<option selected value="">Shipping</option>
<option value="germany">germany (DHL) 3.99€</option>
<option value="international">international (DHL) 5.99€</option>
<option value="pickup">pickup 0.00€</option>
</select>
</div>
<p class="mt-10 text-center text-sm/6 text-red-500">