/
product-variant.go
206 lines (203 loc) · 7.96 KB
/
product-variant.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package models
import (
"github.com/driver005/gateway/core"
"github.com/google/uuid"
)
// @oas:schema:ProductVariant
// title: "Product Variant"
// description: "A Product Variant represents a Product with a specific set of Product Option configurations. The maximum number of Product Variants that a Product can have is given by the number of available Product Option combinations. A product must at least have one product variant."
// type: object
// required:
// - allow_backorder
// - barcode
// - created_at
// - deleted_at
// - ean
// - height
// - hs_code
// - id
// - inventory_quantity
// - length
// - manage_inventory
// - material
// - metadata
// - mid_code
// - origin_country
// - product_id
// - sku
// - title
// - upc
// - updated_at
// - weight
// - width
//
// properties:
//
// id:
// description: The product variant's ID
// type: string
// example: variant_01G1G5V2MRX2V3PVSR2WXYPFB6
// title:
// description: A title that can be displayed for easy identification of the Product Variant.
// type: string
// example: Small
// product_id:
// description: The ID of the product that the product variant belongs to.
// type: string
// example: prod_01G1G5V2MBA328390B5AXJ610F
// product:
// description: The details of the product that the product variant belongs to.
// x-expandable: "product"
// nullable: true
// $ref: "#/components/schemas/Product"
// prices:
// description: The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.
// type: array
// x-expandable: "prices"
// items:
// $ref: "#/components/schemas/MoneyAmount"
// sku:
// description: The unique stock keeping unit used to identify the Product Variant. This will usually be a unique identifer for the item that is to be shipped, and can be referenced across multiple systems.
// nullable: true
// type: string
// example: shirt-123
// barcode:
// description: A generic field for a GTIN number that can be used to identify the Product Variant.
// nullable: true
// type: string
// example: null
// ean:
// description: An EAN barcode number that can be used to identify the Product Variant.
// nullable: true
// type: string
// example: null
// upc:
// description: A UPC barcode number that can be used to identify the Product Variant.
// nullable: true
// type: string
// example: null
// variant_rank:
// description: The ranking of this variant
// nullable: true
// type: number
// default: 0
// inventory_quantity:
// description: The current quantity of the item that is stocked.
// type: integer
// example: 100
// allow_backorder:
// description: Whether the Product Variant should be purchasable when `inventory_quantity` is 0.
// type: boolean
// default: false
// manage_inventory:
// description: Whether Medusa should manage inventory for the Product Variant.
// type: boolean
// default: true
// hs_code:
// description: The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.
// nullable: true
// type: string
// example: null
// origin_country:
// description: The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.
// nullable: true
// type: string
// example: null
// mid_code:
// description: The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.
// nullable: true
// type: string
// example: null
// material:
// description: The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.
// nullable: true
// type: string
// example: null
// weight:
// description: The weight of the Product Variant. May be used in shipping rate calculations.
// nullable: true
// type: number
// example: null
// length:
// description: "The length of the Product Variant. May be used in shipping rate calculations."
// nullable: true
// type: number
// example: null
// height:
// description: The height of the Product Variant. May be used in shipping rate calculations.
// nullable: true
// type: number
// example: null
// width:
// description: The width of the Product Variant. May be used in shipping rate calculations.
// nullable: true
// type: number
// example: null
// options:
// description: The details of the product options that this product variant defines values for.
// type: array
// x-expandable: "options"
// items:
// $ref: "#/components/schemas/ProductOptionValue"
// inventory_items:
// description: The details inventory items of the product variant.
// type: array
// x-expandable: "inventory_items"
// items:
// $ref: "#/components/schemas/ProductVariantInventoryItem"
// created_at:
// description: The date with timezone at which the resource was created.
// type: string
// format: date-time
// updated_at:
// description: The date with timezone at which the resource was updated.
// type: string
// format: date-time
// deleted_at:
// description: The date with timezone at which the resource was deleted.
// nullable: true
// type: string
// format: date-time
// metadata:
// description: An optional key-value map with additional details
// nullable: true
// type: object
// example: {car: "white"}
// externalDocs:
// description: "Learn about the metadata attribute, and how to delete and update it."
// url: "https://docs.medusajs.com/development/entities/overview#metadata-attribute"
// purchasable:
// description: |
// Only used with the inventory modules.
// A boolean value indicating whether the Product Variant is purchasable.
// A variant is purchasable if:
// - inventory is not managed
// - it has no inventory items
// - it is in stock
// - it is backorderable.
// type: boolean
type ProductVariant struct {
core.SoftDeletableModel
AllowBackorder bool `json:"allow_backorder" gorm:"column:allow_backorder;default:false"`
Purchasable bool `json:"purchasable" gorm:"column:purchasable"`
Barcode string `json:"barcode" gorm:"column:barcode"`
Ean string `json:"ean" gorm:"column:ean"`
Height float64 `json:"height" gorm:"column:height"`
HsCode string `json:"hs_code" gorm:"column:hs_code"`
InventoryQuantity int `json:"inventory_quantity" gorm:"column:inventory_quantity"`
Length float64 `json:"length" gorm:"column:length"`
ManageInventory bool `json:"manage_inventory" gorm:"column:manage_inventory;default:true"`
Material string `json:"material" gorm:"column:material"`
MIdCode string `json:"mid_code" gorm:"column:mid_code"`
Options []ProductOptionValue `json:"options" gorm:"foreignKey:Id"`
OriginCountry string `json:"origin_country" gorm:"column:origin_country"`
Prices []MoneyAmount `json:"prices" gorm:"many2many:product_variant_money_amount"`
Product *Product `json:"product" gorm:"foreignKey:ProductId"`
ProductId uuid.NullUUID `json:"product_id" gorm:"column:product_id"`
Sku string `json:"sku" gorm:"column:sku"`
Title string `json:"title" gorm:"column:title"`
Upc string `json:"upc" gorm:"column:upc"`
VariantRank int `json:"variant_rank" gorm:"column:variant_rank;default:0"`
Weight float64 `json:"weight" gorm:"column:weight"`
Width float64 `json:"width" gorm:"column:width"`
}