ui.shipaid.com 0.0.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/dist/style.css +1 -0
- package/dist/ui.shipaid.com.es.js +257 -0
- package/package.json +40 -0
- package/types/scss.d.ts +5 -0
- package/types/shipaid.ts +13 -0
- package/types/shopify.ts +84 -0
- package/types/vite-env.d.ts +9 -0
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.shipaid-prompt{--shipaid-primary: #002bd6;--shipaid-secondary: #0076ff;--shipaid-text: #000000;--shipaid-text-muted: #cccccc;--shipaid-text-grey: #aaaaaa;--shipaid-light-grey: #ebecf0;--shipaid-font: "Lato", sans-serif;--shipaid-font-sm: 14px;--shipaid-font-base: 16px;--shipaid-font-lg: 18px;--shipaid-font-regular: 400;--shipaid-font-heavy: 700;width:400px;font-family:var(--shipaid-font);font-size:var(--shipaid-font-base);color:var(--shipaid-text);display:flex;flex-direction:column;gap:1rem;margin:2rem 0 2rem auto}.shipaid-prompt p,.shipaid-prompt a{margin:0;line-height:1}.shipaid-prompt .prompt-title{text-align:center;font-size:var(--shipaid-font-lg);font-weight:var(--shipaid-font-heavy)}.shipaid-prompt .prompt-product{display:flex;flex-direction:row;gap:2rem;height:55px;margin-top:1rem}.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-title{font-size:var(--shipaid-font-base);font-weight:var(--shipaid-font-heavy)}.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-description{font-size:var(--shipaid-font-sm);margin-top:1rem}.shipaid-prompt .prompt-product .prompt-product-actions{margin-left:auto;display:flex;flex-direction:column;justify-content:space-between;text-align:right}.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-price{color:var(--shipaid-text-muted);font-size:var(--shipaid-font-base)}.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-button{background-color:transparent;border:none;color:var(--shipaid-primary);text-transform:uppercase;font-weight:var(--shipaid-font-heavy);cursor:pointer}.shipaid-prompt .prompt-footer{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-top:1rem}.shipaid-prompt .prompt-footer .prompt-footer-about{color:var(--shipaid-text-grey);cursor:pointer;text-decoration:underline;font-size:var(--shipaid-font-sm)}.shipaid-prompt .prompt-footer .prompt-footer-badge{background-color:var(--shipaid-light-grey);color:var(--shipaid-text);padding:.5rem 1.5rem;border-radius:30px;cursor:pointer;text-decoration:none;font-size:var(--shipaid-font-sm)}.shipaid-prompt .prompt-footer .prompt-footer-badge .ship{text-transform:uppercase;color:var(--shipaid-secondary);font-weight:var(--shipaid-font-heavy)}.shipaid-prompt .prompt-footer .prompt-footer-badge .aid{text-transform:uppercase;color:var(--shipaid-text-grey);font-weight:var(--shipaid-font-heavy)}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { state, customElement } from "lit/decorators.js";
|
|
21
|
+
import { LitElement, html } from "lit";
|
|
22
|
+
import { useOnce, useEffect } from "lit-element-effect/effect";
|
|
23
|
+
import { when } from "lit/directives/when.js";
|
|
24
|
+
var styles = '.shipaid-prompt {\n --shipaid-primary: #002bd6;\n --shipaid-secondary: #0076ff;\n --shipaid-text: #000000;\n --shipaid-text-muted: #cccccc;\n --shipaid-text-grey: #aaaaaa;\n --shipaid-light-grey: #ebecf0;\n --shipaid-font: "Lato", sans-serif;\n --shipaid-font-sm: 14px;\n --shipaid-font-base: 16px;\n --shipaid-font-lg: 18px;\n --shipaid-font-regular: 400;\n --shipaid-font-heavy: 700;\n width: 400px;\n font-family: var(--shipaid-font);\n font-size: var(--shipaid-font-base);\n color: var(--shipaid-text);\n display: flex;\n flex-direction: column;\n gap: 1rem;\n margin: 2rem 0 2rem auto;\n}\n.shipaid-prompt p, .shipaid-prompt a {\n margin: 0;\n line-height: 1;\n}\n.shipaid-prompt .prompt-title {\n text-align: center;\n font-size: var(--shipaid-font-lg);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-product {\n display: flex;\n flex-direction: row;\n gap: 2rem;\n height: 55px;\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-title {\n font-size: var(--shipaid-font-base);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-description {\n font-size: var(--shipaid-font-sm);\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-product .prompt-product-actions {\n margin-left: auto;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n text-align: right;\n}\n.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-price {\n color: var(--shipaid-text-muted);\n font-size: var(--shipaid-font-base);\n}\n.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-button {\n background-color: transparent;\n border: none;\n color: var(--shipaid-primary);\n text-transform: uppercase;\n font-weight: var(--shipaid-font-heavy);\n cursor: pointer;\n}\n.shipaid-prompt .prompt-footer {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-footer .prompt-footer-about {\n color: var(--shipaid-text-grey);\n cursor: pointer;\n text-decoration: underline;\n font-size: var(--shipaid-font-sm);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge {\n background-color: var(--shipaid-light-grey);\n color: var(--shipaid-text);\n padding: 0.5rem 1.5rem;\n border-radius: 30px;\n cursor: pointer;\n text-decoration: none;\n font-size: var(--shipaid-font-sm);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge .ship {\n text-transform: uppercase;\n color: var(--shipaid-secondary);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge .aid {\n text-transform: uppercase;\n color: var(--shipaid-text-grey);\n font-weight: var(--shipaid-font-heavy);\n}';
|
|
25
|
+
var __defProp2 = Object.defineProperty;
|
|
26
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
27
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
28
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
29
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
30
|
+
if (decorator = decorators[i])
|
|
31
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
32
|
+
if (kind && result)
|
|
33
|
+
__defProp2(target, key, result);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
const currencyFormat = (value) => {
|
|
37
|
+
var _a, _b, _c, _d, _e;
|
|
38
|
+
return new Intl.NumberFormat((_b = (_a = window.Shopify) == null ? void 0 : _a.locale) != null ? _b : void 0, {
|
|
39
|
+
currency: (_e = (_d = (_c = window.Shopify) == null ? void 0 : _c.currency) == null ? void 0 : _d.active) != null ? _e : "USD",
|
|
40
|
+
style: "currency"
|
|
41
|
+
}).format(value);
|
|
42
|
+
};
|
|
43
|
+
const runRequest = async (input, init) => {
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(input, init);
|
|
46
|
+
if (!response.ok)
|
|
47
|
+
throw new Error(await response.text());
|
|
48
|
+
const data = await response.json();
|
|
49
|
+
return data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(error);
|
|
52
|
+
throw new Error("Failed to complete fetch request.");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
let ShipAidWidget = class extends LitElement {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
var _a;
|
|
59
|
+
this._storeDomain = (_a = window.Shopify) == null ? void 0 : _a.shop;
|
|
60
|
+
this._hasFinishedSetup = false;
|
|
61
|
+
this._hasProtectionInCart = false;
|
|
62
|
+
this._state = {
|
|
63
|
+
loading: false,
|
|
64
|
+
success: null,
|
|
65
|
+
error: false
|
|
66
|
+
};
|
|
67
|
+
this._fetch = {
|
|
68
|
+
get: (url) => runRequest(url),
|
|
69
|
+
post: (url, body) => runRequest(url, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: { "Content-Type": "application/json" },
|
|
72
|
+
body: JSON.stringify(body)
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
render() {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
useOnce(this, async () => {
|
|
79
|
+
var _a2, _b2;
|
|
80
|
+
const [apiData, cartData] = await Promise.all([this._fetchShipAidData(), this._fetchCart()]);
|
|
81
|
+
this._store = apiData;
|
|
82
|
+
this._cart = cartData;
|
|
83
|
+
const isProductInCart = (_b2 = (_a2 = cartData.items) == null ? void 0 : _a2.some((item) => item.variant_id === apiData.productVariantNumericId)) != null ? _b2 : false;
|
|
84
|
+
this._hasProtectionInCart = isProductInCart;
|
|
85
|
+
this._hasFinishedSetup = true;
|
|
86
|
+
this._dispatchEvent("shipaid-loaded", apiData);
|
|
87
|
+
});
|
|
88
|
+
useEffect(this, () => {
|
|
89
|
+
var _a2, _b2, _c, _d;
|
|
90
|
+
if (!((_a2 = this._cart) == null ? void 0 : _a2.items))
|
|
91
|
+
return;
|
|
92
|
+
const protectionProductIndex = (_c = (_b2 = this._cart) == null ? void 0 : _b2.items) == null ? void 0 : _c.findIndex((item) => {
|
|
93
|
+
var _a3;
|
|
94
|
+
return item.variant_id === ((_a3 = this._store) == null ? void 0 : _a3.productVariantNumericId);
|
|
95
|
+
});
|
|
96
|
+
const protectionProduct = (_d = this._cart) == null ? void 0 : _d.items[protectionProductIndex];
|
|
97
|
+
this._hasProtectionInCart = !!protectionProduct;
|
|
98
|
+
if (protectionProduct) {
|
|
99
|
+
this._protectionProduct = __spreadProps(__spreadValues({}, protectionProduct), { index: protectionProductIndex, position: protectionProductIndex + 1 });
|
|
100
|
+
}
|
|
101
|
+
}, [this._store, this._cart]);
|
|
102
|
+
const promptTemplate = html`
|
|
103
|
+
<div class="shipaid-prompt">
|
|
104
|
+
<p class="prompt-title">${this._hasProtectionInCart ? "Active" : "Inactive"}</p>
|
|
105
|
+
<div class="prompt-product">
|
|
106
|
+
<!-- <div class="prompt-product-image">
|
|
107
|
+
<img src="" alt="ShipAid logo" />
|
|
108
|
+
</div> -->
|
|
109
|
+
<div class="prompt-product-details">
|
|
110
|
+
<p class="prompt-product-details-title">Instant Package Protection</p>
|
|
111
|
+
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="prompt-product-actions">
|
|
114
|
+
<p class="prompt-product-actions-price">${currencyFormat((_b = (_a = this._store) == null ? void 0 : _a.productPrice) != null ? _b : 0)}</p>
|
|
115
|
+
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
116
|
+
${this._state.loading ? "Loading..." : this._hasProtectionInCart ? "Remove" : "+ Add"}
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="prompt-footer">
|
|
121
|
+
<b class="prompt-footer-about" href="/">Learn More</b>
|
|
122
|
+
<a class="prompt-footer-badge" href="/">
|
|
123
|
+
<span>Powered by</span>
|
|
124
|
+
<span class="ship">Ship</span>
|
|
125
|
+
<span class="aid">Aid</span>
|
|
126
|
+
</a>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
`;
|
|
130
|
+
return html`
|
|
131
|
+
${when(this._hasFinishedSetup && this._store, () => promptTemplate, () => html`<p>Loading...</p>`)}
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
_dispatchEvent(event, detail = {}) {
|
|
135
|
+
this.dispatchEvent(new CustomEvent(event, { bubbles: true, composed: true, detail }));
|
|
136
|
+
}
|
|
137
|
+
_setState(state2, message) {
|
|
138
|
+
this._state = {
|
|
139
|
+
loading: state2 === "loading",
|
|
140
|
+
success: state2 === "success",
|
|
141
|
+
error: state2 === "error" ? message || true : false
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async _updateProtection() {
|
|
145
|
+
return this._hasProtectionInCart ? this.removeProtection() : this.addProtection();
|
|
146
|
+
}
|
|
147
|
+
async _fetchShipAidData() {
|
|
148
|
+
try {
|
|
149
|
+
if (!this._storeDomain)
|
|
150
|
+
throw new Error("Missing store domain - cannot continue.");
|
|
151
|
+
const variables = { store: this._storeDomain };
|
|
152
|
+
const query = `query StoreByDomain($store: String!) {
|
|
153
|
+
store(store: $store) {
|
|
154
|
+
store
|
|
155
|
+
productId
|
|
156
|
+
productVariantId
|
|
157
|
+
productVariantNumericId
|
|
158
|
+
productPrice
|
|
159
|
+
}
|
|
160
|
+
}`;
|
|
161
|
+
const { data } = await this._fetch.post("http://localhost:1337/v1/graphql", { query, variables });
|
|
162
|
+
if (!data.store)
|
|
163
|
+
throw new Error(`Could not find a store for ${this._storeDomain}`);
|
|
164
|
+
if (!data.store.productVariantNumericId)
|
|
165
|
+
throw new Error("Missing variant ID for ShipAid product.");
|
|
166
|
+
return data.store;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error(error);
|
|
169
|
+
throw new Error(`Could not find a store for ${this._storeDomain}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async _fetchCart() {
|
|
173
|
+
try {
|
|
174
|
+
const cart = await this._fetch.get("/cart.js");
|
|
175
|
+
return cart;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error(error);
|
|
178
|
+
throw new Error("Could not fetch cart for current domain.");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
hasProtection() {
|
|
182
|
+
return this._hasProtectionInCart;
|
|
183
|
+
}
|
|
184
|
+
async addProtection() {
|
|
185
|
+
var _a, _b;
|
|
186
|
+
try {
|
|
187
|
+
if (!((_a = this._store) == null ? void 0 : _a.productVariantNumericId))
|
|
188
|
+
throw new Error("Store has not been loaded.");
|
|
189
|
+
if (!((_b = this._cart) == null ? void 0 : _b.items))
|
|
190
|
+
throw new Error("Cart has not been loaded.");
|
|
191
|
+
this._setState("loading");
|
|
192
|
+
const payload = {
|
|
193
|
+
id: this._store.productVariantNumericId,
|
|
194
|
+
quantity: 1
|
|
195
|
+
};
|
|
196
|
+
const cartItem = await this._fetch.post("/cart/add.js", payload);
|
|
197
|
+
const updatedCart = __spreadProps(__spreadValues({}, this._cart), {
|
|
198
|
+
items: [cartItem, ...this._cart.items]
|
|
199
|
+
});
|
|
200
|
+
this._cart = updatedCart;
|
|
201
|
+
this._setState("success");
|
|
202
|
+
this._dispatchEvent("shipaid-protection-status", { protection: true, cart: updatedCart, lineItem: cartItem });
|
|
203
|
+
} catch (err) {
|
|
204
|
+
const error = err;
|
|
205
|
+
console.error(error);
|
|
206
|
+
this._setState("error", "Failed to add protection to cart - please try again, or contact us for help.");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async removeProtection() {
|
|
210
|
+
var _a;
|
|
211
|
+
try {
|
|
212
|
+
if (!((_a = this._store) == null ? void 0 : _a.productVariantNumericId))
|
|
213
|
+
throw new Error("Store has not been loaded.");
|
|
214
|
+
if (!this._protectionProduct)
|
|
215
|
+
throw new Error("Protection product not found.");
|
|
216
|
+
this._setState("loading");
|
|
217
|
+
const payload = {
|
|
218
|
+
id: this._protectionProduct.key,
|
|
219
|
+
quantity: 0
|
|
220
|
+
};
|
|
221
|
+
const cart = await this._fetch.post("/cart/change.js", payload);
|
|
222
|
+
this._dispatchEvent("shipaid-protection-status", { protection: false, cart, lineItem: this._protectionProduct });
|
|
223
|
+
this._cart = cart;
|
|
224
|
+
this._setState("success");
|
|
225
|
+
} catch (err) {
|
|
226
|
+
const error = err;
|
|
227
|
+
console.error(error);
|
|
228
|
+
this._setState("error", "Failed to add protection to cart - please try again, or contact us for help.");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
ShipAidWidget.styles = styles;
|
|
233
|
+
__decorateClass([
|
|
234
|
+
state()
|
|
235
|
+
], ShipAidWidget.prototype, "_storeDomain", 2);
|
|
236
|
+
__decorateClass([
|
|
237
|
+
state()
|
|
238
|
+
], ShipAidWidget.prototype, "_store", 2);
|
|
239
|
+
__decorateClass([
|
|
240
|
+
state()
|
|
241
|
+
], ShipAidWidget.prototype, "_cart", 2);
|
|
242
|
+
__decorateClass([
|
|
243
|
+
state()
|
|
244
|
+
], ShipAidWidget.prototype, "_hasFinishedSetup", 2);
|
|
245
|
+
__decorateClass([
|
|
246
|
+
state()
|
|
247
|
+
], ShipAidWidget.prototype, "_hasProtectionInCart", 2);
|
|
248
|
+
__decorateClass([
|
|
249
|
+
state()
|
|
250
|
+
], ShipAidWidget.prototype, "_protectionProduct", 2);
|
|
251
|
+
__decorateClass([
|
|
252
|
+
state()
|
|
253
|
+
], ShipAidWidget.prototype, "_state", 2);
|
|
254
|
+
ShipAidWidget = __decorateClass([
|
|
255
|
+
customElement("shipaid-widget")
|
|
256
|
+
], ShipAidWidget);
|
|
257
|
+
export { ShipAidWidget };
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ui.shipaid.com",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"main": "dist/ui.shipaid.com.es.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/ui.shipaid.com.es.js"
|
|
8
|
+
},
|
|
9
|
+
"types": "dist-types/src/shipaid-widget.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"types"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@lit-labs/task": "^1.1.1",
|
|
16
|
+
"lit": "^2.2.0",
|
|
17
|
+
"lit-element-effect": "^1.0.2"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
21
|
+
"@typescript-eslint/parser": "^5.15.0",
|
|
22
|
+
"eslint": "^7.32.0",
|
|
23
|
+
"eslint-config-standard": "^16.0.3",
|
|
24
|
+
"eslint-plugin-html": "^6.2.0",
|
|
25
|
+
"eslint-plugin-import": "^2.25.4",
|
|
26
|
+
"eslint-plugin-lit": "^1.6.1",
|
|
27
|
+
"eslint-plugin-lit-a11y": "^2.2.0",
|
|
28
|
+
"eslint-plugin-node": "^11.1.0",
|
|
29
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
30
|
+
"rollup-plugin-postcss-lit": "^2.0.0",
|
|
31
|
+
"sass": "^1.49.9",
|
|
32
|
+
"typescript": "^4.6.2",
|
|
33
|
+
"vite": "^2.8.6"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"develop": "vite",
|
|
37
|
+
"build": "tsc && vite build",
|
|
38
|
+
"lint": "eslint . --ext=ts --fix"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/types/scss.d.ts
ADDED
package/types/shipaid.ts
ADDED
package/types/shopify.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* eslint-disable no-use-before-define */
|
|
2
|
+
/* eslint-disable camelcase */
|
|
3
|
+
export interface ShopifyCart {
|
|
4
|
+
token: string;
|
|
5
|
+
note?: null;
|
|
6
|
+
original_total_price: number;
|
|
7
|
+
total_price: number;
|
|
8
|
+
total_discount: number;
|
|
9
|
+
total_weight: number;
|
|
10
|
+
item_count: number;
|
|
11
|
+
items?: ShopifyCartItem[];
|
|
12
|
+
requires_shipping: boolean;
|
|
13
|
+
currency: string;
|
|
14
|
+
items_subtotal_price: number;
|
|
15
|
+
cart_level_discount_applications?: (null)[] | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ShopifyCartItem {
|
|
19
|
+
id: number;
|
|
20
|
+
index: number;
|
|
21
|
+
position: number;
|
|
22
|
+
properties?: null;
|
|
23
|
+
quantity: number;
|
|
24
|
+
variant_id: number;
|
|
25
|
+
key: string;
|
|
26
|
+
title: string;
|
|
27
|
+
price: number;
|
|
28
|
+
original_price: number;
|
|
29
|
+
discounted_price: number;
|
|
30
|
+
line_price: number;
|
|
31
|
+
original_line_price: number;
|
|
32
|
+
total_discount: number;
|
|
33
|
+
discounts?: (null)[] | null;
|
|
34
|
+
sku: string;
|
|
35
|
+
grams: number;
|
|
36
|
+
vendor: string;
|
|
37
|
+
taxable: boolean;
|
|
38
|
+
product_id: number;
|
|
39
|
+
product_has_only_default_variant: boolean;
|
|
40
|
+
gift_card: boolean;
|
|
41
|
+
final_price: number;
|
|
42
|
+
final_line_price: number;
|
|
43
|
+
url: string;
|
|
44
|
+
featured_image: FeaturedImage;
|
|
45
|
+
image: string;
|
|
46
|
+
handle: string;
|
|
47
|
+
requires_shipping: boolean;
|
|
48
|
+
product_type: string;
|
|
49
|
+
product_title: string;
|
|
50
|
+
product_description: string;
|
|
51
|
+
variant_title?: null;
|
|
52
|
+
variant_options?: (string)[] | null;
|
|
53
|
+
options_with_values?: (OptionsWithValuesEntity)[] | null;
|
|
54
|
+
line_level_discount_allocations?: (null)[] | null;
|
|
55
|
+
line_level_total_discount: number;
|
|
56
|
+
}
|
|
57
|
+
export interface FeaturedImage {
|
|
58
|
+
aspect_ratio: number;
|
|
59
|
+
alt: string;
|
|
60
|
+
height: number;
|
|
61
|
+
url: string;
|
|
62
|
+
width: number;
|
|
63
|
+
}
|
|
64
|
+
export interface OptionsWithValuesEntity {
|
|
65
|
+
name: string;
|
|
66
|
+
value: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ShopifyCartAddPayload {
|
|
70
|
+
id: number | string
|
|
71
|
+
quantity?: number
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare global {
|
|
75
|
+
interface Window {
|
|
76
|
+
Shopify?: {
|
|
77
|
+
shop?: string
|
|
78
|
+
locale?: string
|
|
79
|
+
currency?: {
|
|
80
|
+
active?: string
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|