-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorder.go
154 lines (140 loc) · 5.29 KB
/
order.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
package woocommerce
type OrderStatus string
const (
OrderStatusPending OrderStatus = "pending"
OrderStatusProcessing OrderStatus = "processing"
OrderStatusOnHold OrderStatus = "on-hold"
OrderStatusCompleted OrderStatus = "completed"
OrderStatusCancelled OrderStatus = "cancelled"
OrderStatusRefunded OrderStatus = "refunded"
OrderStatusFailed OrderStatus = "failed"
OrderStatusTrash OrderStatus = "trash"
)
// Address is the address used in the order.
// It is used as billing and shipping address.
// Some fields are only present in billing address.
type Address struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Company string `json:"company"`
Address1 string `json:"address_1"`
Address2 string `json:"address_2"`
City string `json:"city"`
State string `json:"state"`
Postcode string `json:"postcode"`
Country string `json:"country"`
// The following fields are only present in the billing address.
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
}
// MetaData holds the meta data.
type MetaData struct {
ID int `json:"id"`
Key string `json:"key"`
Value interface{} `json:"value"`
}
type OrderTax struct {
ID int `json:"id"`
RateCode string `json:"rate_code"`
RateID String `json:"rate_id"`
Label string `json:"label"`
Compound bool `json:"compound"`
// TaxTotal presents tax total not including shipping taxes.
TaxTotal Float `json:"tax_total"`
ShippingTaxTotal Float `json:"shipping_tax_total"`
MetaData []MetaData `json:"meta_data"`
}
type OrderItem struct {
ID int `json:"id"`
Name string `json:"name"`
ProductID int `json:"product_id"`
VariationID int `json:"variation_id"`
Quantity int `json:"quantity"`
TaxClass string `json:"tax_class"`
// Subtotal is line subtotal before discounts
Subtotal Float `json:"subtotal"`
// SubtotalTax is line subtotal tax before discounts
SubtotalTax Float `json:"subtotal_tax"`
// Total is line total after discounts
Total Float `json:"total"`
// TotalTax is line total tax after discounts
TotalTax Float `json:"total_tax"`
Taxes []OrderTax `json:"taxes"`
MetaData []MetaData `json:"meta_data"`
SKU string `json:"sku"`
Price Float `json:"price"`
}
type OrderShipping struct {
ID int `json:"id"`
MethodTitle string `json:"method_title"`
MethodID string `json:"method_id"`
// Total is the line total after discounts.
Total Float `json:"total"`
// TotalTax is the line total tax after discounts.
TotalTax Float `json:"total_tax"`
Taxes []OrderTax `json:"taxes"`
MetaData []MetaData `json:"meta_data"`
}
type OrderCoupon struct {
ID int `json:"ID,omitempty"`
Code string `json:"code"`
Discount Float `json:"discount,omitempty"`
DiscountTax Float `json:"discount_tax,omitempty"`
MetaData []MetaData `json:"meta_data,omitempty"`
}
type OrderRefund struct {
ID int
Reason string
// Total is the refund total.
Total Float
}
// Order is the order object that the API returns.
type Order struct {
ID int `json:"id"`
ParentID int `json:"parent_id"`
Number string `json:"number"`
OrderKey string `json:"order_key"`
CreatedVia string `json:"created_via"`
Version string `json:"version"`
Status OrderStatus `json:"status"`
// Currency in 3-letter ISO format.
Currency string `json:"currency"`
DateCreated Time `json:"date_created"`
DateModified Time `json:"date_modified"`
// DiscountTotal is the total discount amount for the order
DiscountTotal string `json:"discount_total"`
// DiscountTax is the discount tax amount for the order
DiscountTax string `json:"discount_tax"`
// ShippingTotal is the shipping amount for the order
ShippingTotal string `json:"shipping_total"`
// ShippingTax is the shipping tax amount for the order
ShippingTax string `json:"shipping_tax"`
// CartTax is the sum of line item taxes only
CartTax string `json:"cart_tax"`
// Total is the grand total
Total string `json:"total"`
// TotalTax is the sum of all taxes
TotalTax string `json:"total_tax"`
// PricesIncludeTax is true the prices included tax during checkout
PricesIncludeTax bool `json:"prices_include_tax"`
CustomerID int `json:"customer_id"`
CustomerIPAddress string `json:"customer_ip_address"`
CustomerUserAgent string `json:"customer_user_agent"`
CustomerNote string `json:"customer_note"`
Billing Address `json:"billing"`
Shipping Address `json:"shipping"`
// PaymentMethod is the ID of the Payment method
PaymentMethod string `json:"payment_method"`
PaymentMethodTitle string `json:"payment_method_title"`
TransactionID string `json:"transaction_id"`
DatePaid NullTime `json:"date_paid"`
DateCompleted NullTime `json:"date_completed"`
// CartHash is the MD5 hash of the cart items.
CartHash string `json:"cart_hash"`
MetaData []MetaData `json:"meta_data"`
LineItems []OrderItem `json:"line_items"`
TaxLines []OrderTax `json:"tax_lines"`
ShippingLines []OrderShipping `json:"shipping_lines"`
CouponLines []OrderCoupon `json:"coupon_lines"`
Refunds []OrderRefund `json:"refunds"`
}