ui.shipaid.com 0.3.102 → 0.3.103
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/README.md +202 -202
- package/dist/widget.es.js +13 -3
- package/dist/widget.iife.js +1 -1
- package/dist/widget.umd.js +1 -1
- package/dist-types/common/shopify/index.d.ts +6 -6
- package/dist-types/common/shopify/protection.d.ts +7 -7
- package/dist-types/common/shopify/types/ShopifyCart.d.ts +29 -29
- package/dist-types/common/shopify/types/ShopifyProduct.d.ts +12 -12
- package/dist-types/common/types/ShipAid.d.ts +82 -82
- package/dist-types/widget/src/assets/confirmation-styles.d.ts +2 -2
- package/dist-types/widget/src/assets/icons.d.ts +9 -9
- package/dist-types/widget/src/assets/learn-more-styles.d.ts +2 -2
- package/dist-types/widget/src/assets/styles.d.ts +2 -2
- package/dist-types/widget/src/components/checkout-package-protection.d.ts +13 -13
- package/dist-types/widget/src/components/confirmation-popup.d.ts +9 -9
- package/dist-types/widget/src/components/learn-more-popup.d.ts +8 -8
- package/dist-types/widget/src/components/product-add-confirmation.d.ts +13 -0
- package/dist-types/widget/src/components/shipaid-cart-confirmation.d.ts +15 -15
- package/dist-types/widget/src/shipaid-widget.d.ts +150 -150
- package/dist-types/widget/src/utils/fetch_interceptor.d.ts +3 -3
- package/dist-types/widget/src/utils/fetch_interceptor.test.d.ts +1 -1
- package/dist-types/widget/types/shipaid.d.ts +10 -10
- package/dist-types/widget/types/shopify.d.ts +29 -29
- package/dist-types/widget/types/widget.d.ts +13 -13
- package/package.json +48 -48
- package/dist-types/widget/src/components/checkout-button.d.ts +0 -7
- package/dist-types/widget/src/components/checkoutButton.d.ts +0 -13
- package/dist-types/widget/src/components/content-loader.d.ts +0 -6
package/README.md
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
# ShipAid Shopify Widget
|
|
2
|
-
|
|
3
|
-
This is the repository for the ShipAid Shopify (and possibly others in future) widget. It uses the [Lit](https://lit.dev/) web components library, so it is recommended to become familiar with it before contributing to this repository.
|
|
4
|
-
|
|
5
|
-
Using Lit provides a framework that allows us to build a reactive UI, using JSX-like syntax - no need to use JQuery etc. And it can easily be installed in a page by using the custom web component name:
|
|
6
|
-
```html
|
|
7
|
-
<shipaid-widget>Fallback Content</shipaid-widget>
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
This widget provides an interface where a user can choose to add or remove ShipAid protection - this is actually a product in their store that can be added to cart. When the component is loaded, we immediately run a request to fetch the ShipAid protection product details from our API, as well as the customers current cart from the [Shopify AJAX API](https://shopify.dev/api/ajax/reference/cart).
|
|
13
|
-
Once we have this data, we can check whether the customer currently has the ShipAid product in their cart, and show either the add or remove product buttons based on this.
|
|
14
|
-
|
|
15
|
-
We also emit various [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events#adding_custom_data_%E2%80%93_customevent) when we add or remove the ShipAid product from the cart, so other developers can listen to these events, and update AJAX carts.
|
|
16
|
-
|
|
17
|
-
### Installation
|
|
18
|
-
|
|
19
|
-
Add the script tag to the theme - if the theme has an ajax cart, you'll likely want to add this to the `theme.liquid` file, otherwise if the store has only a cart page (`/cart`), then you can add it to just that page, to save it being unecessarily loaded when it isn't needed.
|
|
20
|
-
As we don't want to affect a stores speed at all, you should add it to the bottom of the page just before the ending body tag (`</body>`), rather than inside the `<head>` block.
|
|
21
|
-
|
|
22
|
-
```html
|
|
23
|
-
<!-- ShipAid Widget -->
|
|
24
|
-
<script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
|
|
25
|
-
```
|
|
26
|
-
Then add the widget element where needed:
|
|
27
|
-
|
|
28
|
-
```html
|
|
29
|
-
<shipaid-widget></shipaid-widget>
|
|
30
|
-
|
|
31
|
-
<!-- Disable polling example -->
|
|
32
|
-
<shipaid-widget disablePolling></shipaid-widget>
|
|
33
|
-
|
|
34
|
-
<!-- With customised text -->
|
|
35
|
-
<shipaid-widget>
|
|
36
|
-
<p slot="loading">Loading ShipAid Protection</p>
|
|
37
|
-
</shipaid-widget>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
#### Test Mode
|
|
41
|
-
|
|
42
|
-
Sometimes, a store won't have activated their subscription before you install the widget - in this case, the widget does not display (you will notice a message in the console reflecting this). So to force the widget to show while you are installing and testing it, you can add this query param to the page URL: `shipaid-test`.
|
|
43
|
-
For example: `https://some-store.myshopify.com/cart?shipaid-text`
|
|
44
|
-
|
|
45
|
-
### Slots
|
|
46
|
-
|
|
47
|
-
Slots, with the syntax `slot="<slot name>"`, can be used to customise the widgets content - for example, a merchant may want to add a custom subtitle, which can be done like so:
|
|
48
|
-
```html
|
|
49
|
-
<shipaid-widget>
|
|
50
|
-
<p slot="subtitle">Shipping protection is required to be able to return or refunds items.</p>
|
|
51
|
-
</shipaid-widget>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
The default content will be replaced by any slot content. You can also add inline styles to the slots, if you need to change the font size/weight for example - but color changes should be handled by CSS variables:
|
|
55
|
-
```html
|
|
56
|
-
<span slot="title" style="font-weight: 500;">Package Protection</span>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
| Name | Description |
|
|
60
|
-
|--------|-------------|
|
|
61
|
-
| `loading` | Replaces the text that is shown whilst the widget is loading - I.e. fetching content from the Shopify or ShipAid API's. |
|
|
62
|
-
| `title` | Replaces the default title. |
|
|
63
|
-
| `subtitle` | Replaces the default subtitle. |
|
|
64
|
-
|
|
65
|
-
### Props
|
|
66
|
-
|
|
67
|
-
This is a list of props that can be used to configure the widget:
|
|
68
|
-
|
|
69
|
-
| Prop | Description | Value/Type |
|
|
70
|
-
|--------|-------------|---------|
|
|
71
|
-
| `disablePolling` | Sets whether the cart should disable polling (enabled by default) - should be disabled if integrating manually with an ajax cart. | `boolean` |
|
|
72
|
-
| `pollingInterval` | If polling is enabled, it sets the interval (in ms) between API updates. | `number` in milliseconds |
|
|
73
|
-
| `disableRefresh ` | Sets whether the store cart should be updated when the protection item is added/removed. Add if you want to initially hide the protection product from the cart, even if it has just been added. | `boolean` |
|
|
74
|
-
| `customerId ` | Passes the information of the customer to the widget. Add if merchant wants to disable auto opt-in for some customers based on the customer tags. | `boolean` |
|
|
75
|
-
| `lang ` | Sets the widget language (see the translations section below). This value can be any supported [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). | `string` defaults to `en` |
|
|
76
|
-
| `refreshCart` | Refresh the page if shipaid product quantity is greater than one to sync product qty at checkout | `boolean` |
|
|
77
|
-
| `persistPopup` | Use local storage to show popup so that popup don't re-render on script refresh | `boolean` |
|
|
78
|
-
|
|
79
|
-
### Events
|
|
80
|
-
|
|
81
|
-
This is a list of the events emitted by the widget. You can listen to these events like so:
|
|
82
|
-
```js
|
|
83
|
-
document.addEventListener('shipaid-protection-status', ({ detail }) => {
|
|
84
|
-
console.log(detail.cart) // ShopifyCart
|
|
85
|
-
})
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
| Event | Description | Payload |
|
|
89
|
-
|-------|-------------|---------|
|
|
90
|
-
| `shipaid-loaded` | Dispatched when the widget has finished fetching data from the API, and has successfully rendered. | Contains the data from the ShipAid API: [`ShipAidStore`](/types/shipaid.ts) |
|
|
91
|
-
| `shipaid-protection-status` | Dispatched when a user either adds or removes the protection product from their cart. | `{ protection: boolean, cart: ShopifyCart, lineItem: ShopifyCartItem }` |
|
|
92
|
-
|
|
93
|
-
### Methods
|
|
94
|
-
|
|
95
|
-
This is a list of public methods available on the widget HTMLElement that can be used to change protection settings. These can be used by querying the element:
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
const shipAidEl = document.querySelector('shipaid-widget')
|
|
99
|
-
if (shipAidEl) await shipAidEl.updateCart()
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
| Method | Description | Payload |
|
|
103
|
-
|--------|-------------|---------|
|
|
104
|
-
| `hasProtection` | Returns a boolean which indicates whether the protection item is currently in the cart. | |
|
|
105
|
-
| `updateCart` | Updates the internal cart, and triggers any protection product updates - use this method with with ajax carts, to update protection state without needing to reload the page. | Optional - the cart object from the ajax API. |
|
|
106
|
-
| `addProtection` | Adds the relevant protection item to cart. | |
|
|
107
|
-
| `removeProtection` | Removes the protection item from the cart. | |
|
|
108
|
-
|
|
109
|
-
### Styles
|
|
110
|
-
|
|
111
|
-
If you need to change any of the widget colors to suit a specific theme, there are various CSS variables you can use to do so. These should be added to the style attribute on the widget element:
|
|
112
|
-
|
|
113
|
-
```html
|
|
114
|
-
<shipaid-widget
|
|
115
|
-
style="
|
|
116
|
-
--shipaid-text: #fff;
|
|
117
|
-
--shipaid-prompt-actions-price-color: #fff;
|
|
118
|
-
"
|
|
119
|
-
>
|
|
120
|
-
</shipaid-widget>
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
| Variable | Description | Default |
|
|
124
|
-
|----------|-------------|---------|
|
|
125
|
-
| `--shipaid-text` | Changes the global text color. | `#000000` |
|
|
126
|
-
| `--shipaid-text-muted` | Changes the global muted text color. | `#aaaaaa` |
|
|
127
|
-
| `--shipaid-prompt-margin` | Changes the margins of the main container element. | `2rem 0px 4rem auto` |
|
|
128
|
-
| `--shipaid-prompt-width` | Changes the width of the main container element. | `400px` |
|
|
129
|
-
| `--shipaid-prompt-width-mobile` | Changes the mobile width of the main container element. | `100%` |
|
|
130
|
-
| `--shipaid-prompt-actions-price-color` | Changes the color of the price element. | `var(--shipaid-text-muted)` |
|
|
131
|
-
| `--shipaid-prompt-actions-button-color` | Changes the color of the add/remove button element. | `var(--shipaid-primary)` |
|
|
132
|
-
| `--shipaid-prompt-badge-background-color` | Changes the background color of the learn more button element. | `var(--shipaid-light-grey)` |
|
|
133
|
-
| `--shipaid-prompt-badge-text-color` | Changes the color of the learn more button element. | `var(--shipaid-text)` |
|
|
134
|
-
| `--shipaid-logo-height` | Changes the height of ShipAid logo. | `var(--shipaid-logo-height, 35px)` |
|
|
135
|
-
| `--shipaid-logo-max-height` | Changes the max height of ShipAid logo. | `var(--shipaid-logo-max-height, 35px)` |
|
|
136
|
-
| `--shipaid-logo-width` | Changes the width of ShipAid logo. | `var(--shipaid-logo-width, auto)` |
|
|
137
|
-
| `--shipaid-logo-max-width` | Changes the max width of ShipAid logo. | `var(--shipaid-logo-max-width, 50px)` |
|
|
138
|
-
| `--shipaid-prompt-footer-button-size` | Changes the height of info button in footer. | `var(--shipaid-prompt-footer-button-size, 10px)` |
|
|
139
|
-
| `--shipaid-prompt-badge-border-radius` | Changes border radius of footer | `var(--shipaid-prompt-badge-border-radius, 30px)` |
|
|
140
|
-
| `--shipaid-footer-badge-logo-height` | Changes the height of logo in footer. | `var(--shipaid-footer-badge-logo-height, 9px)` |
|
|
141
|
-
| `--shipaid-prompt-footer-location` | Changes the position of footer badge | `var(--shipaid-prompt-footer-location, flex-start)` |
|
|
142
|
-
| `--shipaid-prompt-product-actions-content` | Changes the spaces between price and add/remove button | `var(--shipaid-prompt-product-actions-content, space-between)` |
|
|
143
|
-
| `--shipaid-prompt-footer-topMargin` | Changes margin between header and badge footer | `var(--shipaid-prompt-footer-topMargin, 0px)` |
|
|
144
|
-
| `-shipaid-prompt-footer-display` | Changes the display option for footer | `var(-shipaid-prompt-footer-display, flex)` |
|
|
145
|
-
| `--shipaid-active-logo-color` | Changes the logo color when the product is in the cart | `#000000` |
|
|
146
|
-
| `--shipaid-inactive-logo-color` | Changes the logo color when the product isn't in the cart | `#0056d6` |
|
|
147
|
-
|
|
148
|
-
Other variables can be found [here](/widget/src/assets/styles.ts) (`/widget/src/assets/styles.ts`).
|
|
149
|
-
|
|
150
|
-
### Translations
|
|
151
|
-
|
|
152
|
-
This widget also supports multiple languages, using the `lit-translate` plugin. The widget language can be configured using an attribute and would usally be static, but supports reactively swapping the language if a theme needs - i.e. if a user switches the language using a select option in the theme, then the widget language could be updated at the same time by selecting the widget element, and setting the `lang` attribute.
|
|
153
|
-
|
|
154
|
-
To create lang files, you should copy the default `/lang/en.json` file, and rename it to an [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) - for example `cp /src/lang/en.json /src/lang/fs.json`. You can then go through each key, and translate the existing text to the relevant language. This should be all you need to do - the widget automatically (and lazily, to save bundle size) imports the relevant lang file when it is specified. It will also fallback to the default `en.json` lang file if a certain language doesn't exist yet.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
## Contributing
|
|
158
|
-
|
|
159
|
-
### Requirements
|
|
160
|
-
|
|
161
|
-
- Node v16+
|
|
162
|
-
- PNPM
|
|
163
|
-
- Development Shopify store (with the ShipAid app installed)
|
|
164
|
-
- ShipAid API development/staging instance
|
|
165
|
-
|
|
166
|
-
### Development
|
|
167
|
-
|
|
168
|
-
You will need to make sure your development store has the ShipAid app installed, so the store and its protection product is added to the DB. You will also need to ensure the Shopify app you are testing this with has an app proxy added, and pointed towards an API instance.
|
|
169
|
-
|
|
170
|
-
```sh
|
|
171
|
-
pnpm install
|
|
172
|
-
pnpm run develop
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Once the project is running, add the below to your development Shopify store `theme.liquid`:
|
|
176
|
-
|
|
177
|
-
```html
|
|
178
|
-
<!-- Dev -->
|
|
179
|
-
<script src="http://localhost:3000/src/shipaid-widget.ts"type="module" ></script>
|
|
180
|
-
|
|
181
|
-
<!-- Prod -->
|
|
182
|
-
<!-- ShipAid Widget -->
|
|
183
|
-
<script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
|
|
184
|
-
```
|
|
185
|
-
And add the widget element where needed:
|
|
186
|
-
|
|
187
|
-
```html
|
|
188
|
-
<shipaid-widget>
|
|
189
|
-
<p>Loading ShipAid Protection</p>
|
|
190
|
-
</shipaid-widget>
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Build
|
|
194
|
-
|
|
195
|
-
Once the project has been built, you can publish the project to NPM, and users can add the script to their store using a package CDN (I.e. [Unpkg](https://unpkg.com/)).
|
|
196
|
-
|
|
197
|
-
```sh
|
|
198
|
-
pnpm install
|
|
199
|
-
pnpm run lint
|
|
200
|
-
pnpm run build
|
|
201
|
-
pnpm publish
|
|
202
|
-
```
|
|
1
|
+
# ShipAid Shopify Widget
|
|
2
|
+
|
|
3
|
+
This is the repository for the ShipAid Shopify (and possibly others in future) widget. It uses the [Lit](https://lit.dev/) web components library, so it is recommended to become familiar with it before contributing to this repository.
|
|
4
|
+
|
|
5
|
+
Using Lit provides a framework that allows us to build a reactive UI, using JSX-like syntax - no need to use JQuery etc. And it can easily be installed in a page by using the custom web component name:
|
|
6
|
+
```html
|
|
7
|
+
<shipaid-widget>Fallback Content</shipaid-widget>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
This widget provides an interface where a user can choose to add or remove ShipAid protection - this is actually a product in their store that can be added to cart. When the component is loaded, we immediately run a request to fetch the ShipAid protection product details from our API, as well as the customers current cart from the [Shopify AJAX API](https://shopify.dev/api/ajax/reference/cart).
|
|
13
|
+
Once we have this data, we can check whether the customer currently has the ShipAid product in their cart, and show either the add or remove product buttons based on this.
|
|
14
|
+
|
|
15
|
+
We also emit various [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events#adding_custom_data_%E2%80%93_customevent) when we add or remove the ShipAid product from the cart, so other developers can listen to these events, and update AJAX carts.
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
Add the script tag to the theme - if the theme has an ajax cart, you'll likely want to add this to the `theme.liquid` file, otherwise if the store has only a cart page (`/cart`), then you can add it to just that page, to save it being unecessarily loaded when it isn't needed.
|
|
20
|
+
As we don't want to affect a stores speed at all, you should add it to the bottom of the page just before the ending body tag (`</body>`), rather than inside the `<head>` block.
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<!-- ShipAid Widget -->
|
|
24
|
+
<script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
|
|
25
|
+
```
|
|
26
|
+
Then add the widget element where needed:
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<shipaid-widget></shipaid-widget>
|
|
30
|
+
|
|
31
|
+
<!-- Disable polling example -->
|
|
32
|
+
<shipaid-widget disablePolling></shipaid-widget>
|
|
33
|
+
|
|
34
|
+
<!-- With customised text -->
|
|
35
|
+
<shipaid-widget>
|
|
36
|
+
<p slot="loading">Loading ShipAid Protection</p>
|
|
37
|
+
</shipaid-widget>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Test Mode
|
|
41
|
+
|
|
42
|
+
Sometimes, a store won't have activated their subscription before you install the widget - in this case, the widget does not display (you will notice a message in the console reflecting this). So to force the widget to show while you are installing and testing it, you can add this query param to the page URL: `shipaid-test`.
|
|
43
|
+
For example: `https://some-store.myshopify.com/cart?shipaid-text`
|
|
44
|
+
|
|
45
|
+
### Slots
|
|
46
|
+
|
|
47
|
+
Slots, with the syntax `slot="<slot name>"`, can be used to customise the widgets content - for example, a merchant may want to add a custom subtitle, which can be done like so:
|
|
48
|
+
```html
|
|
49
|
+
<shipaid-widget>
|
|
50
|
+
<p slot="subtitle">Shipping protection is required to be able to return or refunds items.</p>
|
|
51
|
+
</shipaid-widget>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The default content will be replaced by any slot content. You can also add inline styles to the slots, if you need to change the font size/weight for example - but color changes should be handled by CSS variables:
|
|
55
|
+
```html
|
|
56
|
+
<span slot="title" style="font-weight: 500;">Package Protection</span>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Name | Description |
|
|
60
|
+
|--------|-------------|
|
|
61
|
+
| `loading` | Replaces the text that is shown whilst the widget is loading - I.e. fetching content from the Shopify or ShipAid API's. |
|
|
62
|
+
| `title` | Replaces the default title. |
|
|
63
|
+
| `subtitle` | Replaces the default subtitle. |
|
|
64
|
+
|
|
65
|
+
### Props
|
|
66
|
+
|
|
67
|
+
This is a list of props that can be used to configure the widget:
|
|
68
|
+
|
|
69
|
+
| Prop | Description | Value/Type |
|
|
70
|
+
|--------|-------------|---------|
|
|
71
|
+
| `disablePolling` | Sets whether the cart should disable polling (enabled by default) - should be disabled if integrating manually with an ajax cart. | `boolean` |
|
|
72
|
+
| `pollingInterval` | If polling is enabled, it sets the interval (in ms) between API updates. | `number` in milliseconds |
|
|
73
|
+
| `disableRefresh ` | Sets whether the store cart should be updated when the protection item is added/removed. Add if you want to initially hide the protection product from the cart, even if it has just been added. | `boolean` |
|
|
74
|
+
| `customerId ` | Passes the information of the customer to the widget. Add if merchant wants to disable auto opt-in for some customers based on the customer tags. | `boolean` |
|
|
75
|
+
| `lang ` | Sets the widget language (see the translations section below). This value can be any supported [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). | `string` defaults to `en` |
|
|
76
|
+
| `refreshCart` | Refresh the page if shipaid product quantity is greater than one to sync product qty at checkout | `boolean` |
|
|
77
|
+
| `persistPopup` | Use local storage to show popup so that popup don't re-render on script refresh | `boolean` |
|
|
78
|
+
|
|
79
|
+
### Events
|
|
80
|
+
|
|
81
|
+
This is a list of the events emitted by the widget. You can listen to these events like so:
|
|
82
|
+
```js
|
|
83
|
+
document.addEventListener('shipaid-protection-status', ({ detail }) => {
|
|
84
|
+
console.log(detail.cart) // ShopifyCart
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| Event | Description | Payload |
|
|
89
|
+
|-------|-------------|---------|
|
|
90
|
+
| `shipaid-loaded` | Dispatched when the widget has finished fetching data from the API, and has successfully rendered. | Contains the data from the ShipAid API: [`ShipAidStore`](/types/shipaid.ts) |
|
|
91
|
+
| `shipaid-protection-status` | Dispatched when a user either adds or removes the protection product from their cart. | `{ protection: boolean, cart: ShopifyCart, lineItem: ShopifyCartItem }` |
|
|
92
|
+
|
|
93
|
+
### Methods
|
|
94
|
+
|
|
95
|
+
This is a list of public methods available on the widget HTMLElement that can be used to change protection settings. These can be used by querying the element:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const shipAidEl = document.querySelector('shipaid-widget')
|
|
99
|
+
if (shipAidEl) await shipAidEl.updateCart()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
| Method | Description | Payload |
|
|
103
|
+
|--------|-------------|---------|
|
|
104
|
+
| `hasProtection` | Returns a boolean which indicates whether the protection item is currently in the cart. | |
|
|
105
|
+
| `updateCart` | Updates the internal cart, and triggers any protection product updates - use this method with with ajax carts, to update protection state without needing to reload the page. | Optional - the cart object from the ajax API. |
|
|
106
|
+
| `addProtection` | Adds the relevant protection item to cart. | |
|
|
107
|
+
| `removeProtection` | Removes the protection item from the cart. | |
|
|
108
|
+
|
|
109
|
+
### Styles
|
|
110
|
+
|
|
111
|
+
If you need to change any of the widget colors to suit a specific theme, there are various CSS variables you can use to do so. These should be added to the style attribute on the widget element:
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<shipaid-widget
|
|
115
|
+
style="
|
|
116
|
+
--shipaid-text: #fff;
|
|
117
|
+
--shipaid-prompt-actions-price-color: #fff;
|
|
118
|
+
"
|
|
119
|
+
>
|
|
120
|
+
</shipaid-widget>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
| Variable | Description | Default |
|
|
124
|
+
|----------|-------------|---------|
|
|
125
|
+
| `--shipaid-text` | Changes the global text color. | `#000000` |
|
|
126
|
+
| `--shipaid-text-muted` | Changes the global muted text color. | `#aaaaaa` |
|
|
127
|
+
| `--shipaid-prompt-margin` | Changes the margins of the main container element. | `2rem 0px 4rem auto` |
|
|
128
|
+
| `--shipaid-prompt-width` | Changes the width of the main container element. | `400px` |
|
|
129
|
+
| `--shipaid-prompt-width-mobile` | Changes the mobile width of the main container element. | `100%` |
|
|
130
|
+
| `--shipaid-prompt-actions-price-color` | Changes the color of the price element. | `var(--shipaid-text-muted)` |
|
|
131
|
+
| `--shipaid-prompt-actions-button-color` | Changes the color of the add/remove button element. | `var(--shipaid-primary)` |
|
|
132
|
+
| `--shipaid-prompt-badge-background-color` | Changes the background color of the learn more button element. | `var(--shipaid-light-grey)` |
|
|
133
|
+
| `--shipaid-prompt-badge-text-color` | Changes the color of the learn more button element. | `var(--shipaid-text)` |
|
|
134
|
+
| `--shipaid-logo-height` | Changes the height of ShipAid logo. | `var(--shipaid-logo-height, 35px)` |
|
|
135
|
+
| `--shipaid-logo-max-height` | Changes the max height of ShipAid logo. | `var(--shipaid-logo-max-height, 35px)` |
|
|
136
|
+
| `--shipaid-logo-width` | Changes the width of ShipAid logo. | `var(--shipaid-logo-width, auto)` |
|
|
137
|
+
| `--shipaid-logo-max-width` | Changes the max width of ShipAid logo. | `var(--shipaid-logo-max-width, 50px)` |
|
|
138
|
+
| `--shipaid-prompt-footer-button-size` | Changes the height of info button in footer. | `var(--shipaid-prompt-footer-button-size, 10px)` |
|
|
139
|
+
| `--shipaid-prompt-badge-border-radius` | Changes border radius of footer | `var(--shipaid-prompt-badge-border-radius, 30px)` |
|
|
140
|
+
| `--shipaid-footer-badge-logo-height` | Changes the height of logo in footer. | `var(--shipaid-footer-badge-logo-height, 9px)` |
|
|
141
|
+
| `--shipaid-prompt-footer-location` | Changes the position of footer badge | `var(--shipaid-prompt-footer-location, flex-start)` |
|
|
142
|
+
| `--shipaid-prompt-product-actions-content` | Changes the spaces between price and add/remove button | `var(--shipaid-prompt-product-actions-content, space-between)` |
|
|
143
|
+
| `--shipaid-prompt-footer-topMargin` | Changes margin between header and badge footer | `var(--shipaid-prompt-footer-topMargin, 0px)` |
|
|
144
|
+
| `-shipaid-prompt-footer-display` | Changes the display option for footer | `var(-shipaid-prompt-footer-display, flex)` |
|
|
145
|
+
| `--shipaid-active-logo-color` | Changes the logo color when the product is in the cart | `#000000` |
|
|
146
|
+
| `--shipaid-inactive-logo-color` | Changes the logo color when the product isn't in the cart | `#0056d6` |
|
|
147
|
+
|
|
148
|
+
Other variables can be found [here](/widget/src/assets/styles.ts) (`/widget/src/assets/styles.ts`).
|
|
149
|
+
|
|
150
|
+
### Translations
|
|
151
|
+
|
|
152
|
+
This widget also supports multiple languages, using the `lit-translate` plugin. The widget language can be configured using an attribute and would usally be static, but supports reactively swapping the language if a theme needs - i.e. if a user switches the language using a select option in the theme, then the widget language could be updated at the same time by selecting the widget element, and setting the `lang` attribute.
|
|
153
|
+
|
|
154
|
+
To create lang files, you should copy the default `/lang/en.json` file, and rename it to an [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) - for example `cp /src/lang/en.json /src/lang/fs.json`. You can then go through each key, and translate the existing text to the relevant language. This should be all you need to do - the widget automatically (and lazily, to save bundle size) imports the relevant lang file when it is specified. It will also fallback to the default `en.json` lang file if a certain language doesn't exist yet.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
### Requirements
|
|
160
|
+
|
|
161
|
+
- Node v16+
|
|
162
|
+
- PNPM
|
|
163
|
+
- Development Shopify store (with the ShipAid app installed)
|
|
164
|
+
- ShipAid API development/staging instance
|
|
165
|
+
|
|
166
|
+
### Development
|
|
167
|
+
|
|
168
|
+
You will need to make sure your development store has the ShipAid app installed, so the store and its protection product is added to the DB. You will also need to ensure the Shopify app you are testing this with has an app proxy added, and pointed towards an API instance.
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
pnpm install
|
|
172
|
+
pnpm run develop
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Once the project is running, add the below to your development Shopify store `theme.liquid`:
|
|
176
|
+
|
|
177
|
+
```html
|
|
178
|
+
<!-- Dev -->
|
|
179
|
+
<script src="http://localhost:3000/src/shipaid-widget.ts"type="module" ></script>
|
|
180
|
+
|
|
181
|
+
<!-- Prod -->
|
|
182
|
+
<!-- ShipAid Widget -->
|
|
183
|
+
<script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
|
|
184
|
+
```
|
|
185
|
+
And add the widget element where needed:
|
|
186
|
+
|
|
187
|
+
```html
|
|
188
|
+
<shipaid-widget>
|
|
189
|
+
<p>Loading ShipAid Protection</p>
|
|
190
|
+
</shipaid-widget>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Build
|
|
194
|
+
|
|
195
|
+
Once the project has been built, you can publish the project to NPM, and users can add the script to their store using a package CDN (I.e. [Unpkg](https://unpkg.com/)).
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
pnpm install
|
|
199
|
+
pnpm run lint
|
|
200
|
+
pnpm run build
|
|
201
|
+
pnpm publish
|
|
202
|
+
```
|
package/dist/widget.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function calculateProtectionTotal(store, protectionProduct, cart) {
|
|
2
|
-
var _a, _b;
|
|
2
|
+
var _a, _b, _c;
|
|
3
3
|
if (!store) throw new Error("Missing store settings.");
|
|
4
4
|
if (!protectionProduct) throw new Error("Missing protectionProduct.");
|
|
5
5
|
if (!cart) throw new Error("Missing Shopify cart.");
|
|
@@ -29,10 +29,13 @@ function calculateProtectionTotal(store, protectionProduct, cart) {
|
|
|
29
29
|
})) ?? [];
|
|
30
30
|
const protectionVariantsInCartTotal = protectionVariantsInCart.reduce((total, item) => total + item.final_line_price, 0);
|
|
31
31
|
const cartTotal = itemTotal - protectionVariantsInCartTotal;
|
|
32
|
-
|
|
32
|
+
const allowZeroCartValueProtection = (_b = store.widgetConfigurations) == null ? void 0 : _b.allowZeroCartValueProtection;
|
|
33
|
+
if (!allowZeroCartValueProtection) {
|
|
34
|
+
if (cartTotal === 0) return cartTotal;
|
|
35
|
+
}
|
|
33
36
|
if (settings.protectionType === "FIXED") {
|
|
34
37
|
if (typeof settings.defaultFee !== "number") throw new Error("Missing default fee amount.");
|
|
35
|
-
if (!((
|
|
38
|
+
if (!((_c = settings.rules) == null ? void 0 : _c.length)) return settings.defaultFee;
|
|
36
39
|
const formattedCartTotal = cartTotal / 100;
|
|
37
40
|
const sortedRules = settings.rules.sort((a2, b) => {
|
|
38
41
|
if (!a2.rangeLower || !b.rangeLower) return 0;
|
|
@@ -46,6 +49,13 @@ function calculateProtectionTotal(store, protectionProduct, cart) {
|
|
|
46
49
|
return typeof (rule == null ? void 0 : rule.fee) === "number" ? rule.fee : settings.defaultFee;
|
|
47
50
|
}
|
|
48
51
|
if (settings.protectionType === "PERCENTAGE") {
|
|
52
|
+
if (cartTotal <= 0 && allowZeroCartValueProtection) {
|
|
53
|
+
const minPricedVariant = ((protectionProduct == null ? void 0 : protectionProduct.variants) ?? []).reduce((min, v2) => {
|
|
54
|
+
const price = Number(v2.price);
|
|
55
|
+
return price > 0 && (!min || price < Number(min.price)) ? v2 : min;
|
|
56
|
+
}, null);
|
|
57
|
+
if (minPricedVariant) return Number(minPricedVariant.price);
|
|
58
|
+
}
|
|
49
59
|
const percentageFee = cartTotal * settings.percentage / 100;
|
|
50
60
|
return percentageFee >= settings.minimumFee ? percentageFee : settings.minimumFee;
|
|
51
61
|
}
|
package/dist/widget.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ShipAidWidget=function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const
|
|
1
|
+
var ShipAidWidget=function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r,n;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const a=null==t?void 0:t.protectionSettings;if(!a)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const s=Array.isArray(null==t?void 0:t.excludedProductSkus)?t.excludedProductSkus.map((t=>t.trim())):[],d=Array.isArray(null==t?void 0:t.excludedProductsVariantsId)?t.excludedProductsVariantsId.map((t=>{var e;return parseInt((null==(e=t.match(/\d+/))?void 0:e[0])??"",10)})):[],p=(i.items??[]).reduce(((t,e)=>(t=>!(!t.sku||!s.includes(t.sku.trim()))||!(!t.variant_id||!d.includes(t.variant_id)))(e)?t-e.final_line_price:t),i.total_price||0)-((null==(o=i.items)?void 0:o.filter((t=>{var i;return null==(i=null==e?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))??[]).reduce(((t,e)=>t+e.final_line_price),0),l=null==(r=t.widgetConfigurations)?void 0:r.allowZeroCartValueProtection;if(!l&&0===p)return p;if("FIXED"===a.protectionType){if("number"!=typeof a.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(n=a.rules)?void 0:n.length))return a.defaultFee;const t=p/100,e=a.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:a.defaultFee}if("PERCENTAGE"===a.protectionType){if(p<=0&&l){const t=((null==e?void 0:e.variants)??[]).reduce(((t,e)=>{const i=Number(e.price);return i>0&&(!t||i<Number(t.price))?e:t}),null);if(t)return Number(t.price)}const t=p*a.percentage/100;return t>=a.minimumFee?t:a.minimumFee}throw new Error("No protection type handler found for this store.")},findProtectionVariant:function(t,e,i){var o;if(!(null==t?void 0:t.protectionSettings)||!(null==(o=null==e?void 0:e.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const r=null==e?void 0:e.variants.flatMap((t=>{if(!(null==t?void 0:t.price))return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=r.find((t=>t.formattedPrice>=i));return n||r[r.length-1]}},i=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},o=(t,e,i)=>{e.constructor.createProperty(i,t)};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
package/dist/widget.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShipAidWidget={})}(this,(function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShipAidWidget={})}(this,(function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r,n;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const a=null==t?void 0:t.protectionSettings;if(!a)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const s=Array.isArray(null==t?void 0:t.excludedProductSkus)?t.excludedProductSkus.map((t=>t.trim())):[],d=Array.isArray(null==t?void 0:t.excludedProductsVariantsId)?t.excludedProductsVariantsId.map((t=>{var e;return parseInt((null==(e=t.match(/\d+/))?void 0:e[0])??"",10)})):[],p=(i.items??[]).reduce(((t,e)=>(t=>!(!t.sku||!s.includes(t.sku.trim()))||!(!t.variant_id||!d.includes(t.variant_id)))(e)?t-e.final_line_price:t),i.total_price||0)-((null==(o=i.items)?void 0:o.filter((t=>{var i;return null==(i=null==e?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))??[]).reduce(((t,e)=>t+e.final_line_price),0),l=null==(r=t.widgetConfigurations)?void 0:r.allowZeroCartValueProtection;if(!l&&0===p)return p;if("FIXED"===a.protectionType){if("number"!=typeof a.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(n=a.rules)?void 0:n.length))return a.defaultFee;const t=p/100,e=a.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:a.defaultFee}if("PERCENTAGE"===a.protectionType){if(p<=0&&l){const t=((null==e?void 0:e.variants)??[]).reduce(((t,e)=>{const i=Number(e.price);return i>0&&(!t||i<Number(t.price))?e:t}),null);if(t)return Number(t.price)}const t=p*a.percentage/100;return t>=a.minimumFee?t:a.minimumFee}throw new Error("No protection type handler found for this store.")},findProtectionVariant:function(t,e,i){var o;if(!(null==t?void 0:t.protectionSettings)||!(null==(o=null==e?void 0:e.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const r=null==e?void 0:e.variants.flatMap((t=>{if(!(null==t?void 0:t.price))return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=r.find((t=>t.formattedPrice>=i));return n||r[r.length-1]}},i=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},o=(t,e,i)=>{e.constructor.createProperty(i,t)};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { calculateProtectionTotal, findProtectionVariant } from './protection';
|
|
2
|
-
declare const _default: {
|
|
3
|
-
calculateProtectionTotal: typeof calculateProtectionTotal;
|
|
4
|
-
findProtectionVariant: typeof findProtectionVariant;
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
1
|
+
import { calculateProtectionTotal, findProtectionVariant } from './protection';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
calculateProtectionTotal: typeof calculateProtectionTotal;
|
|
4
|
+
findProtectionVariant: typeof findProtectionVariant;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ShipAidStore } from '../types/ShipAid';
|
|
2
|
-
import { type ShopifyCart } from './types/ShopifyCart';
|
|
3
|
-
import { type ShopifyProduct, type ShopifyProductVariant } from './types/ShopifyProduct';
|
|
4
|
-
/** Given the current cart, it calculates the protection total according to the store protection settings. */
|
|
5
|
-
export declare function calculateProtectionTotal(store: ShipAidStore, protectionProduct: ShopifyProduct, cart: ShopifyCart): number;
|
|
6
|
-
export declare function findProtectionVariant(store: ShipAidStore, protectionProduct: ShopifyProduct, protectionFee: number): ShopifyProductVariant | undefined;
|
|
7
|
-
export declare function getIdFromShopifyGid(gid: string): string | null;
|
|
1
|
+
import { type ShipAidStore } from '../types/ShipAid';
|
|
2
|
+
import { type ShopifyCart } from './types/ShopifyCart';
|
|
3
|
+
import { type ShopifyProduct, type ShopifyProductVariant } from './types/ShopifyProduct';
|
|
4
|
+
/** Given the current cart, it calculates the protection total according to the store protection settings. */
|
|
5
|
+
export declare function calculateProtectionTotal(store: ShipAidStore, protectionProduct: ShopifyProduct, cart: ShopifyCart): number;
|
|
6
|
+
export declare function findProtectionVariant(store: ShipAidStore, protectionProduct: ShopifyProduct, protectionFee: number): ShopifyProductVariant | undefined;
|
|
7
|
+
export declare function getIdFromShopifyGid(gid: string): string | null;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export interface ShopifyCart {
|
|
2
|
-
/** Should be the lowest common denomination */
|
|
3
|
-
total_price: number;
|
|
4
|
-
item_count: number;
|
|
5
|
-
items?: ShopifyCartItem[];
|
|
6
|
-
}
|
|
7
|
-
export interface ShopifyCartItem {
|
|
8
|
-
id: number;
|
|
9
|
-
index: number;
|
|
10
|
-
position: number;
|
|
11
|
-
quantity: number;
|
|
12
|
-
variant_id: number;
|
|
13
|
-
key: string;
|
|
14
|
-
sku: string;
|
|
15
|
-
/** Should be the lowest common denomination */
|
|
16
|
-
final_line_price: number;
|
|
17
|
-
selling_plan_allocation?: any;
|
|
18
|
-
}
|
|
19
|
-
export interface FeaturedImage {
|
|
20
|
-
aspect_ratio: number;
|
|
21
|
-
alt: string;
|
|
22
|
-
height: number;
|
|
23
|
-
url: string;
|
|
24
|
-
width: number;
|
|
25
|
-
}
|
|
26
|
-
export interface OptionsWithValues {
|
|
27
|
-
name: string;
|
|
28
|
-
value: string;
|
|
29
|
-
}
|
|
1
|
+
export interface ShopifyCart {
|
|
2
|
+
/** Should be the lowest common denomination */
|
|
3
|
+
total_price: number;
|
|
4
|
+
item_count: number;
|
|
5
|
+
items?: ShopifyCartItem[];
|
|
6
|
+
}
|
|
7
|
+
export interface ShopifyCartItem {
|
|
8
|
+
id: number;
|
|
9
|
+
index: number;
|
|
10
|
+
position: number;
|
|
11
|
+
quantity: number;
|
|
12
|
+
variant_id: number;
|
|
13
|
+
key: string;
|
|
14
|
+
sku: string;
|
|
15
|
+
/** Should be the lowest common denomination */
|
|
16
|
+
final_line_price: number;
|
|
17
|
+
selling_plan_allocation?: any;
|
|
18
|
+
}
|
|
19
|
+
export interface FeaturedImage {
|
|
20
|
+
aspect_ratio: number;
|
|
21
|
+
alt: string;
|
|
22
|
+
height: number;
|
|
23
|
+
url: string;
|
|
24
|
+
width: number;
|
|
25
|
+
}
|
|
26
|
+
export interface OptionsWithValues {
|
|
27
|
+
name: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export interface ShopifyProduct {
|
|
2
|
-
id?: string;
|
|
3
|
-
image?: {
|
|
4
|
-
src: string;
|
|
5
|
-
};
|
|
6
|
-
title?: string;
|
|
7
|
-
variants?: ShopifyProductVariant[];
|
|
8
|
-
}
|
|
9
|
-
export interface ShopifyProductVariant {
|
|
10
|
-
id: number;
|
|
11
|
-
price: string;
|
|
12
|
-
}
|
|
1
|
+
export interface ShopifyProduct {
|
|
2
|
+
id?: string;
|
|
3
|
+
image?: {
|
|
4
|
+
src: string;
|
|
5
|
+
};
|
|
6
|
+
title?: string;
|
|
7
|
+
variants?: ShopifyProductVariant[];
|
|
8
|
+
}
|
|
9
|
+
export interface ShopifyProductVariant {
|
|
10
|
+
id: number;
|
|
11
|
+
price: string;
|
|
12
|
+
}
|