feat(cart): Shipping methods (#6101)

This commit is contained in:
Oli Juhl
2024-01-18 12:16:15 +01:00
committed by GitHub
parent 5cfb662ec0
commit 7f7cb2a263
19 changed files with 431 additions and 31 deletions
+3 -3
View File
@@ -94,13 +94,13 @@ export default class LineItem {
@Property({ columnType: "jsonb", nullable: true })
variant_option_values?: Record<string, unknown> | null
@Property({ columnType: "boolean", default: true })
@Property({ columnType: "boolean" })
requires_shipping = true
@Property({ columnType: "boolean", default: true })
@Property({ columnType: "boolean" })
is_discountable = true
@Property({ columnType: "boolean", default: false })
@Property({ columnType: "boolean" })
is_tax_inclusive = false
@Property({ columnType: "numeric", nullable: true })
+6 -3
View File
@@ -16,16 +16,20 @@ import ShippingMethodAdjustmentLine from "./shipping-method-adjustment-line"
import ShippingMethodTaxLine from "./shipping-method-tax-line"
@Entity({ tableName: "cart_shipping_method" })
@Check<ShippingMethod>({ expression: (columns) => `${columns.amount} >= 0` })
export default class ShippingMethod {
@PrimaryKey({ columnType: "text" })
id: string
@Property({ columnType: "text" })
cart_id: string
@ManyToOne(() => Cart, {
onDelete: "cascade",
index: "IDX_shipping_method_cart_id",
fieldName: "cart_id",
nullable: true,
})
cart: Cart
cart?: Cart | null
@Property({ columnType: "text" })
name: string
@@ -34,7 +38,6 @@ export default class ShippingMethod {
description?: string | null
@Property({ columnType: "numeric", serializer: Number })
@Check({ expression: "amount >= 0" }) // TODO: Validate that numeric types work with the expression
amount: number
@Property({ columnType: "boolean" })