ui.shipaid.com 0.3.46 → 0.3.48
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/dist/nl-CI8lUOMC.js +41 -0
- package/dist/widget.es.js +231 -72
- package/dist/widget.iife.js +44 -44
- package/dist/widget.umd.js +44 -44
- package/dist-types/widget/src/shipaid-widget.d.ts +19 -2
- package/package.json +3 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const loading = "Laad ShipAid Widget...";
|
|
2
|
+
const title = "Bezorggarantie";
|
|
3
|
+
const description = "in geval van verlies, schade of diefstal";
|
|
4
|
+
const footer = {
|
|
5
|
+
button: "Aangedreven door"
|
|
6
|
+
};
|
|
7
|
+
const actions = {
|
|
8
|
+
add: "Toevoegen",
|
|
9
|
+
remove: "Verwijderen",
|
|
10
|
+
loading: "Bezig met laden..."
|
|
11
|
+
};
|
|
12
|
+
const nl = {
|
|
13
|
+
loading,
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
footer,
|
|
17
|
+
actions,
|
|
18
|
+
"learn-more-popup": {
|
|
19
|
+
close: "Sluiten",
|
|
20
|
+
title: "Bezorggarantie",
|
|
21
|
+
disclaimer: {
|
|
22
|
+
"subtitle-enable": "We stellen je favoriete merken in staat om een bezorggarantie te bieden omdat we weten dat elke bestelling belangrijk is en dingen kunnen gebeuren!",
|
|
23
|
+
"subtitle-monitor": "We monitoren je pakket continu en bieden een handig portaal om de voortgang van je bestelling op elk moment te volgen!",
|
|
24
|
+
"subtitle-notify": "Je wordt gedurende het gehele verzendproces op de hoogte gehouden, zodat je altijd op de hoogte bent van elke stap.",
|
|
25
|
+
"subtitle-resolution": "In geval van problemen tijdens het transport bieden we een snelle en gemakkelijke manier om het probleem direct bij het merk te melden, voor een snelle oplossing.",
|
|
26
|
+
text: "Door deze bezorggarantie aan te schaffen, ga je akkoord met onze Servicevoorwaarden en Privacybeleid. Je bent niet verplicht om deze garantie aan te schaffen. Deze garantie is GEEN verzekering en biedt geen schadevergoeding voor verlies, schade of aansprakelijkheid als gevolg van een onvoorziene of onbekende gebeurtenis, maar biedt via ShipAid een bezorggarantie waarbij, als het product dat je hebt besteld niet in bevredigende staat wordt geleverd, het merk van wie je het product hebt besteld, het product gratis kan vervangen. ShipAid levert geen producten of diensten direct aan consumenten, maar biedt een dienst die merken in staat stelt om productvervanging aan hun klanten te faciliteren. Het kopen van deze garantie betekent niet automatisch dat je wordt vergoed voor product- of verzendkosten, aangezien het oplossingproces en de beslissing voor compensatie strikt wordt bepaald door het merk van wie je koopt. Het merk zal bewijs van schade of niet-geleverde producten vereisen."
|
|
27
|
+
},
|
|
28
|
+
links: {
|
|
29
|
+
terms: "Servicevoorwaarden",
|
|
30
|
+
privacy: "Privacybeleid"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
actions,
|
|
36
|
+
nl as default,
|
|
37
|
+
description,
|
|
38
|
+
footer,
|
|
39
|
+
loading,
|
|
40
|
+
title
|
|
41
|
+
};
|
package/dist/widget.es.js
CHANGED
|
@@ -1960,6 +1960,23 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
1960
1960
|
if (result) __defProp(target, key, result);
|
|
1961
1961
|
return result;
|
|
1962
1962
|
};
|
|
1963
|
+
const formatCartDataItems = (cart) => {
|
|
1964
|
+
const formattedCartWithItems = {
|
|
1965
|
+
items: cart.lines.edges.map(({ node: l2 }) => {
|
|
1966
|
+
return {
|
|
1967
|
+
id: l2.id,
|
|
1968
|
+
key: l2.id,
|
|
1969
|
+
variant_id: l2.merchandise.id,
|
|
1970
|
+
sku: l2.merchandise.sku,
|
|
1971
|
+
final_line_price: parseFloat(l2.cost.totalAmount.amount),
|
|
1972
|
+
quantity: l2.quantity
|
|
1973
|
+
};
|
|
1974
|
+
}),
|
|
1975
|
+
total_price: parseFloat(cart.cost.totalAmount.amount),
|
|
1976
|
+
item_count: cart.lines.edges.length
|
|
1977
|
+
};
|
|
1978
|
+
return formattedCartWithItems;
|
|
1979
|
+
};
|
|
1963
1980
|
const runRequest = async (input, init) => {
|
|
1964
1981
|
try {
|
|
1965
1982
|
const response = await fetch(input, init);
|
|
@@ -2004,6 +2021,7 @@ const langFiles = /* @__PURE__ */ Object.assign({
|
|
|
2004
2021
|
"./lang/es.json": () => import("./es-gSoKNDaV.js").then((m2) => m2["default"]),
|
|
2005
2022
|
"./lang/fr.json": () => import("./fr-B4wOlIrE.js").then((m2) => m2["default"]),
|
|
2006
2023
|
"./lang/it.json": () => import("./it-1qLegqAS.js").then((m2) => m2["default"]),
|
|
2024
|
+
"./lang/nl.json": () => import("./nl-CI8lUOMC.js").then((m2) => m2["default"]),
|
|
2007
2025
|
"./lang/pt.json": () => import("./pt-CeUvCcpv.js").then((m2) => m2["default"])
|
|
2008
2026
|
});
|
|
2009
2027
|
registerTranslateConfig({
|
|
@@ -2017,6 +2035,11 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2017
2035
|
constructor() {
|
|
2018
2036
|
var _a, _b, _c;
|
|
2019
2037
|
super(...arguments);
|
|
2038
|
+
this.env = "prod";
|
|
2039
|
+
this.useCustomStoreFront = false;
|
|
2040
|
+
this.storeDomain = "";
|
|
2041
|
+
this.storeAccessToken = "";
|
|
2042
|
+
this.cartId = "";
|
|
2020
2043
|
this.disablePolling = false;
|
|
2021
2044
|
this.disableActions = false;
|
|
2022
2045
|
this.pollingInterval = POLL_INTERVAL_DEFAULT;
|
|
@@ -2036,7 +2059,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2036
2059
|
this.hasLoadedStrings = false;
|
|
2037
2060
|
this.fetchInterceptorCleanup = () => {
|
|
2038
2061
|
};
|
|
2039
|
-
this.intervalId =
|
|
2062
|
+
this.intervalId = null;
|
|
2040
2063
|
this._state = {
|
|
2041
2064
|
loading: false,
|
|
2042
2065
|
success: null,
|
|
@@ -2064,6 +2087,61 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2064
2087
|
localStorage.setItem(`${LOCAL_STORAGE_SHIPAID_POPUP_KEY}`, "true");
|
|
2065
2088
|
}
|
|
2066
2089
|
}
|
|
2090
|
+
get nhost() {
|
|
2091
|
+
const subdomain = this.env === "prod" ? "gjiyysyzjwuculcymsvb" : this.env === "staging" ? "xfnjpunvafvudwuzwjlm" : "local";
|
|
2092
|
+
const region = "us-east-1";
|
|
2093
|
+
const url = `https://${subdomain}.graphql.${region}.nhost.run/v1`;
|
|
2094
|
+
return {
|
|
2095
|
+
request: async (query, variables) => {
|
|
2096
|
+
try {
|
|
2097
|
+
const response = await fetch(url, {
|
|
2098
|
+
method: "post",
|
|
2099
|
+
body: JSON.stringify({
|
|
2100
|
+
query,
|
|
2101
|
+
variables
|
|
2102
|
+
})
|
|
2103
|
+
});
|
|
2104
|
+
const result = await response.json();
|
|
2105
|
+
return result;
|
|
2106
|
+
} catch (error) {
|
|
2107
|
+
console.log(`Nhost Error: ${error}`);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
/** Runs a GraphQL query and returns the data
|
|
2113
|
+
* @param query GraphQL query string
|
|
2114
|
+
* @param variables Variables for the query
|
|
2115
|
+
* @returns Query response data
|
|
2116
|
+
*/
|
|
2117
|
+
async runStoreFrontQuery(query, variables) {
|
|
2118
|
+
try {
|
|
2119
|
+
const myHeaders = new Headers();
|
|
2120
|
+
myHeaders.append("Content-Type", "application/json");
|
|
2121
|
+
myHeaders.append("X-Shopify-Storefront-Access-Token", this.storeAccessToken);
|
|
2122
|
+
const raw = JSON.stringify({
|
|
2123
|
+
query,
|
|
2124
|
+
variables
|
|
2125
|
+
});
|
|
2126
|
+
const requestOptions = {
|
|
2127
|
+
method: "POST",
|
|
2128
|
+
headers: myHeaders,
|
|
2129
|
+
body: raw
|
|
2130
|
+
};
|
|
2131
|
+
const response = await fetch(`https://${this.storeDomain}/api/2021-07/graphql.json`, requestOptions);
|
|
2132
|
+
if (!response.ok) {
|
|
2133
|
+
throw new Error(`GraphQL request failed: ${response.statusText}`);
|
|
2134
|
+
}
|
|
2135
|
+
const json = await response.json();
|
|
2136
|
+
if (json.errors) {
|
|
2137
|
+
throw new Error(json.errors[0].message);
|
|
2138
|
+
}
|
|
2139
|
+
return json.data;
|
|
2140
|
+
} catch (error) {
|
|
2141
|
+
console.error("GraphQL query error:", error);
|
|
2142
|
+
throw new Error("Failed to execute GraphQL query");
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2067
2145
|
/** Getter to check if we should refresh the page or not */
|
|
2068
2146
|
get shouldRefreshOnUpdate() {
|
|
2069
2147
|
if (this.disablePolling) return false;
|
|
@@ -2171,25 +2249,36 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2171
2249
|
/** Fetches store info from the ShipAid public API. */
|
|
2172
2250
|
async _fetchShipAidData() {
|
|
2173
2251
|
var _a, _b, _c, _d, _e;
|
|
2174
|
-
|
|
2252
|
+
let shop;
|
|
2253
|
+
if (this.storeDomain) {
|
|
2254
|
+
shop = this.storeDomain;
|
|
2255
|
+
} else {
|
|
2256
|
+
shop = ((_a = window.Shopify) == null ? void 0 : _a.shop) ?? ((_c = (_b = window.Shopify) == null ? void 0 : _b.Checkout) == null ? void 0 : _c.apiHost);
|
|
2257
|
+
}
|
|
2175
2258
|
if (!shop) throw new Error("No shop found in Shopify object.");
|
|
2176
2259
|
try {
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2260
|
+
let endpoint;
|
|
2261
|
+
let result;
|
|
2262
|
+
if (this.useCustomStoreFront) {
|
|
2263
|
+
result = await this.nhost.request(StoreQuery, { store: shop });
|
|
2264
|
+
} else {
|
|
2265
|
+
endpoint = new URL(window.location.href);
|
|
2266
|
+
endpoint.pathname = this._apiEndpoint;
|
|
2267
|
+
const payload = {
|
|
2268
|
+
query: StoreQuery,
|
|
2269
|
+
variables: { store: shop }
|
|
2270
|
+
};
|
|
2271
|
+
result = await this._fetch.post(
|
|
2272
|
+
endpoint.toString(),
|
|
2273
|
+
payload
|
|
2274
|
+
);
|
|
2275
|
+
}
|
|
2276
|
+
if (!result) throw new Error("Missing response for store query.");
|
|
2277
|
+
if ((_d = result.errors) == null ? void 0 : _d.length) throw new Error(result.errors[0].message);
|
|
2278
|
+
if (!((_e = result.data) == null ? void 0 : _e.store)) {
|
|
2190
2279
|
throw new Error("Missing store from store query response.");
|
|
2191
2280
|
}
|
|
2192
|
-
return
|
|
2281
|
+
return result.data.store;
|
|
2193
2282
|
} catch (error) {
|
|
2194
2283
|
console.error(error);
|
|
2195
2284
|
throw new Error(`Could not find a store for ${this._storeDomain}`);
|
|
@@ -2239,6 +2328,14 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2239
2328
|
/** Fetch current cart from the Shopify ajax API */
|
|
2240
2329
|
async _fetchCart() {
|
|
2241
2330
|
try {
|
|
2331
|
+
if (this.useCustomStoreFront && this.cartId) {
|
|
2332
|
+
const result = await this.runStoreFrontQuery(
|
|
2333
|
+
"query getCart($cartId: ID!){ cart( id: $cartId ) { id createdAt updatedAt lines(first: 10) { edges { node { id quantity merchandise { ... on ProductVariant { id sku } } cost{ totalAmount{ amount currencyCode } } } } } cost { totalAmount { amount currencyCode } subtotalAmount { amount currencyCode } } } }",
|
|
2334
|
+
{ cartId: this.cartId }
|
|
2335
|
+
);
|
|
2336
|
+
const cart2 = formatCartDataItems(result.cart);
|
|
2337
|
+
return cart2;
|
|
2338
|
+
}
|
|
2242
2339
|
const cart = await this._fetch.get("/cart.js");
|
|
2243
2340
|
return cart;
|
|
2244
2341
|
} catch (err) {
|
|
@@ -2249,10 +2346,32 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2249
2346
|
}
|
|
2250
2347
|
/** Fetch current product from the Shopify ajax API */
|
|
2251
2348
|
async _fetchProduct() {
|
|
2349
|
+
var _a, _b;
|
|
2252
2350
|
try {
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2351
|
+
let product;
|
|
2352
|
+
if (this.useCustomStoreFront) {
|
|
2353
|
+
const result = await this.runStoreFrontQuery(
|
|
2354
|
+
"query searchProducts($query: String!, $first: Int) { search(query: $query, first: $first, types: PRODUCT) { edges { node { ... on Product { id title handle variants(first: 1) { edges { node { id title price { amount } } } } } } } } }",
|
|
2355
|
+
{
|
|
2356
|
+
query: "ShipAid Delivery Guarantee",
|
|
2357
|
+
first: 1
|
|
2358
|
+
}
|
|
2359
|
+
);
|
|
2360
|
+
if ((_b = (_a = result == null ? void 0 : result.search) == null ? void 0 : _a.edges) == null ? void 0 : _b.length) {
|
|
2361
|
+
const protectionProductItem = result.search.edges[0];
|
|
2362
|
+
product = {
|
|
2363
|
+
id: protectionProductItem.node.id,
|
|
2364
|
+
variants: protectionProductItem.node.variants.edges.map((v2) => ({
|
|
2365
|
+
id: v2.node.id,
|
|
2366
|
+
price: v2.node.price.amount
|
|
2367
|
+
}))
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
} else {
|
|
2371
|
+
product = (await this._fetch.get(
|
|
2372
|
+
`/products/${PRODUCT_HANDLE}.json`
|
|
2373
|
+
)).product;
|
|
2374
|
+
}
|
|
2256
2375
|
return product;
|
|
2257
2376
|
} catch (err) {
|
|
2258
2377
|
const error = err;
|
|
@@ -2270,6 +2389,77 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2270
2389
|
if (!cart) cart = await this._fetchCart();
|
|
2271
2390
|
this._cart = cart;
|
|
2272
2391
|
}
|
|
2392
|
+
async addCartProtectionVariant() {
|
|
2393
|
+
var _a, _b, _c, _d;
|
|
2394
|
+
let cart;
|
|
2395
|
+
let sellingPlanId;
|
|
2396
|
+
if (this.supportSubscriptions) {
|
|
2397
|
+
const itemWithSubscription = (_b = (_a = this._cart) == null ? void 0 : _a.items) == null ? void 0 : _b.find((item) => {
|
|
2398
|
+
var _a2;
|
|
2399
|
+
return item.id !== ((_a2 = this._protectionVariant) == null ? void 0 : _a2.id) && !!(item == null ? void 0 : item.selling_plan_allocation);
|
|
2400
|
+
});
|
|
2401
|
+
if (itemWithSubscription) {
|
|
2402
|
+
const protectionSellingPlan = await this._fetchSellingPlanFromVariant(itemWithSubscription.selling_plan_allocation.selling_plan);
|
|
2403
|
+
sellingPlanId = protectionSellingPlan ? getIdFromShopifyGid(protectionSellingPlan.id) : null;
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
if (this.useCustomStoreFront) {
|
|
2407
|
+
const cartItemAdded = await this.runStoreFrontQuery(
|
|
2408
|
+
"mutation AddItemToCart($cartId: ID!, $lines: [CartLineInput!]!) { cartLinesAdd(cartId: $cartId, lines: $lines) { cart { id lines(first: 10) { edges { node { id quantity merchandise { ... on ProductVariant { id sku } } cost{ totalAmount{ amount currencyCode } } } } } cost { totalAmount { amount currencyCode } subtotalAmount { amount currencyCode } } } } }",
|
|
2409
|
+
{
|
|
2410
|
+
cartId: this.cartId,
|
|
2411
|
+
lines: [{
|
|
2412
|
+
merchandiseId: String((_c = this._protectionVariant) == null ? void 0 : _c.id),
|
|
2413
|
+
quantity: 1,
|
|
2414
|
+
sellingPlanId
|
|
2415
|
+
}]
|
|
2416
|
+
}
|
|
2417
|
+
);
|
|
2418
|
+
cart = formatCartDataItems(cartItemAdded.cartLinesAdd.cart);
|
|
2419
|
+
} else {
|
|
2420
|
+
const payload = {
|
|
2421
|
+
quantity: 1,
|
|
2422
|
+
id: String((_d = this._protectionVariant) == null ? void 0 : _d.id),
|
|
2423
|
+
selling_plan: sellingPlanId
|
|
2424
|
+
};
|
|
2425
|
+
cart = await this._fetch.post(
|
|
2426
|
+
"/cart/add.js",
|
|
2427
|
+
payload
|
|
2428
|
+
);
|
|
2429
|
+
}
|
|
2430
|
+
return cart;
|
|
2431
|
+
}
|
|
2432
|
+
async updateCartProtectionVariant(qty, protectionCartItem = null, sellingPlanId = null) {
|
|
2433
|
+
var _a, _b;
|
|
2434
|
+
let cart;
|
|
2435
|
+
if (this.useCustomStoreFront) {
|
|
2436
|
+
const cartItemUpdated = await this.runStoreFrontQuery(
|
|
2437
|
+
"mutation RemoveItemToCart($cartId: ID!, $lines: [CartLineUpdateInput!]!) { cartLinesUpdate(cartId: $cartId, lines: $lines) { cart { id lines(first: 10) { edges { node { id quantity merchandise { ... on ProductVariant { id sku } } cost{ totalAmount{ amount currencyCode } } } } } cost { totalAmount { amount currencyCode } subtotalAmount { amount currencyCode } } } } }",
|
|
2438
|
+
{
|
|
2439
|
+
cartId: this.cartId,
|
|
2440
|
+
lines: [
|
|
2441
|
+
{
|
|
2442
|
+
id: String(protectionCartItem ? protectionCartItem.key : (_a = this._protectionCartItem) == null ? void 0 : _a.key),
|
|
2443
|
+
quantity: qty,
|
|
2444
|
+
sellingPlanId
|
|
2445
|
+
}
|
|
2446
|
+
]
|
|
2447
|
+
}
|
|
2448
|
+
);
|
|
2449
|
+
cart = formatCartDataItems(cartItemUpdated.cartLinesUpdate.cart);
|
|
2450
|
+
} else {
|
|
2451
|
+
const payload = {
|
|
2452
|
+
quantity: qty,
|
|
2453
|
+
id: String(protectionCartItem ? protectionCartItem.key : (_b = this._protectionCartItem) == null ? void 0 : _b.key),
|
|
2454
|
+
selling_plan: sellingPlanId
|
|
2455
|
+
};
|
|
2456
|
+
cart = await this._fetch.post(
|
|
2457
|
+
"/cart/change.js",
|
|
2458
|
+
payload
|
|
2459
|
+
);
|
|
2460
|
+
}
|
|
2461
|
+
return cart;
|
|
2462
|
+
}
|
|
2273
2463
|
/** Add ShipAid shipping protection. */
|
|
2274
2464
|
async addProtection() {
|
|
2275
2465
|
var _a, _b;
|
|
@@ -2280,26 +2470,8 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2280
2470
|
throw new Error("No protection variant found.");
|
|
2281
2471
|
}
|
|
2282
2472
|
this._setState("loading");
|
|
2283
|
-
const
|
|
2284
|
-
|
|
2285
|
-
id: this._protectionVariant.id
|
|
2286
|
-
};
|
|
2287
|
-
if (this.supportSubscriptions) {
|
|
2288
|
-
const itemWithSubscription = this._cart.items.find((item) => {
|
|
2289
|
-
var _a2;
|
|
2290
|
-
return item.id !== ((_a2 = this._protectionVariant) == null ? void 0 : _a2.id) && !!(item == null ? void 0 : item.selling_plan_allocation);
|
|
2291
|
-
});
|
|
2292
|
-
if (itemWithSubscription) {
|
|
2293
|
-
const protectionSellingPlan = await this._fetchSellingPlanFromVariant(itemWithSubscription.selling_plan_allocation.selling_plan);
|
|
2294
|
-
const sellingPlanId = protectionSellingPlan ? getIdFromShopifyGid(protectionSellingPlan.id) : null;
|
|
2295
|
-
payload.selling_plan = sellingPlanId;
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
const cartItem = await this._fetch.post(
|
|
2299
|
-
"/cart/add.js",
|
|
2300
|
-
payload
|
|
2301
|
-
);
|
|
2302
|
-
await this._handleRefresh(cartItem);
|
|
2473
|
+
const cart = await this.addCartProtectionVariant();
|
|
2474
|
+
await this._handleRefresh(cart);
|
|
2303
2475
|
this._setState("success");
|
|
2304
2476
|
} catch (err) {
|
|
2305
2477
|
const error = err;
|
|
@@ -2317,14 +2489,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2317
2489
|
throw new Error("Protection product not found.");
|
|
2318
2490
|
}
|
|
2319
2491
|
this._setState("loading");
|
|
2320
|
-
const
|
|
2321
|
-
quantity: 0,
|
|
2322
|
-
id: this._protectionCartItem.key
|
|
2323
|
-
};
|
|
2324
|
-
const cart = await this._fetch.post(
|
|
2325
|
-
"/cart/change.js",
|
|
2326
|
-
payload
|
|
2327
|
-
);
|
|
2492
|
+
const cart = await this.updateCartProtectionVariant(0, this._protectionCartItem);
|
|
2328
2493
|
await this._handleRefresh(cart);
|
|
2329
2494
|
this._cart = cart;
|
|
2330
2495
|
this._setState("success");
|
|
@@ -2382,14 +2547,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2382
2547
|
);
|
|
2383
2548
|
});
|
|
2384
2549
|
const protectionCartItem = (_e = this._cart) == null ? void 0 : _e.items[protectionCartItemIndex];
|
|
2385
|
-
const
|
|
2386
|
-
id: protectionCartItem.key,
|
|
2387
|
-
quantity: 0
|
|
2388
|
-
};
|
|
2389
|
-
const cart = await this._fetch.post(
|
|
2390
|
-
"/cart/change.js",
|
|
2391
|
-
removePayload
|
|
2392
|
-
);
|
|
2550
|
+
const cart = await this.updateCartProtectionVariant(0, protectionCartItem);
|
|
2393
2551
|
return await this._handleRefresh(cart);
|
|
2394
2552
|
}
|
|
2395
2553
|
}
|
|
@@ -2579,14 +2737,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2579
2737
|
if (!this._store) return;
|
|
2580
2738
|
const protectionFee = await this.calculateProtectionTotal(this._cart);
|
|
2581
2739
|
if (this._cart.item_count > 0 && !!protectionCartItem && (this._cart.total_price === (protectionCartItem == null ? void 0 : protectionCartItem.final_line_price) || !protectionFee)) {
|
|
2582
|
-
const
|
|
2583
|
-
id: protectionCartItem.key,
|
|
2584
|
-
quantity: 0
|
|
2585
|
-
};
|
|
2586
|
-
const cart2 = await this._fetch.post(
|
|
2587
|
-
"/cart/change.js",
|
|
2588
|
-
removePayload
|
|
2589
|
-
);
|
|
2740
|
+
const cart2 = await this.updateCartProtectionVariant(0, protectionCartItem);
|
|
2590
2741
|
sessionStorage.removeItem(LOCAL_STORAGE_KEY);
|
|
2591
2742
|
return await this._handleRefresh(cart2);
|
|
2592
2743
|
}
|
|
@@ -2624,7 +2775,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2624
2775
|
updateSubscriptionPayload = { id: protectionCartItem.key, quantity: 1, selling_plan: sellingPlanId };
|
|
2625
2776
|
}
|
|
2626
2777
|
if (updateSubscriptionPayload) {
|
|
2627
|
-
const cart2 = await this.
|
|
2778
|
+
const cart2 = await this.updateCartProtectionVariant(updateSubscriptionPayload.quantity, protectionCartItem, updateSubscriptionPayload.selling_plan);
|
|
2628
2779
|
await this._handleRefresh(cart2);
|
|
2629
2780
|
}
|
|
2630
2781
|
}
|
|
@@ -2635,14 +2786,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2635
2786
|
position: protectionCartItemIndex + 1
|
|
2636
2787
|
};
|
|
2637
2788
|
if (protectionCartItem.quantity === 1) return;
|
|
2638
|
-
const
|
|
2639
|
-
id: protectionCartItem.key,
|
|
2640
|
-
quantity: 1
|
|
2641
|
-
};
|
|
2642
|
-
const cart2 = await this._fetch.post(
|
|
2643
|
-
"/cart/change.js",
|
|
2644
|
-
updatePayload2
|
|
2645
|
-
);
|
|
2789
|
+
const cart2 = await this.updateCartProtectionVariant(1, protectionCartItem);
|
|
2646
2790
|
this._handleRefreshCart();
|
|
2647
2791
|
return await this._handleRefresh(cart2);
|
|
2648
2792
|
}
|
|
@@ -3043,6 +3187,21 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3043
3187
|
};
|
|
3044
3188
|
_ShipAidWidget.styles = styles;
|
|
3045
3189
|
let ShipAidWidget = _ShipAidWidget;
|
|
3190
|
+
__decorateClass([
|
|
3191
|
+
n$7({ type: String, attribute: true })
|
|
3192
|
+
], ShipAidWidget.prototype, "env");
|
|
3193
|
+
__decorateClass([
|
|
3194
|
+
n$7({ type: Boolean, attribute: true })
|
|
3195
|
+
], ShipAidWidget.prototype, "useCustomStoreFront");
|
|
3196
|
+
__decorateClass([
|
|
3197
|
+
n$7({ type: String, attribute: true })
|
|
3198
|
+
], ShipAidWidget.prototype, "storeDomain");
|
|
3199
|
+
__decorateClass([
|
|
3200
|
+
n$7({ type: String, attribute: true })
|
|
3201
|
+
], ShipAidWidget.prototype, "storeAccessToken");
|
|
3202
|
+
__decorateClass([
|
|
3203
|
+
n$7({ type: String, attribute: true })
|
|
3204
|
+
], ShipAidWidget.prototype, "cartId");
|
|
3046
3205
|
__decorateClass([
|
|
3047
3206
|
n$7({ type: Boolean, attribute: true })
|
|
3048
3207
|
], ShipAidWidget.prototype, "disablePolling");
|