@dropins/storefront-cart 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.js +5 -5
- package/chunks/CartFragment.js +235 -0
- package/chunks/EmptyCart.js +1 -0
- package/chunks/getEstimateShipping.js +48 -0
- package/chunks/getEstimatedTotals.js +4 -51
- package/chunks/getStoreConfig.js +4 -4
- package/chunks/resetCart.js +1 -230
- package/chunks/updateProductsFromCart.js +4 -4
- package/components/Cart/Cart.d.ts +2 -1
- package/components/EstimateShipping/EstimateShipping.d.ts +20 -0
- package/components/EstimateShipping/index.d.ts +2 -0
- package/components/MiniCart/MiniCart.d.ts +1 -0
- package/components/OrderSummary/OrderSummary.d.ts +37 -0
- package/components/OrderSummary/index.d.ts +3 -0
- package/components/index.d.ts +3 -1
- package/containers/Cart/Cart.d.ts +4 -6
- package/containers/Cart.js +1 -1
- package/containers/EstimateShipping/EstimateShipping.d.ts +7 -0
- package/containers/EstimateShipping/index.d.ts +3 -0
- package/containers/EstimateShipping.d.ts +3 -0
- package/containers/EstimateShipping.js +1 -0
- package/containers/MiniCart.js +1 -1
- package/containers/OrderSummary/OrderSummary.d.ts +16 -0
- package/containers/OrderSummary/index.d.ts +3 -0
- package/containers/OrderSummary.d.ts +3 -0
- package/containers/OrderSummary.js +1 -0
- package/containers/index.d.ts +2 -0
- package/data/models/cart-model.d.ts +9 -1
- package/data/models/index.d.ts +1 -0
- package/data/models/shipping-models.d.ts +16 -0
- package/data/transforms/__fixtures__/productTypesData.d.ts +223 -5
- package/data/transforms/transform-shipping.d.ts +5 -0
- package/i18n/en_US.json.d.ts +57 -2
- package/lib/state.d.ts +1 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/chunks/MiniCart.js +0 -1
package/api.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{s as c,f as d,h as u}from"./chunks/resetCart.js";import{g as x,r as y,d as $,a as v,b as w,c as Q}from"./chunks/resetCart.js";import{C as f,a as l,t as g}from"./chunks/CartFragment.js";import{events as p}from"@dropins/tools/event-bus.js";import{p as I,a as _}from"./chunks/updateProductsFromCart.js";import{u as k}from"./chunks/updateProductsFromCart.js";import{c as h}from"./chunks/getStoreConfig.js";import{g as Y,b as j,i as q,a as B}from"./chunks/getStoreConfig.js";import{a as K,g as L,b as V}from"./chunks/getEstimateShipping.js";import{g as X}from"./chunks/getEstimatedTotals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const E=`
|
|
2
2
|
mutation ADD_PRODUCTS_TO_CART_MUTATION(
|
|
3
3
|
$cartId: String!,
|
|
4
4
|
$cartItems: [CartItemInput!]!,
|
|
5
|
-
${
|
|
5
|
+
${f}
|
|
6
6
|
) {
|
|
7
7
|
addProductsToCart(
|
|
8
8
|
cartId: $cartId
|
|
@@ -17,9 +17,9 @@ import{C,a as T,s as n,f as m,h as u,t as l}from"./chunks/resetCart.js";import{g
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
${
|
|
21
|
-
`,
|
|
20
|
+
${l}
|
|
21
|
+
`,b=async a=>{let s=!1;const o=c.cartId||await R().then(e=>(s=!0,e));return d(E,{variables:{cartId:o,cartItems:a.map(({sku:e,parentSku:r,quantity:n,optionsUIDs:t,enteredOptions:i})=>({sku:e,parent_sku:r,quantity:n,selected_options:t,entered_options:i}))}}).then(({errors:e,data:r})=>{var i;const n=[...((i=r==null?void 0:r.addProductsToCart)==null?void 0:i.user_errors)??[],...e??[]];if(n.length>0)return u(n);const t=g(r.addProductsToCart.cart);if(p.emit("cart/updated",t),p.emit("cart/data",t),t){const m=t.items.filter(C=>a.some(({sku:T})=>T===C.sku));s?I(t,m,c.locale??"en-US"):_(t,m,c.locale??"en-US")}return t})},A=`
|
|
22
22
|
mutation CREATE_EMPTY_CART_MUTATION {
|
|
23
23
|
createEmptyCart
|
|
24
24
|
}
|
|
25
|
-
`,
|
|
25
|
+
`,R=async()=>{const{disableGuestCart:a}=h.getConfig();if(a)throw new Error("Guest cart is disabled");return await d(A).then(({data:s})=>{const o=s.createEmptyCart;return c.cartId=o,o})};export{b as addProductsToCart,h as config,R as createEmptyCart,d as fetchGraphQl,Y as getCartData,x as getConfig,K as getCountries,L as getEstimateShipping,X as getEstimatedTotals,V as getRegions,j as getStoreConfig,q as initialize,B as initializeCart,y as removeFetchGraphQlHeader,$ as resetCart,v as setEndpoint,w as setFetchGraphQlHeader,Q as setFetchGraphQlHeaders,k as updateProductsFromCart};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import{s}from"./resetCart.js";function R(r){var n,u,e,l,c,t,a;return r?{id:r.id,totalQuantity:z(r),errors:S(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((n=s.config)==null?void 0:n.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency},excludingTax:{value:r.prices.grand_total_excluding_tax.value,currency:r.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(u=r.prices.subtotal_excluding_tax)==null?void 0:u.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(l=r.prices.subtotal_including_tax)==null?void 0:l.value,currency:(c=r.prices.subtotal_including_tax)==null?void 0:c.currency},includingDiscountOnly:{value:(t=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:t.value,currency:(a=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:a.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:k(r.prices.applied_taxes),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&N(r)},isGuestCart:!s.authenticated,hasOutOfStockItems:$(r),hasFullyOutOfStockItems:P(r)}:null}function k(r){return r!=null&&r.length?r.reduce((n,u)=>({value:n.value+u.amount.value,currency:u.amount.currency}),{value:0,currency:""}):null}function h(r){var u;if(!((u=r==null?void 0:r.items)!=null&&u.length))return[];const n=s.config;return r.items.map(e=>{var l,c,t,a,_,o,i,g,y,m,f,b,d,v,C,x;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(O=>O.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(l=e.configured_variant)==null?void 0:l.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((a=(t=e.configured_variant)==null?void 0:t.thumbnail)==null?void 0:a.label)||e.product.thumbnail.label},price:{value:e.prices.price.value,currency:e.prices.price.currency},taxedPrice:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency},links:G(e.links),total:e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.row_total.value,currency:e.prices.row_total.currency}:{value:(_=e.prices.original_row_total)==null?void 0:_.value,currency:(o=e.prices.original_row_total)==null?void 0:o.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(i=e.configured_variant)==null?void 0:i.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(y=e.configured_variant)==null?void 0:y.price_range)==null?void 0:m.maximum_price.regular_price.currency}:e.__typename==="GiftCardCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.price.value,currency:e.prices.price.currency}:{value:(f=e.product.price_range)==null?void 0:f.maximum_price.regular_price.value,currency:(b=e.product.price_range)==null?void 0:b.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(d=e.configured_variant)==null?void 0:d.price_range)==null?void 0:v.maximum_price.discount.amount_off)>0:((C=e.product.price_range)==null?void 0:C.maximum_price.discount.amount_off)>0,bundleOptions:e.__typename==="BundleCartItem"?w(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:A(e.customizable_options),sender:e.__typename==="GiftCardCartItem"?e.sender_name:null,senderEmail:e.__typename==="GiftCardCartItem"?e.sender_email:null,recipient:e.__typename==="GiftCardCartItem"?e.recipient_name:null,recipientEmail:e.__typename==="GiftCardCartItem"?e.recipient_email:null,message:e.__typename==="GiftCardCartItem"?e.message:null,discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},onlyXLeftInStock:e.__typename==="ConfigurableCartItem"?(x=e.configured_variant)==null?void 0:x.only_x_left_in_stock:e.product.only_x_left_in_stock,lowInventory:e.is_available&&e.product.only_x_left_in_stock!==null,insufficientQuantity:(e.__typename==="ConfigurableCartItem"?e.configured_variant:e.product).stock_status==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockLevel:M(e)}})}function S(r){var u;const n=(u=r==null?void 0:r.items)==null?void 0:u.reduce((e,l)=>{var c;return(c=l.errors)==null||c.forEach(t=>{e.push({uid:l.uid,text:t.message})}),e},[]);return n!=null&&n.length?n:null}function I(r){return r!=null&&r.length?r.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})):[]}function w(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(l=>l.label).join(", ")})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function E(r){const n=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function A(r){const n=r==null?void 0:r.map(e=>({uid:e.customizable_option_uid,label:e.label,type:e.type,values:e.values.map(l=>({uid:l.customizable_option_value_uid,label:l.label,value:l.value}))})),u={};return n==null||n.forEach(e=>{var l;switch(e.type){case"field":case"area":case"date_time":u[e.label]=e.values[0].value;break;case"radio":case"drop_down":u[e.label]=e.values[0].label;break;case"multiple":case"checkbox":u[e.label]=e.values.reduce((o,i)=>o?`${o}, ${i.label}`:i.label,"");break;case"file":const c=new DOMParser,t=e.values[0].value,_=((l=c.parseFromString(t,"text/html").querySelector("a"))==null?void 0:l.textContent)||"";u[e.label]=_;break}}),u}function z(r){var n,u;return((n=s.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((u=s.config)==null?void 0:u.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function G(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function N(r){var n,u,e,l;return(n=r.shipping_addresses)!=null&&n.length?(u=r.shipping_addresses)==null?void 0:u.map(c=>({countryCode:c.country.code,zipCode:c.postcode,regionCode:c.region.code})):(e=r.addresses)!=null&&e.length?(l=r.addresses)==null?void 0:l.filter(c=>c.default_shipping).map(c=>{var t;return c.default_shipping&&{countryCode:c.country_id,zipCode:c.postcode,regionCode:(t=c.region)==null?void 0:t.region_code}}):null}function $(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"||e.product.stock_status==="IN_STOCK"&&!e.is_available})}function M(r){if(!r.not_available_message)return null;const n=r.not_available_message.match(/-?\d+/);return n?parseInt(n[0]):"noNumber"}function P(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"})}const p=`
|
|
2
|
+
customizable_options {
|
|
3
|
+
type
|
|
4
|
+
customizable_option_uid
|
|
5
|
+
label
|
|
6
|
+
is_required
|
|
7
|
+
values {
|
|
8
|
+
label
|
|
9
|
+
value
|
|
10
|
+
price{
|
|
11
|
+
type
|
|
12
|
+
units
|
|
13
|
+
value
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`,T=`
|
|
18
|
+
price_range {
|
|
19
|
+
minimum_price {
|
|
20
|
+
regular_price {
|
|
21
|
+
value
|
|
22
|
+
currency
|
|
23
|
+
}
|
|
24
|
+
final_price {
|
|
25
|
+
value
|
|
26
|
+
currency
|
|
27
|
+
}
|
|
28
|
+
discount {
|
|
29
|
+
percent_off
|
|
30
|
+
amount_off
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
maximum_price {
|
|
34
|
+
regular_price {
|
|
35
|
+
value
|
|
36
|
+
currency
|
|
37
|
+
}
|
|
38
|
+
final_price {
|
|
39
|
+
value
|
|
40
|
+
currency
|
|
41
|
+
}
|
|
42
|
+
discount {
|
|
43
|
+
percent_off
|
|
44
|
+
amount_off
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`,D=`
|
|
49
|
+
fragment CartFragment on Cart {
|
|
50
|
+
id
|
|
51
|
+
total_quantity
|
|
52
|
+
is_virtual
|
|
53
|
+
prices {
|
|
54
|
+
subtotal_with_discount_excluding_tax {
|
|
55
|
+
currency
|
|
56
|
+
value
|
|
57
|
+
}
|
|
58
|
+
subtotal_including_tax {
|
|
59
|
+
currency
|
|
60
|
+
value
|
|
61
|
+
}
|
|
62
|
+
subtotal_excluding_tax {
|
|
63
|
+
currency
|
|
64
|
+
value
|
|
65
|
+
}
|
|
66
|
+
grand_total {
|
|
67
|
+
currency
|
|
68
|
+
value
|
|
69
|
+
}
|
|
70
|
+
grand_total_excluding_tax {
|
|
71
|
+
currency
|
|
72
|
+
value
|
|
73
|
+
}
|
|
74
|
+
applied_taxes {
|
|
75
|
+
label,
|
|
76
|
+
amount {
|
|
77
|
+
value
|
|
78
|
+
currency
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
discounts {
|
|
82
|
+
amount {
|
|
83
|
+
value
|
|
84
|
+
currency
|
|
85
|
+
}
|
|
86
|
+
label
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
itemsV2 (
|
|
90
|
+
pageSize:$pageSize,
|
|
91
|
+
currentPage:$currentPage,
|
|
92
|
+
sort: $itemsSortInput
|
|
93
|
+
) {
|
|
94
|
+
items {
|
|
95
|
+
__typename
|
|
96
|
+
uid
|
|
97
|
+
quantity
|
|
98
|
+
is_available
|
|
99
|
+
not_available_message
|
|
100
|
+
errors {
|
|
101
|
+
code
|
|
102
|
+
message
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
prices {
|
|
106
|
+
price {
|
|
107
|
+
value
|
|
108
|
+
currency
|
|
109
|
+
}
|
|
110
|
+
total_item_discount {
|
|
111
|
+
value
|
|
112
|
+
currency
|
|
113
|
+
}
|
|
114
|
+
row_total {
|
|
115
|
+
value
|
|
116
|
+
currency
|
|
117
|
+
}
|
|
118
|
+
row_total_including_tax {
|
|
119
|
+
value
|
|
120
|
+
currency
|
|
121
|
+
}
|
|
122
|
+
price_including_tax {
|
|
123
|
+
value
|
|
124
|
+
currency
|
|
125
|
+
}
|
|
126
|
+
fixed_product_taxes {
|
|
127
|
+
amount {
|
|
128
|
+
value
|
|
129
|
+
currency
|
|
130
|
+
}
|
|
131
|
+
label
|
|
132
|
+
}
|
|
133
|
+
original_row_total{
|
|
134
|
+
value
|
|
135
|
+
currency
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
product {
|
|
140
|
+
name
|
|
141
|
+
sku
|
|
142
|
+
thumbnail {
|
|
143
|
+
url
|
|
144
|
+
label
|
|
145
|
+
}
|
|
146
|
+
url_key
|
|
147
|
+
url_suffix
|
|
148
|
+
categories {
|
|
149
|
+
url_path
|
|
150
|
+
url_key
|
|
151
|
+
}
|
|
152
|
+
only_x_left_in_stock
|
|
153
|
+
stock_status
|
|
154
|
+
${T}
|
|
155
|
+
}
|
|
156
|
+
...on SimpleCartItem {
|
|
157
|
+
${p}
|
|
158
|
+
}
|
|
159
|
+
... on ConfigurableCartItem {
|
|
160
|
+
configurable_options {
|
|
161
|
+
configurable_product_option_uid
|
|
162
|
+
option_label
|
|
163
|
+
value_label
|
|
164
|
+
}
|
|
165
|
+
configured_variant {
|
|
166
|
+
uid
|
|
167
|
+
sku
|
|
168
|
+
only_x_left_in_stock
|
|
169
|
+
stock_status
|
|
170
|
+
thumbnail {
|
|
171
|
+
label
|
|
172
|
+
url
|
|
173
|
+
}
|
|
174
|
+
${T}
|
|
175
|
+
}
|
|
176
|
+
${p}
|
|
177
|
+
}
|
|
178
|
+
... on DownloadableCartItem {
|
|
179
|
+
links {
|
|
180
|
+
sort_order
|
|
181
|
+
title
|
|
182
|
+
}
|
|
183
|
+
${p}
|
|
184
|
+
}
|
|
185
|
+
... on BundleCartItem {
|
|
186
|
+
bundle_options {
|
|
187
|
+
uid
|
|
188
|
+
label
|
|
189
|
+
values {
|
|
190
|
+
uid
|
|
191
|
+
label
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
... on GiftCardCartItem {
|
|
196
|
+
message
|
|
197
|
+
recipient_email
|
|
198
|
+
recipient_name
|
|
199
|
+
sender_email
|
|
200
|
+
sender_name
|
|
201
|
+
amount{
|
|
202
|
+
currency
|
|
203
|
+
value
|
|
204
|
+
}
|
|
205
|
+
is_available
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
shipping_addresses {
|
|
210
|
+
country {
|
|
211
|
+
code
|
|
212
|
+
}
|
|
213
|
+
region {
|
|
214
|
+
code
|
|
215
|
+
}
|
|
216
|
+
postcode
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
`,V=`
|
|
220
|
+
$pageSize: Int! = 100,
|
|
221
|
+
$currentPage: Int! = 1,
|
|
222
|
+
$itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
|
|
223
|
+
`,q=`
|
|
224
|
+
customer {
|
|
225
|
+
addresses {
|
|
226
|
+
default_shipping
|
|
227
|
+
country_id
|
|
228
|
+
postcode
|
|
229
|
+
region {
|
|
230
|
+
region
|
|
231
|
+
region_code
|
|
232
|
+
region_id
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}`;export{V as C,D as a,q as b,R as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@dropins/tools/preact-compat.js";import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{classes as c}from"@dropins/tools/lib.js";import{IllustratedMessage as s,Icon as i,Button as l}from"@dropins/tools/components.js";/* empty css */import{useText as m}from"@dropins/tools/i18n.js";const p=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("g",{clipPath:"url(#clip0_102_196)"},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),e.createElement("defs",null,e.createElement("clipPath",{id:"clip0_102_196"},e.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),k=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("g",{clipPath:"url(#clip0_4797_15331)"},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),e.createElement("defs",null,e.createElement("clipPath",{id:"clip0_4797_15331"},e.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),C=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),L=({className:t,children:d,ctaLinkURL:o,...a})=>{const n=m({emptyCart:"Cart.EmptyCart.heading",cta:"Cart.EmptyCart.cta"});return r("div",{...a,className:c(["cart-empty-cart",t]),children:r(s,{className:c(["cart-empty-cart__wrapper",t]),"data-testid":"cart-empty-cart",heading:n.emptyCart,icon:r(i,{className:"cart-empty-cart__icon",source:p}),action:o?r(l,{"data-testid":"cart-empty-cart-button",size:"medium",variant:"primary",type:"submit",href:o,children:n.cta},"routeHome"):void 0})})};export{L as E,k as S,C as a};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{s as a,f as u,h as l}from"./resetCart.js";import{events as p}from"@dropins/tools/event-bus.js";const h=e=>{var r,o,t;return{countryCode:e.country_code||"US",postCode:e.postcode||"",region:((r=e.region)==null?void 0:r.region)||"",regionCode:((o=e.region)==null?void 0:o.code)||"",regionId:((t=e.region)==null?void 0:t.id)||0}},m=e=>e?{carrierCode:e.carrier_code||"",methodCode:e.method_code||"",amount:e.amount,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}:null,g=`
|
|
2
|
+
query COUNTRIES_QUERY {
|
|
3
|
+
countries {
|
|
4
|
+
label: full_name_locale
|
|
5
|
+
id
|
|
6
|
+
}
|
|
7
|
+
storeConfig {
|
|
8
|
+
defaultCountry: default_country
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`,f=`
|
|
12
|
+
query REGIONS_QUERY($id: String) {
|
|
13
|
+
country(id: $id) {
|
|
14
|
+
available_regions {
|
|
15
|
+
code
|
|
16
|
+
name
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`,y=`
|
|
21
|
+
mutation ESTIMATE_SHIPPING_METHODS_MUTATION(
|
|
22
|
+
$cartId: String!
|
|
23
|
+
$address: EstimateAddressInput!
|
|
24
|
+
) {
|
|
25
|
+
estimateShippingMethods(
|
|
26
|
+
input: {
|
|
27
|
+
cart_id: $cartId
|
|
28
|
+
address: $address
|
|
29
|
+
}
|
|
30
|
+
) {
|
|
31
|
+
amount {
|
|
32
|
+
currency
|
|
33
|
+
value
|
|
34
|
+
}
|
|
35
|
+
carrier_code
|
|
36
|
+
method_code
|
|
37
|
+
error_message
|
|
38
|
+
price_excl_tax {
|
|
39
|
+
currency
|
|
40
|
+
value
|
|
41
|
+
}
|
|
42
|
+
price_incl_tax {
|
|
43
|
+
currency
|
|
44
|
+
value
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`,C=async e=>{const r=a.cartId;if(!r)throw new Error("No cart ID found");if(!e)throw new Error("No address parameter found");const{countryCode:o,postcode:t,region:n}=e,i={country_code:o||"US",postcode:t||"",region:{region:(n==null?void 0:n.region)||"",region_code:(n==null?void 0:n.code)||"",region_id:(n==null?void 0:n.id)||0}};return u(y,{variables:{cartId:r,address:i}}).then(({errors:c,data:s})=>{if(c)return l(c);const d=s.estimateShippingMethods.find(_=>!_.error_message)||null;return p.emit("shipping/estimate",{address:h(i),shippingMethod:m(d)}),d})},x=async()=>u(g,{}).then(({errors:e,data:r})=>{var n,i;if(e)return l(e);const o=((n=r==null?void 0:r.countries)==null?void 0:n.sort((c,s)=>c.label.localeCompare(s.label)))||[],t=((i=r==null?void 0:r.storeConfig)==null?void 0:i.defaultCountry)||"US";return o.forEach(c=>{c.isDefaultCountry=c.id===t}),o}),T=async e=>u(f,{variables:{id:e}}).then(({errors:r,data:o})=>{var t;return r?l(r):((t=o==null?void 0:o.country)==null?void 0:t.available_regions)||[]});export{x as a,T as b,C as g};
|
|
@@ -1,56 +1,9 @@
|
|
|
1
|
-
import{s as
|
|
2
|
-
mutation ESTIMATE_SHIPPING_METHODS_MUTATION(
|
|
3
|
-
$cartId: String!
|
|
4
|
-
$address: EstimateAddressInput!
|
|
5
|
-
) {
|
|
6
|
-
estimateShippingMethods(
|
|
7
|
-
input: {
|
|
8
|
-
cart_id: $cartId
|
|
9
|
-
address: $address
|
|
10
|
-
}
|
|
11
|
-
) {
|
|
12
|
-
amount {
|
|
13
|
-
currency
|
|
14
|
-
value
|
|
15
|
-
}
|
|
16
|
-
carrier_code
|
|
17
|
-
method_code
|
|
18
|
-
error_message
|
|
19
|
-
price_excl_tax {
|
|
20
|
-
currency
|
|
21
|
-
value
|
|
22
|
-
}
|
|
23
|
-
price_incl_tax {
|
|
24
|
-
currency
|
|
25
|
-
value
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`,g=`
|
|
30
|
-
query COUNTRIES_QUERY {
|
|
31
|
-
countries {
|
|
32
|
-
label: full_name_locale
|
|
33
|
-
id
|
|
34
|
-
}
|
|
35
|
-
storeConfig {
|
|
36
|
-
defaultCountry: default_country
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
`,f=`
|
|
40
|
-
query REGIONS_QUERY($id: String) {
|
|
41
|
-
country(id: $id) {
|
|
42
|
-
available_regions {
|
|
43
|
-
code
|
|
44
|
-
name
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`,N=async r=>{const t=l.cartId;if(!t)throw new Error("No cart ID found");if(!r)throw new Error("No address parameter found");const{countryCode:o,postcode:n,region:e}=r;return d(I,{variables:{cartId:t,address:{country_code:o||"US",postcode:n||"",region:{region:(e==null?void 0:e.region)||"",region_code:(e==null?void 0:e.code)||"",region_id:(e==null?void 0:e.id)||0}}}}).then(({errors:i,data:s})=>{if(i)return u(i);const c=s.estimateShippingMethods;return c.length===0?null:c.find(a=>!a.error_message)})},M=async()=>d(g,{}).then(({errors:r,data:t})=>{var e,i;if(r)return u(r);const o=((e=t==null?void 0:t.countries)==null?void 0:e.sort((s,c)=>s.label.localeCompare(c.label)))||[],n=((i=t==null?void 0:t.storeConfig)==null?void 0:i.defaultCountry)||"US";return o.forEach(s=>{s.isDefaultCountry=s.id===n}),o}),U=async r=>d(f,{variables:{id:r}}).then(({errors:t,data:o})=>{var n;return t?u(t):((n=o==null?void 0:o.country)==null?void 0:n.available_regions)||[]}),S=`
|
|
1
|
+
import{s as h,f as m,h as T}from"./resetCart.js";import{C as E,a as I,t as g}from"./CartFragment.js";import"@dropins/tools/event-bus.js";const u=`
|
|
49
2
|
mutation GET_ESTIMATED_TOTALS_MUTATION(
|
|
50
3
|
$cartId: String!
|
|
51
4
|
$address: EstimateAddressInput!,
|
|
52
5
|
$shipping_method: ShippingMethodInput,
|
|
53
|
-
${
|
|
6
|
+
${E}
|
|
54
7
|
|
|
55
8
|
) {
|
|
56
9
|
estimateTotals(
|
|
@@ -65,5 +18,5 @@ query REGIONS_QUERY($id: String) {
|
|
|
65
18
|
}
|
|
66
19
|
}
|
|
67
20
|
}
|
|
68
|
-
${
|
|
69
|
-
|
|
21
|
+
${I}
|
|
22
|
+
`,M=async o=>{var e,a;const r=h.cartId;if(!r)throw new Error("No cart ID found");if(!o)throw new Error("No address parameter found");const{countryCode:i,postcode:n,region:t}=o,c=(e=o.shipping_method)==null?void 0:e.carrier_code,p=(a=o.shipping_method)==null?void 0:a.method_code;return m(u,{variables:{cartId:r,address:{country_code:i||"US",postcode:n||"00000",region:{region:(t==null?void 0:t.region)||"region",region_code:(t==null?void 0:t.code)||"regionCode",region_id:(t==null?void 0:t.id)||0}},shipping_method:{carrier_code:c||"",method_code:p||""}}}).then(({errors:d,data:_})=>{if(d)return T(d);const s=_.estimateTotals;return s?g(s.cart):null})};export{M as g};
|
package/chunks/getStoreConfig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{events as
|
|
1
|
+
import{events as e}from"@dropins/tools/event-bus.js";import{s as a,d as y,e as f,f as s,h as o}from"./resetCart.js";import{C as u,a as l,b as m,t as p}from"./CartFragment.js";import{Initializer as C}from"@dropins/tools/lib.js";const d=new C({init:async t=>{const r={disableGuestCart:!1,...t};d.config.setConfig(r),c().catch(console.error)},listeners:()=>[e.on("authenticated",t=>{a.authenticated&&!t?e.emit("cart/reset",void 0):t&&!a.authenticated&&(a.authenticated=t,c().catch(console.error))},{eager:!0}),e.on("locale",async t=>{t!==a.locale&&(a.locale=t,c().catch(console.error))}),e.on("cart/reset",()=>{y().catch(console.error),e.emit("cart/data",null)}),e.on("cart/data",t=>{f(t)})]}),h=d.config;function T(t){if(!t)return null;const r=i=>{switch(i){case 1:return"EXCLUDING_TAX";case 2:return"INCLUDING_TAX";case 3:return"INCLUDING_EXCLUDING_TAX";default:return"EXCLUDING_TAX"}};return{displayMiniCart:t.minicart_display,miniCartMaxItemsDisplay:t.minicart_max_items,cartExpiresInDays:t.cart_expires_in_days,cartSummaryDisplayTotal:t.cart_summary_display_quantity,defaultCountry:t.default_country,categoryFixedProductTaxDisplaySetting:t.category_fixed_product_tax_display_setting,productFixedProductTaxDisplaySetting:t.product_fixed_product_tax_display_setting,salesFixedProductTaxDisplaySetting:t.sales_fixed_product_tax_display_setting,shoppingCartDisplaySetting:{zeroTax:t.shopping_cart_display_zero_tax,subtotal:r(t.shopping_cart_display_subtotal),price:r(t.shopping_cart_display_price),shipping:r(t.shopping_cart_display_shipping),fullSummary:t.shopping_cart_display_full_summary,grandTotal:t.shopping_cart_display_grand_total,taxGiftWrapping:t.shopping_cart_display_tax_gift_wrapping},useConfigurableParentThumbnail:t.configurable_thumbnail_source==="parent"}}const x=`
|
|
2
2
|
query GUEST_CART_QUERY(
|
|
3
3
|
$cartId: String!,
|
|
4
4
|
${u}
|
|
@@ -14,7 +14,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
|
|
|
14
14
|
query CUSTOMER_CART_QUERY(
|
|
15
15
|
${u}
|
|
16
16
|
) {
|
|
17
|
-
${
|
|
17
|
+
${m}
|
|
18
18
|
|
|
19
19
|
cart: customerCart {
|
|
20
20
|
...CartFragment
|
|
@@ -22,7 +22,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
${l}
|
|
25
|
-
`,_=async()=>{const t=a.authenticated,r=a.cartId;if(t)return s(I,{method:"POST"}).then(({errors:
|
|
25
|
+
`,_=async()=>{const t=a.authenticated,r=a.cartId;if(t)return s(I,{method:"POST"}).then(({errors:i,data:n})=>{if(i)return o(i);const g={...n.cart,...n.customer};return p(g)});if(!r)throw new Error("No cart ID found");return s(x,{method:"POST",cache:"no-cache",variables:{cartId:r}}).then(({errors:i,data:n})=>i?o(i):p(n.cart))},E=`
|
|
26
26
|
mutation MERGE_CARTS_MUTATION(
|
|
27
27
|
$guestCartId: String!,
|
|
28
28
|
$customerCartId: String!,
|
|
@@ -37,7 +37,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
${l}
|
|
40
|
-
`,c=async()=>{a.config=await A();const t=a.authenticated?await S():await R();return
|
|
40
|
+
`,c=async()=>{if(a.initializing)return null;a.initializing=!0,a.config=await A();const t=a.authenticated?await S():await R();return e.emit("cart/initialized",t),e.emit("cart/data",t),a.initializing=!1,t};async function S(){const t=a.cartId,r=await _();return r?(a.cartId=r.id,!t||r.id===t?r:await s(E,{variables:{guestCartId:t,customerCartId:r.id}}).then(()=>_()).then(i=>{const n={oldCartItems:r.items,newCart:i};return e.emit("cart/merged",n),i}).catch(()=>(console.error("Could not merge carts"),r))):null}async function R(){if(h.getConfig().disableGuestCart===!0||!a.cartId)return null;try{return await _()}catch(t){return console.error(t),null}}const G=`
|
|
41
41
|
query STORE_CONFIG_QUERY {
|
|
42
42
|
storeConfig {
|
|
43
43
|
minicart_display
|