@abra-promotions/webhooks-for-tapcart 1.0.1 → 2.0.0-beta.1
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 +7 -44
- package/dist/index.cjs +1607 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -18
- package/dist/index.esm.js +1348 -2888
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -7
- package/dist/index.js +0 -3168
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# @abra/tapcart
|
|
1
|
+
# @abra-promotions/webhooks-for-tapcart
|
|
2
2
|
|
|
3
|
-
Abra Tapcart webhook
|
|
3
|
+
Abra Tapcart webhook integration for promotions.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @abra/tapcart
|
|
8
|
+
npm install @abra-promotions/webhooks-for-tapcart
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
useTapcart
|
|
13
|
+
React is passed in so the package has no imports of its own (a second copy of React would break hooks). useTapcart and tapcartData are provided by tapcart for every block.
|
|
14
14
|
|
|
15
15
|
### useAbra
|
|
16
16
|
|
|
17
17
|
Main hook for Abra promotion logic, use it within tapcart to parse any product into it's discounted version.
|
|
18
18
|
|
|
19
19
|
```javascript
|
|
20
|
-
import { useAbra } from "@abra/tapcart
|
|
20
|
+
import { useAbra } from "@abra-promotions/webhooks-for-tapcart";
|
|
21
21
|
|
|
22
22
|
const MyComponent = ({ useTapcart, tapcartData }) => {
|
|
23
23
|
//Initialize
|
|
24
|
-
const { abra } = useAbra({ useTapcart, tapcartData });
|
|
24
|
+
const { abra } = useAbra({ React, useTapcart, tapcartData });
|
|
25
25
|
|
|
26
26
|
// Use for promotion logic
|
|
27
27
|
const productWithDiscountedPrice = abra.getProductWithDiscount(product);
|
|
@@ -29,46 +29,9 @@ const MyComponent = ({ useTapcart, tapcartData }) => {
|
|
|
29
29
|
};
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
### useAbraActivate
|
|
33
|
-
|
|
34
|
-
Hook for activation logic, add it to the homepage, will enable and disable promotions
|
|
35
|
-
|
|
36
|
-
```javascript
|
|
37
|
-
import { useAbraActivate } from "@abra/tapcart-webhooks";
|
|
38
|
-
|
|
39
|
-
const MyComponent = ({ useTapcart, tapcartData }) => {
|
|
40
|
-
useAbraActivate({
|
|
41
|
-
useTapcart,
|
|
42
|
-
tapcartData,
|
|
43
|
-
discountCode, // (Optional) used for activating private promotions
|
|
44
|
-
displayToast, // (Optional) whether will show a banner after a promotion is activated
|
|
45
|
-
redirectPath, // (Optional) Wheather it should redirect to a specific page after activating
|
|
46
|
-
testDeviceId, // (Optional) Allows activating test promotion code on this device
|
|
47
|
-
testPromotionCode, // (Optional) Code that will activate on test device
|
|
48
|
-
autoApplyDiscount, // (Optional) Make it false for automatic discounts
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return <div>...</div>;
|
|
52
|
-
};
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### useAbraCart / AbraCartBlock
|
|
56
|
-
|
|
57
|
-
Cart-specific functionality: control discounts, attributes and gift items. load it in the cart page.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
import { useAbraCart } from "@abra/tapcart-webhooks";
|
|
61
|
-
|
|
62
|
-
const CartComponent = ({ useTapcart, tapcartData }) => {
|
|
63
|
-
useAbraCart({ useTapcart, tapcartData });
|
|
64
|
-
return <div>...</div>;
|
|
65
|
-
};
|
|
66
|
-
```
|
|
67
|
-
|
|
68
32
|
## Requirements
|
|
69
33
|
|
|
70
|
-
- React 16.8+
|
|
71
|
-
- @tapcart/mobile-components ^0.7.25
|
|
34
|
+
- React 16.8+ (passed in as `React`)
|
|
72
35
|
|
|
73
36
|
## License
|
|
74
37
|
|