@disconetwork/shopify 0.0.7 → 0.0.9

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 CHANGED
@@ -70,3 +70,41 @@ Because the request is replaced as a whole:
70
70
  with `request`.
71
71
  - Include the order total (`order.amount`, `order.currencyCode`) and
72
72
  `purchases` if you want them used for ranking.
73
+
74
+ ## Prepurchase cash-back incentive
75
+
76
+ Two components offer shoppers cash back on their order. Render both:
77
+
78
+ | Component | Extension target(s) | What it does |
79
+ | --------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
80
+ | `DiscoPrepurchaseIncentive` | `purchase.checkout.reductions.render-before`, `purchase.checkout.actions.render-before` | The opt-in at checkout. |
81
+ | `DiscoPrepurchaseThankYou` | `purchase.thank-you.block.render` | Submits the order of a shopper who opted in, or offers the incentive to one who didn't. |
82
+
83
+ The checkout component only records the opt-in, in the
84
+ `prepurchase_incentive_opted_in` cart attribute. The thank-you component is what
85
+ submits the order, so without it opt-ins never become conversions.
86
+
87
+ ```tsx
88
+ import "@shopify/ui-extensions/preact";
89
+ import { render } from "preact";
90
+ import { DiscoPrepurchaseIncentive } from "@disconetwork/shopify";
91
+
92
+ export default () => {
93
+ render(<DiscoPrepurchaseIncentive apiKey="disco_pk_live_…" />, document.body);
94
+ };
95
+ ```
96
+
97
+ | Prop | Type | Description |
98
+ | -------- | -------- | -------------------------------------------------------------------- |
99
+ | `apiKey` | `string` | The merchant's public publisher-channel API key (`disco_pk_live_…`). |
100
+
101
+ - Requests go to Disco's production backend, authenticated by the key.
102
+ - Only live keys work for now: sandbox keys are refused.
103
+ - A component renders nothing when there is nothing to show, including when the
104
+ key is refused.
105
+ - Both extensions need `api_access = true` (for the product suggestions) and
106
+ `network_access = true` under `[extensions.capabilities]`.
107
+
108
+ Disco's own extension imports the same components from
109
+ `@disconetwork/shopify/internal`. There they take an `env` instead of an
110
+ `apiKey`, and the backend resolves the publisher from the shop.