@shoppexio/storefront 1.0.58 → 1.0.60
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/CHANGELOG.md +103 -0
- package/LICENSE +21 -0
- package/README.md +96 -180
- package/dist/chunk-ZVOFFURI.js +15364 -0
- package/dist/chunk-ZVOFFURI.js.map +1 -0
- package/dist/customer.cjs +16013 -1
- package/dist/customer.cjs.map +1 -1
- package/dist/{headless-customer.d.ts → customer.d.cts} +71 -62
- package/dist/customer.d.ts +336 -10
- package/dist/customer.js +726 -2
- package/dist/customer.js.map +1 -1
- package/dist/index.cjs +21533 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1979 -0
- package/dist/index.d.ts +1857 -49
- package/dist/index.js +6139 -0
- package/dist/index.js.map +1 -0
- package/package.json +18 -37
- package/dist/core/attribution.d.ts +0 -26
- package/dist/core/attribution.d.ts.map +0 -1
- package/dist/core/cache.d.ts +0 -26
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/client.d.ts +0 -18
- package/dist/core/client.d.ts.map +0 -1
- package/dist/core/config.d.ts +0 -10
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/endpoint.d.ts +0 -2
- package/dist/core/endpoint.d.ts.map +0 -1
- package/dist/core/errors.d.ts +0 -34
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/telemetry.d.ts +0 -20
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/typed-client.d.ts +0 -15
- package/dist/core/typed-client.d.ts.map +0 -1
- package/dist/customer.d.ts.map +0 -1
- package/dist/headless-customer.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/affiliates.d.ts +0 -32
- package/dist/modules/affiliates.d.ts.map +0 -1
- package/dist/modules/analytics.d.ts +0 -2
- package/dist/modules/analytics.d.ts.map +0 -1
- package/dist/modules/cart.d.ts +0 -62
- package/dist/modules/cart.d.ts.map +0 -1
- package/dist/modules/checkout.d.ts +0 -133
- package/dist/modules/checkout.d.ts.map +0 -1
- package/dist/modules/coupons.d.ts +0 -3
- package/dist/modules/coupons.d.ts.map +0 -1
- package/dist/modules/customer.d.ts +0 -148
- package/dist/modules/customer.d.ts.map +0 -1
- package/dist/modules/invoices.d.ts +0 -6
- package/dist/modules/invoices.d.ts.map +0 -1
- package/dist/modules/navigation.d.ts +0 -20
- package/dist/modules/navigation.d.ts.map +0 -1
- package/dist/modules/pages.d.ts +0 -10
- package/dist/modules/pages.d.ts.map +0 -1
- package/dist/modules/presence.d.ts +0 -12
- package/dist/modules/presence.d.ts.map +0 -1
- package/dist/modules/products.d.ts +0 -16
- package/dist/modules/products.d.ts.map +0 -1
- package/dist/modules/reviews.d.ts +0 -4
- package/dist/modules/reviews.d.ts.map +0 -1
- package/dist/modules/search.d.ts +0 -10
- package/dist/modules/search.d.ts.map +0 -1
- package/dist/modules/store.d.ts +0 -11
- package/dist/modules/store.d.ts.map +0 -1
- package/dist/modules/theme.d.ts +0 -27
- package/dist/modules/theme.d.ts.map +0 -1
- package/dist/shoppex.esm.js +0 -3
- package/dist/shoppex.esm.js.map +0 -1
- package/dist/shoppex.umd.js +0 -2
- package/dist/shoppex.umd.js.map +0 -1
- package/dist/types/api.d.ts +0 -766
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/cart.d.ts +0 -239
- package/dist/types/cart.d.ts.map +0 -1
- package/dist/types/config.d.ts +0 -18
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/theme-config.d.ts +0 -109
- package/dist/types/theme-config.d.ts.map +0 -1
- package/dist/utils/cart-line-id.d.ts +0 -5
- package/dist/utils/cart-line-id.d.ts.map +0 -1
- package/dist/utils/format.d.ts +0 -6
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/requested-currency.d.ts +0 -3
- package/dist/utils/requested-currency.d.ts.map +0 -1
- package/dist/utils/storage.d.ts +0 -10
- package/dist/utils/storage.d.ts.map +0 -1
- package/dist/utils/storefront-catalog.d.ts +0 -5
- package/dist/utils/storefront-catalog.d.ts.map +0 -1
- package/dist/utils/storefront-contact.d.ts +0 -32
- package/dist/utils/storefront-contact.d.ts.map +0 -1
- package/dist/utils/storefront-custom-fields.d.ts +0 -13
- package/dist/utils/storefront-custom-fields.d.ts.map +0 -1
- package/dist/utils/storefront-search.d.ts +0 -22
- package/dist/utils/storefront-search.d.ts.map +0 -1
- package/dist/utils/storefront-stock.d.ts +0 -14
- package/dist/utils/storefront-stock.d.ts.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.60
|
|
4
|
+
|
|
5
|
+
- Reject post-purchase `redirectUrl` values that still contain unresolved template placeholders.
|
|
6
|
+
|
|
7
|
+
## 1.0.59
|
|
8
|
+
|
|
9
|
+
- Add `redirectUrl` to `checkout()` and `buildCheckoutUrl()` for channel-specific post-purchase returns.
|
|
10
|
+
- Keep `currency` and the post-purchase redirect in the same idempotent invoice-create intent.
|
|
11
|
+
- Publish npm from the public Storefront wrapper and keep the internal CDN implementation private.
|
|
12
|
+
- Correct the cart custom-field and `line_id` examples in the npm and Mintlify documentation.
|
|
13
|
+
|
|
14
|
+
## 1.0.58
|
|
15
|
+
|
|
16
|
+
- Add buyer-selected `currency` to `checkout()` and `buildCheckoutUrl()` so quote and invoice creation use the same currency.
|
|
17
|
+
|
|
18
|
+
## 1.0.57
|
|
19
|
+
|
|
20
|
+
- Preserve checkout-origin Turnstile challenge details on `buildCheckoutUrl()` errors so headless callers can render the proof and retry.
|
|
21
|
+
|
|
22
|
+
## 1.0.56
|
|
23
|
+
|
|
24
|
+
- Retain checkout idempotency keys until invoice-create responses are both parseable and definitive, preventing duplicate orders after truncated response bodies.
|
|
25
|
+
- Expose server-requested Turnstile challenges so official storefront checkout surfaces can collect and resubmit human-verification proofs.
|
|
26
|
+
|
|
27
|
+
## 1.0.55
|
|
28
|
+
|
|
29
|
+
- Retain independent checkout idempotency keys for overlapping buyer intents, so an ambiguous response cannot duplicate an earlier invoice when another checkout starts concurrently.
|
|
30
|
+
|
|
31
|
+
## 1.0.54
|
|
32
|
+
|
|
33
|
+
- Reuse checkout idempotency keys after ambiguous transport failures, while rotating them after definitive responses or changed buyer intent.
|
|
34
|
+
- Forward optional `storefront_checkout` Turnstile proofs without changing the idempotent create command.
|
|
35
|
+
|
|
36
|
+
## 1.0.51
|
|
37
|
+
|
|
38
|
+
- Send a fresh idempotency key for every storefront checkout action so network retries replay safely without reviving an older abandoned cart.
|
|
39
|
+
|
|
40
|
+
## 1.0.50
|
|
41
|
+
|
|
42
|
+
- Expose authoritative paid and due amounts in customer order details.
|
|
43
|
+
- Expose volume discounts as a separate buyer-facing price adjustment.
|
|
44
|
+
|
|
45
|
+
## 1.0.49
|
|
46
|
+
|
|
47
|
+
- Expose the complete customer-order pricing breakdown, including buyer-paid processing fees.
|
|
48
|
+
|
|
49
|
+
## 1.0.48
|
|
50
|
+
|
|
51
|
+
- Preserve Headless customer review scores by exposing the stored `1`, `3`, and `5` sentiment levels.
|
|
52
|
+
- Count the 256-character review limit by visible Unicode characters, including joined emoji.
|
|
53
|
+
|
|
54
|
+
## 1.0.47
|
|
55
|
+
|
|
56
|
+
- Add authenticated `orderReview()` and `submitOrderReview()` methods to the Headless Customer SDK.
|
|
57
|
+
- Scope review reads and writes to the signed-in customer's own shop and order.
|
|
58
|
+
|
|
59
|
+
## 1.0.46
|
|
60
|
+
|
|
61
|
+
- Headless customer dashboards now expose Shoppex file deliverables as authenticated `downloadIndex` values instead of hosted-portal-only URLs.
|
|
62
|
+
|
|
63
|
+
## 1.0.45
|
|
64
|
+
|
|
65
|
+
- Expand `@shoppexio/storefront/customer` from order history to buyer-safe customer portal parity: account settings, support, licenses, wallet checkout handoffs, subscriptions, replacements, loyalty, warranties, favorites, affiliate links, and reseller flows.
|
|
66
|
+
- Validate every new customer response against the shared Shoppex wire contracts.
|
|
67
|
+
- Publish the matching customer portal wire contracts with the SDK release.
|
|
68
|
+
- Keep direct money movement, provider redirects, password/session controls, reseller balance spending, and durable API-key creation behind Shoppex-controlled portal handoffs.
|
|
69
|
+
|
|
70
|
+
## 1.0.44
|
|
71
|
+
|
|
72
|
+
- Actually ship the `@shoppexio/storefront/customer` subpath in the published tarball: 1.0.42/1.0.43 documented the entry, but the release pipeline packs `packages/sdk`, whose exports map did not carry it (`ERR_PACKAGE_PATH_NOT_EXPORTED`).
|
|
73
|
+
|
|
74
|
+
## 1.0.43
|
|
75
|
+
|
|
76
|
+
- Require an explicit file index for customer downloads so the SDK never guesses which delivered file to return.
|
|
77
|
+
- Expose safe `downloadIndex` descriptors for headless order details.
|
|
78
|
+
- Keep the local customer session when remote logout fails, so revocation can be retried.
|
|
79
|
+
|
|
80
|
+
## 1.0.42
|
|
81
|
+
|
|
82
|
+
- Add `@shoppexio/storefront/customer` for custom OTP login, customer details, order history, order details, and downloads.
|
|
83
|
+
- Add opt-in `rememberMe` sessions for up to 30 days.
|
|
84
|
+
- Return safe `downloadIndex` descriptors for delivered files and retain the local session when logout revocation can be retried.
|
|
85
|
+
|
|
86
|
+
## 0.3.1
|
|
87
|
+
|
|
88
|
+
- Add `program_enabled` to affiliate validation responses.
|
|
89
|
+
- Clarify disabled affiliate program handling for headless storefronts.
|
|
90
|
+
|
|
91
|
+
## 0.3.0
|
|
92
|
+
|
|
93
|
+
- Publish the active Storefront SDK runtime under `@shoppexio/storefront`.
|
|
94
|
+
- Include cart coupon validation types for `{ productId, variantId }`.
|
|
95
|
+
|
|
96
|
+
## 0.1.1
|
|
97
|
+
|
|
98
|
+
- Package metadata and release polish.
|
|
99
|
+
|
|
100
|
+
## 0.1.0
|
|
101
|
+
|
|
102
|
+
- first public storefront package release
|
|
103
|
+
- typed package entrypoint for the existing Shoppex storefront runtime
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shoppex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,235 +1,151 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @shoppexio/storefront
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official JavaScript storefront SDK for Shoppex.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use this package when you want to embed Shoppex products, cart behavior, and hosted checkout into a custom frontend.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Good fit
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<script src="https://cdn.shoppex.io/sdk/v0.3/shoppex.umd.js"></script>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Use the moving minor channel for managed updates.
|
|
14
|
-
Simple example: `v0.3` moves to the latest `0.3.x` release.
|
|
15
|
-
|
|
16
|
-
If you need a locked production rollout, pin an exact version:
|
|
9
|
+
Use this package for:
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`/sdk/latest/` stays available for internal and development usage only.
|
|
11
|
+
- product loading
|
|
12
|
+
- cart state
|
|
13
|
+
- checkout redirects
|
|
14
|
+
- storefront helpers
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
## Install
|
|
25
17
|
|
|
26
18
|
```bash
|
|
27
19
|
npm install @shoppexio/storefront
|
|
28
20
|
```
|
|
29
21
|
|
|
30
|
-
## Quick
|
|
31
|
-
|
|
32
|
-
```html
|
|
33
|
-
<script src="https://cdn.shoppex.io/sdk/v0.3/shoppex.umd.js"></script>
|
|
34
|
-
<script>
|
|
35
|
-
// Initialize with your store slug
|
|
36
|
-
shoppex.init('my-store');
|
|
37
|
-
|
|
38
|
-
// Get store info
|
|
39
|
-
shoppex.getStore().then(function(result) {
|
|
40
|
-
if (result.success) {
|
|
41
|
-
console.log('Store:', result.data.name);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Add product to cart
|
|
46
|
-
shoppex.addToCart('product-id', 'variant-id', 2);
|
|
47
|
-
|
|
48
|
-
// Checkout (redirects to hosted checkout)
|
|
49
|
-
document.getElementById('checkout-btn').onclick = function() {
|
|
50
|
-
shoppex.checkout();
|
|
51
|
-
};
|
|
52
|
-
</script>
|
|
53
|
-
```
|
|
22
|
+
## Quick start
|
|
54
23
|
|
|
55
|
-
|
|
24
|
+
```ts
|
|
25
|
+
import shoppex from '@shoppexio/storefront';
|
|
56
26
|
|
|
57
|
-
|
|
58
|
-
<script type="module">
|
|
59
|
-
import shoppex from 'https://cdn.shoppex.io/sdk/v0.3/shoppex.esm.js';
|
|
60
|
-
|
|
61
|
-
shoppex.init('my-store');
|
|
62
|
-
|
|
63
|
-
const store = await shoppex.getStore();
|
|
64
|
-
const products = await shoppex.getProducts();
|
|
65
|
-
|
|
66
|
-
shoppex.addToCart(products.data[0].uniqid, 'default', 1);
|
|
67
|
-
|
|
68
|
-
await shoppex.checkout();
|
|
69
|
-
</script>
|
|
70
|
-
```
|
|
27
|
+
shoppex.init('my-store');
|
|
71
28
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// Simple init
|
|
78
|
-
shoppex.init('store-slug');
|
|
79
|
-
|
|
80
|
-
// With options
|
|
81
|
-
shoppex.init({
|
|
82
|
-
storeId: 'store-slug',
|
|
83
|
-
locale: 'de',
|
|
84
|
-
currency: 'EUR'
|
|
29
|
+
const products = await shoppex.getProducts();
|
|
30
|
+
shoppex.addToCart(products.data?.[0]?.uniqid ?? '', 'default', 1, {
|
|
31
|
+
custom_fields: {
|
|
32
|
+
customer_note: 'Gift order',
|
|
33
|
+
},
|
|
85
34
|
});
|
|
35
|
+
await shoppex.checkout();
|
|
86
36
|
```
|
|
87
37
|
|
|
88
|
-
|
|
38
|
+
Cart items use a stable `line_id`. Use this identifier for cart updates and
|
|
39
|
+
removals because one product can have multiple cart configurations.
|
|
89
40
|
|
|
90
|
-
```
|
|
91
|
-
const
|
|
92
|
-
// → { success: true, data: { id, name, currency, ... } }
|
|
41
|
+
```ts
|
|
42
|
+
const [line] = shoppex.getCart();
|
|
93
43
|
|
|
94
|
-
|
|
95
|
-
|
|
44
|
+
if (line) {
|
|
45
|
+
shoppex.updateCartItem(line.line_id, { quantity: 2 });
|
|
46
|
+
shoppex.removeFromCart(line.line_id);
|
|
47
|
+
}
|
|
96
48
|
```
|
|
97
49
|
|
|
98
|
-
|
|
50
|
+
## Multi-currency checkout
|
|
99
51
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// → { success: true, data: [{ uniqid, title, price, images[], variants[], addons[], faqs[], feedback, ... }] }
|
|
103
|
-
// variants[] mirrors price_variants[] (legacy field); both are present for compatibility.
|
|
104
|
-
// images[] contains the full product gallery; the first entry is the primary image.
|
|
105
|
-
|
|
106
|
-
const product = await shoppex.getProduct('product-id-or-slug');
|
|
107
|
-
const categories = await shoppex.getCategories();
|
|
108
|
-
```
|
|
52
|
+
When buyers can select a storefront currency, quote the cart and create the
|
|
53
|
+
invoice with the same currency:
|
|
109
54
|
|
|
110
|
-
|
|
55
|
+
```ts
|
|
56
|
+
const selectedCurrency = 'EUR';
|
|
57
|
+
await shoppex.quoteCart(undefined, selectedCurrency);
|
|
111
58
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
shoppex.addToCart('productId', 'variantId', 2);
|
|
115
|
-
|
|
116
|
-
// With Shoppex features (addons, custom fields)
|
|
117
|
-
shoppex.addToCart('productId', 'variantId', 1, {
|
|
118
|
-
addons: [
|
|
119
|
-
{ id: 'addon_gift_wrap', quantity: 1 }
|
|
120
|
-
],
|
|
121
|
-
customFields: {
|
|
122
|
-
'engraving_text': 'Happy Birthday!'
|
|
123
|
-
},
|
|
124
|
-
priceVariantId: 'price_premium'
|
|
59
|
+
const checkoutUrl = await shoppex.buildCheckoutUrl({
|
|
60
|
+
currency: selectedCurrency,
|
|
125
61
|
});
|
|
126
|
-
|
|
127
|
-
// Get cart
|
|
128
|
-
const cart = shoppex.getCart();
|
|
129
|
-
const itemCount = shoppex.getCartItemCount();
|
|
130
|
-
|
|
131
|
-
// Manage cart
|
|
132
|
-
shoppex.removeFromCart('productId', 'variantId');
|
|
133
|
-
shoppex.clearCart();
|
|
134
|
-
|
|
135
|
-
// Backup/restore (useful for error recovery)
|
|
136
|
-
shoppex.createCartBackup();
|
|
137
|
-
shoppex.restoreCartFromBackup();
|
|
138
62
|
```
|
|
139
63
|
|
|
140
|
-
|
|
64
|
+
After a currency change, quote the cart again before checkout. Quote tokens are
|
|
65
|
+
currency-bound; Shoppex rejects a mismatch as
|
|
66
|
+
`errors.checkout.quote_token_stale` instead of creating an invoice for a total
|
|
67
|
+
the buyer did not approve.
|
|
141
68
|
|
|
142
|
-
|
|
143
|
-
// Simple checkout (auto-redirects)
|
|
144
|
-
await shoppex.checkout();
|
|
145
|
-
|
|
146
|
-
// With coupon
|
|
147
|
-
await shoppex.checkout('SAVE20');
|
|
69
|
+
## Custom customer account
|
|
148
70
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```
|
|
71
|
+
Build your own OTP login, order history, and download UI without adding a
|
|
72
|
+
merchant API key or custom backend. Headless customer accounts are available on
|
|
73
|
+
every Shoppex plan; only the separate Headless Checkout SDK requires Business:
|
|
153
74
|
|
|
154
|
-
|
|
75
|
+
```ts
|
|
76
|
+
import { createCustomerClient } from '@shoppexio/storefront/customer';
|
|
155
77
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
variantId: 'variant-id',
|
|
78
|
+
const customer = createCustomerClient({
|
|
79
|
+
shop: 'my-store',
|
|
80
|
+
publishableKey: 'pk_live_your_key',
|
|
160
81
|
});
|
|
161
|
-
// -> { success: true, data: { valid: true, discount: 20, restriction_scope: 'variants' } }
|
|
162
|
-
```
|
|
163
82
|
|
|
164
|
-
|
|
83
|
+
await customer.requestOtp('buyer@example.com');
|
|
84
|
+
await customer.verifyOtp('buyer@example.com', '123456', { rememberMe: true });
|
|
165
85
|
|
|
166
|
-
|
|
86
|
+
const orders = await customer.orders();
|
|
87
|
+
const firstOrder = orders.invoices[0];
|
|
167
88
|
|
|
168
|
-
|
|
169
|
-
const
|
|
89
|
+
if (firstOrder) {
|
|
90
|
+
const order = await customer.order(firstOrder.uniqid);
|
|
170
91
|
|
|
171
|
-
|
|
172
|
-
|
|
92
|
+
for (const item of order.lineItems) {
|
|
93
|
+
const instructions = item.deliveryText ?? item.product?.serviceText;
|
|
94
|
+
console.log(item.deliveryStatus, instructions, item.deliverySummary);
|
|
95
|
+
}
|
|
173
96
|
}
|
|
174
|
-
|
|
175
|
-
await shoppex.checkout({
|
|
176
|
-
coupon: 'SAVE20',
|
|
177
|
-
affiliateCode: affiliate.data?.affiliate_code,
|
|
178
|
-
});
|
|
179
97
|
```
|
|
180
98
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const reviews = await shoppex.getShopReviews();
|
|
185
|
-
// → { success: true, data: [{ rating, comment, ... }] }
|
|
186
|
-
```
|
|
99
|
+
The publishable key and current browser origin must be configured under
|
|
100
|
+
**Settings -> Developer -> Headless**. `rememberMe` is opt-in and keeps
|
|
101
|
+
the buyer signed in for up to 30 days.
|
|
187
102
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const status = await shoppex.getInvoiceStatus('invoice-id');
|
|
193
|
-
```
|
|
103
|
+
The order detail includes delivery status, service instructions, codes, serials,
|
|
104
|
+
notes, links, and file indexes. Delivery content appears only after Shoppex marks
|
|
105
|
+
the item as delivered. Sanitize rich-text delivery instructions before you render
|
|
106
|
+
them as HTML.
|
|
194
107
|
|
|
195
|
-
|
|
108
|
+
## Coupon validation
|
|
196
109
|
|
|
197
|
-
|
|
198
|
-
const formatter = shoppex.createFormatter('USD', 'en-US');
|
|
199
|
-
formatter.format(29.99); // → "$29.99"
|
|
110
|
+
Use the options form when validating a coupon for a selected product variant:
|
|
200
111
|
|
|
201
|
-
|
|
202
|
-
shoppex.
|
|
112
|
+
```ts
|
|
113
|
+
const result = await shoppex.validateCoupon('SAVE10', {
|
|
114
|
+
productId: 'prod_abc123',
|
|
115
|
+
variantId: 'variant_lifetime',
|
|
116
|
+
});
|
|
203
117
|
```
|
|
204
118
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
The SDK supports Shoppex-specific features not found in competitors:
|
|
119
|
+
Calling `validateCoupon(code)` without options validates against the current SDK cart. Affiliate/referral codes are separate and should use `validateAffiliateCode` or `applyAffiliateCode`. If `program_enabled` is false in an affiliate validation response, the shop-level affiliate program is disabled even if individual links exist.
|
|
208
120
|
|
|
209
|
-
|
|
210
|
-
|---------|-------------|
|
|
211
|
-
| **Product Addons** | Express shipping, gift wrap, etc. |
|
|
212
|
-
| **Custom Fields** | Customer input (engraving, gift message) |
|
|
213
|
-
| **Price Variants** | Different pricing tiers |
|
|
214
|
-
| **Multiple Gateways** | Stripe, PayPal, Crypto |
|
|
121
|
+
## Live online users
|
|
215
122
|
|
|
216
|
-
|
|
123
|
+
The SDK can power a custom live online visitor counter. It provides the data; your storefront renders the badge.
|
|
217
124
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
- Safari 13+
|
|
221
|
-
- Edge 80+
|
|
125
|
+
```ts
|
|
126
|
+
import shoppex from '@shoppexio/storefront';
|
|
222
127
|
|
|
223
|
-
|
|
128
|
+
shoppex.init('my-store');
|
|
224
129
|
|
|
225
|
-
|
|
130
|
+
async function refreshLiveUsers() {
|
|
131
|
+
await shoppex.touchStorefrontPresence();
|
|
226
132
|
|
|
227
|
-
|
|
228
|
-
|
|
133
|
+
const result = await shoppex.getStorefrontOnlineUsers();
|
|
134
|
+
if (result.success && result.data) {
|
|
135
|
+
console.log(`${result.data.count} online`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
229
138
|
|
|
230
|
-
|
|
139
|
+
await refreshLiveUsers();
|
|
140
|
+
setInterval(refreshLiveUsers, 30_000);
|
|
231
141
|
```
|
|
232
142
|
|
|
233
|
-
##
|
|
143
|
+
## Not this package
|
|
144
|
+
|
|
145
|
+
If you want the authenticated Developer API wrapper for backend integrations, use `@shoppexio/sdk`. Do not ship `@shoppexio/sdk` in a browser bundle; use this Storefront SDK for headless storefronts.
|
|
146
|
+
|
|
147
|
+
## Docs
|
|
234
148
|
|
|
235
|
-
|
|
149
|
+
- Storefront docs: [docs.shoppex.io/sdk/introduction](https://docs.shoppex.io/sdk/introduction)
|
|
150
|
+
- Installation: [docs.shoppex.io/sdk/installation](https://docs.shoppex.io/sdk/installation)
|
|
151
|
+
- Headless customer accounts: [docs.shoppex.io/developers/headless/customer-accounts](https://docs.shoppex.io/developers/headless/customer-accounts)
|