@abra-promotions/webhooks-for-tapcart 1.0.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 +75 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.esm.js +3145 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +3168 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @abra/tapcart-webhooks
|
|
2
|
+
|
|
3
|
+
Abra Tapcart webhook integrations for promotions, cart management, and activation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @abra/tapcart-webhooks
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
useTapcart, and tapcartData are properties provided by tapcart for every block.
|
|
14
|
+
|
|
15
|
+
### useAbra
|
|
16
|
+
|
|
17
|
+
Main hook for Abra promotion logic, use it within tapcart to parse any product into it's discounted version.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
import { useAbra } from "@abra/tapcart-webhooks";
|
|
21
|
+
|
|
22
|
+
const MyComponent = ({ useTapcart, tapcartData }) => {
|
|
23
|
+
//Initialize
|
|
24
|
+
const { abra } = useAbra({ useTapcart, tapcartData });
|
|
25
|
+
|
|
26
|
+
// Use for promotion logic
|
|
27
|
+
const productWithDiscountedPrice = abra.getProductWithDiscount(product);
|
|
28
|
+
return <div>...</div>;
|
|
29
|
+
};
|
|
30
|
+
```
|
|
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
|
+
## Requirements
|
|
69
|
+
|
|
70
|
+
- React 16.8+
|
|
71
|
+
- @tapcart/mobile-components ^0.7.25
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
interface TapcartData {
|
|
2
|
+
integrations?: Array<{
|
|
3
|
+
name: string;
|
|
4
|
+
storeFrontAccessToken?: string;
|
|
5
|
+
storeUrl?: string;
|
|
6
|
+
}>;
|
|
7
|
+
appId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface TapcartActions {
|
|
11
|
+
action?: (
|
|
12
|
+
type: string,
|
|
13
|
+
data: any,
|
|
14
|
+
callbacks?: {
|
|
15
|
+
onSuccess?: (result: any) => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
},
|
|
18
|
+
) => void;
|
|
19
|
+
actions?: any;
|
|
20
|
+
variables?: any;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface UseAbraProps {
|
|
24
|
+
useTapcart: () => TapcartActions;
|
|
25
|
+
tapcartData: TapcartData;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface UseAbraActivateProps {
|
|
29
|
+
useTapcart: () => TapcartActions;
|
|
30
|
+
tapcartData: TapcartData;
|
|
31
|
+
testMode?: boolean;
|
|
32
|
+
testDeviceIds?: string[];
|
|
33
|
+
showBanner?: boolean;
|
|
34
|
+
autoApplyDiscount?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface UseAbraCartProps {
|
|
38
|
+
useTapcart: () => TapcartActions;
|
|
39
|
+
tapcartData: TapcartData;
|
|
40
|
+
addGiftOncePerSession?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare function useAbra(props: UseAbraProps): any;
|
|
44
|
+
declare function useAbraActivate(props: UseAbraActivateProps): any;
|
|
45
|
+
declare function useAbraCart(props: UseAbraCartProps): any;
|
|
46
|
+
|
|
47
|
+
export { useAbra, useAbraActivate, useAbraCart };
|
|
48
|
+
export type { TapcartActions, TapcartData, UseAbraActivateProps, UseAbraCartProps, UseAbraProps };
|