@shoppexio/storefront 0.3.1 → 0.3.7
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 +22 -0
- package/dist/index.cjs +11737 -3791
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -6
- package/dist/index.d.ts +47 -6
- package/dist/index.js +11732 -3791
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -44,6 +44,28 @@ const result = await shoppex.validateCoupon('SAVE10', {
|
|
|
44
44
|
|
|
45
45
|
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.
|
|
46
46
|
|
|
47
|
+
## Live online users
|
|
48
|
+
|
|
49
|
+
The SDK can power a custom live online visitor counter. It provides the data; your storefront renders the badge.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import shoppex from '@shoppexio/storefront';
|
|
53
|
+
|
|
54
|
+
shoppex.init('my-store');
|
|
55
|
+
|
|
56
|
+
async function refreshLiveUsers() {
|
|
57
|
+
await shoppex.touchStorefrontPresence();
|
|
58
|
+
|
|
59
|
+
const result = await shoppex.getStorefrontOnlineUsers();
|
|
60
|
+
if (result.success && result.data) {
|
|
61
|
+
console.log(`${result.data.count} online`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await refreshLiveUsers();
|
|
66
|
+
setInterval(refreshLiveUsers, 30_000);
|
|
67
|
+
```
|
|
68
|
+
|
|
47
69
|
## Not this package
|
|
48
70
|
|
|
49
71
|
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.
|