@abra-promotions/webhooks-for-tapcart 2.0.0-beta.4 → 2.0.0-beta.5
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 +49 -0
- package/dist/index.cjs +4578 -1101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +320 -2
- package/dist/index.esm.js +4501 -1102
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,6 +29,55 @@ const MyComponent = ({ useTapcart, tapcartData }) => {
|
|
|
29
29
|
};
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
### Shared helpers for Abra's blocks
|
|
33
|
+
|
|
34
|
+
Abra's own blocks (Activate, Activate Private, Cart, Banners) import these instead of keeping
|
|
35
|
+
copies:
|
|
36
|
+
|
|
37
|
+
- `slugify(text)`: Abra's Tapcart metafield key for a promotion title or tag visibility.
|
|
38
|
+
- Promotions: `parsePromotion` (any non-draft promotion, what Abra Activate stores, so a
|
|
39
|
+
scheduled one turns on at its start date) and `parsePromotionIfActive` (only while ACTIVE or
|
|
40
|
+
SCHEDULED and within its dates, what the blocks that render it use).
|
|
41
|
+
- Storage (`STORAGE_KEYS` and read/write helpers, all taking the object `useTapcart()` returns):
|
|
42
|
+
`abra` (`readAbraSession`, `readStoredPromotion`, `readActivePromotion`, `writeAbraSession`),
|
|
43
|
+
`abra.giftsAdded` (`readGiftsAdded`, `writeGiftsAdded`, `recordGiftAdded`, `clearGiftsAdded`),
|
|
44
|
+
`abra.selectedGiftVariantIds` and `abra.private-promotion`.
|
|
45
|
+
- Products: `fetchProducts({ ids | handles, storeUrl, storeFrontAccessToken, country, details })`
|
|
46
|
+
and the `useProducts({ React, ... })` hook. `details` adds titles, variant images and selling
|
|
47
|
+
plans. A query whose country fails is retried without it.
|
|
48
|
+
- Gifts: `getBxgyGetsCards`, `extractNumericSellingPlanId`, `toGiftPurchaseType`,
|
|
49
|
+
`resolveGiftSellingPlanId`.
|
|
50
|
+
- Buy X get Y (`bxgy.js`), ported from the abra repo's theme extension (`BxgyDiscount`) so the
|
|
51
|
+
app agrees with the storefront: `toBxgyLine(s)` turn any cart item shape into one line shape
|
|
52
|
+
(Abra gift lines, marked by the `__abra` attribute, never count); `areAllBxgyCardsMet`,
|
|
53
|
+
`getBxgyTimesMet` (gets-side capacity and `maxApplicationsPerOrder`),
|
|
54
|
+
`wouldAddingTriggerNewBxgyApplication` (product-page price previews), `getBxgyProgress`
|
|
55
|
+
(banner progress) and the matchers. Cases in `bxgy.test.js` marked "theme:" are the theme's
|
|
56
|
+
own tests.
|
|
57
|
+
|
|
58
|
+
### Discount strategies
|
|
59
|
+
|
|
60
|
+
Every discount family has a strategy (`strategyFor(discount)`, `src/strategies/`) ported from the
|
|
61
|
+
Shopify function that decides what checkout grants (the storefront theme for native Shopify codes
|
|
62
|
+
and display-only rules). Where the theme and a function disagree, the function wins, so the app
|
|
63
|
+
never shows a price or gift checkout won't honor. They all work on one cart-line shape
|
|
64
|
+
(`toCartLines`) and share the entitlement matcher (`matchesEntitledScope`):
|
|
65
|
+
|
|
66
|
+
- `priceDiscount` — the per-unit discount a product page shows (used by `getBiggestDiscount`,
|
|
67
|
+
which then applies Shopify's combining rules and tag stacking from `price-selection.js`).
|
|
68
|
+
- `codeApplies` — whether CartBlock keeps the discount code on the cart.
|
|
69
|
+
- `giftAwards` / `giftOptions` / `giftRules` — the gifts granted now and the freeGiftSettings.
|
|
70
|
+
- `progress` — banner numbers (tiers and gifts).
|
|
71
|
+
|
|
72
|
+
`readActivePromotion` filters the stored promotion's discounts at read time (`eligibility.js`:
|
|
73
|
+
dates, markets, POS-only, bulk codes, customer restrictions). Each test file ports the
|
|
74
|
+
function's and the theme's own cases (marked "function:" / "theme:").
|
|
75
|
+
|
|
76
|
+
Not handled yet: currency conversion. Thresholds and fixed amounts are compared in the shop's
|
|
77
|
+
currency; every strategy takes `opts.currencyRate` for when the app can get a rate.
|
|
78
|
+
|
|
79
|
+
Adding an export a block imports means raising `BLOCKS_NEED_PKG` in `scripts/lib/code.mjs`.
|
|
80
|
+
|
|
32
81
|
## Requirements
|
|
33
82
|
|
|
34
83
|
- React 16.8+ (passed in as `React`)
|