-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcart.go
119 lines (105 loc) · 4.1 KB
/
cart.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
package woocommerce
type CouponType string
const (
CouponTypePercent CouponType = "percent"
CouponTypeFixedCart CouponType = "fixed_cart"
CouponTypeFixedProduct CouponType = "fixed_product"
)
type CouponTotals struct {
CurrencyCode string `json:"currency_code"`
CurrencySymbol string `json:"currency_symbol"`
CurrencyMinorUnit int `json:"currency_minor_unit"`
CurrencyDecimalSeparator string `json:"currency_decimal_separator"`
CurrencyThousandSeparator string `json:"currency_thousand_separator"`
CurrencyPrefix string `json:"currency_prefix"`
CurrencySuffix string `json:"currency_suffix"`
TotalDiscount Int `json:"total_discount"`
TotalDiscountTax Int `json:"total_discount_tax"`
}
type Coupon struct {
Code string `json:"code"`
Type CouponType `json:"discount_type"`
Totals CouponTotals `json:"totals"`
}
type CartImage struct {
ID int `json:"id"`
SRC string `json:"src"`
Thumbnail string `json:"thumbnail"`
}
type CartItemTotals struct {
CurrencyCode string `json:"currency_code"`
CurrencyMinorUnit int `json:"currency_minor_unit"`
LineTotal Int `json:"line_total"`
LineTotalTax Int `json:"line_total_tax"`
LineSubtotal Int `json:"line_subtotal"`
LineSubtotalTax Int `json:"line_subtotal_tax"`
}
type CartAddress struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
Phone string `json:"phone,omitempty"`
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"`
}
type CartTotals struct {
CurrencyCode string `json:"currency_code"`
CurrencyMinorUnit int `json:"currency_minor_unit"`
TotalItems Int `json:"total_items"`
TotalItemsTax Int `json:"total_items_tax"`
TotalFees Int `json:"total_fees"`
TotalFeesTax Int `json:"total_fees_tax"`
TotalDiscount Int `json:"total_discount"`
TotalDiscountTax Int `json:"total_discount_tax"`
TotalShipping Int `json:"total_shipping"`
TotalShippingTax Int `json:"total_shipping_tax"`
TotalPrice Int `json:"total_price"`
TotalTax Int `json:"total_tax"`
}
type CartItemVariation struct {
Attribute string `json:"attribute"`
Value string `json:"value"`
}
type CartItem struct {
Key string `json:"key"`
ID int `json:"id"`
Quantity int `json:"quantity"`
Name string `json:"name"`
Summary string `json:"summary"`
ShortDescription string `json:"short_description"`
Description string `json:"description"`
SKU string `json:"sku"`
Images []CartImage `json:"images"`
Totals CartItemTotals `json:"totals"`
Variations []CartItemVariation `json:"variation"`
}
type CartShippingRateInner struct {
RateID string `json:"rate_id"`
Name string `json:"name"`
Description string `json:"description"`
Price Int `json:"price"`
MethodID string `json:"method_id"`
Selected bool `json:"selected"`
CurrencyCode string `json:"currency_code"`
}
type CartShippingRate struct {
PackageID int `json:"package_id"`
Name string `json:"name"`
ShippingRates []CartShippingRateInner `json:"shipping_rates"`
}
// Cart holds the cart data.
type Cart struct {
// CartToken is the cart token returned by woocommerce on cart request.
CartToken string `json:"cart_token"`
Coupons []Coupon `json:"coupons"`
Items []CartItem `json:"items"`
ShippingAddress CartAddress `json:"shipping_address"`
BillingAddress CartAddress `json:"billing_address"`
Totals CartTotals `json:"totals"`
ShippingRates []CartShippingRate `json:"shipping_rates"`
}