@moonbase.sh/storefront 2.9.1 → 3.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 +54 -0
- package/dist/moonbase.d.ts +36 -1
- package/dist/moonbase.js +7163 -6926
- package/dist/moonbase.umd.cjs +16 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -99,6 +99,9 @@ Moonbase.configure({
|
|
|
99
99
|
cart: {
|
|
100
100
|
quantity: 'single',
|
|
101
101
|
},
|
|
102
|
+
checkout: {
|
|
103
|
+
redirect: 'auto',
|
|
104
|
+
},
|
|
102
105
|
pricing: {
|
|
103
106
|
trailingZeros: 'always',
|
|
104
107
|
currencyDisplay: 'code',
|
|
@@ -116,6 +119,27 @@ Moonbase.configure({
|
|
|
116
119
|
})
|
|
117
120
|
```
|
|
118
121
|
|
|
122
|
+
`checkout.redirect` decides where checkout happens:
|
|
123
|
+
|
|
124
|
+
| Value | Behavior |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `'auto'` (default) | Overlay on desktop, full-page redirect to the hosted checkout on mobile. |
|
|
127
|
+
| `'always'` / `true` | Always redirect to the hosted checkout. |
|
|
128
|
+
| `'never'` / `false` | Always use the overlay. |
|
|
129
|
+
|
|
130
|
+
The overlay keeps buyers on your page, but it cannot show Apple Pay or Google Pay.
|
|
131
|
+
Those wallets require the *top-level* page's domain to be a registered payment-method
|
|
132
|
+
domain, and for an embedded storefront that is your own site, not Moonbase's — no
|
|
133
|
+
amount of configuration on our side changes that. Redirecting makes the hosted
|
|
134
|
+
checkout the top-level document, so the wallets appear. `'auto'` takes that trade only
|
|
135
|
+
on mobile, where wallet usage concentrates, and keeps the overlay everywhere else.
|
|
136
|
+
Phones redirect; tablets and desktops get the overlay.
|
|
137
|
+
|
|
138
|
+
A redirected buyer is always brought back to your page once they've paid, so
|
|
139
|
+
`checkout-completed` fires and the cart clears exactly as it does with the overlay.
|
|
140
|
+
The hosted checkout stays anonymous for the trip — it prefills from the order rather
|
|
141
|
+
than signing the buyer into a Moonbase account, matching the overlay's behavior.
|
|
142
|
+
|
|
119
143
|
`pricing.trailingZeros` controls how whole prices render. The default `'auto'`
|
|
120
144
|
drops the decimals — a $10.00 product shows as `$10`. Set it to `'always'` to keep
|
|
121
145
|
the currency's own fraction digits instead (`$10.00`, and still `¥1000` for
|
|
@@ -156,6 +180,36 @@ shows in the totals, the nudge does not. With no cart-wide offer configured on y
|
|
|
156
180
|
storefront, the meter never renders either way. `savingLabel` names the saving row
|
|
157
181
|
in the cart totals.
|
|
158
182
|
|
|
183
|
+
Offers keyed off a single product work the other way round: the widget surfaces one
|
|
184
|
+
as a card in the cart, and the buyer presses it to take the offer. That card is
|
|
185
|
+
hidden once the offer's product is already in the cart, so a buyer who adds that
|
|
186
|
+
product *before* the one that qualifies them for the offer never gets a chance to
|
|
187
|
+
claim it. `cart.offers.autoApply` closes that gap.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
Moonbase.configure({
|
|
191
|
+
cart: {
|
|
192
|
+
offers: {
|
|
193
|
+
autoApply: true,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
})
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
With it on, the cart applies an eligible offer to the product it discounts by
|
|
200
|
+
itself, once every product that offer names is in the cart. It never adds anything
|
|
201
|
+
to the cart on the buyer's behalf, and it never takes an offer the cart is still
|
|
202
|
+
selling: an offer naming a product they have not added keeps showing as a card and
|
|
203
|
+
still takes a press, since an offer is good for one line only and applying it early
|
|
204
|
+
would take that card away. It never replaces an offer already on a line either. Off
|
|
205
|
+
by default.
|
|
206
|
+
|
|
207
|
+
That governs when an offer is taken rather than where it stays: remove one of the
|
|
208
|
+
products that qualified an offer and it stays on the line it landed on, just as an
|
|
209
|
+
offer claimed from a card does. A buyer can already put a multi-target offer on one
|
|
210
|
+
product and never add the other, so nothing here is a cart they couldn't have built
|
|
211
|
+
by hand.
|
|
212
|
+
|
|
159
213
|
You can also control where the widget mounts by providing `target`.
|
|
160
214
|
|
|
161
215
|
## Promotions
|
package/dist/moonbase.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ActivationRequestFulfillmentType } from '@moonbase.sh/vue';
|
|
2
2
|
import { CartItem } from '@moonbase.sh/vue';
|
|
3
|
+
import { CheckoutRedirectMode } from '@moonbase.sh/vue';
|
|
3
4
|
import { Download } from '@moonbase.sh/vue';
|
|
4
5
|
import { InjectionKey } from 'vue';
|
|
5
6
|
import { MarketingConsentType } from '@moonbase.sh/vue';
|
|
@@ -346,7 +347,18 @@ export declare interface MoonbaseOptions {
|
|
|
346
347
|
};
|
|
347
348
|
};
|
|
348
349
|
checkout: {
|
|
349
|
-
|
|
350
|
+
/**
|
|
351
|
+
* Where checkout happens.
|
|
352
|
+
*
|
|
353
|
+
* - `'auto'` (default) — overlay on desktop, full-page redirect on mobile.
|
|
354
|
+
* The redirect is what makes Apple Pay and Google Pay available: those
|
|
355
|
+
* wallets require the *top-level* domain to be a registered payment-method
|
|
356
|
+
* domain, which it never is when checkout runs in an iframe on the host's
|
|
357
|
+
* own site.
|
|
358
|
+
* - `'always'` / `true` — always redirect to the hosted checkout.
|
|
359
|
+
* - `'never'` / `false` — always use the overlay, wallets included in the cost.
|
|
360
|
+
*/
|
|
361
|
+
redirect: boolean | CheckoutRedirectMode;
|
|
350
362
|
};
|
|
351
363
|
cart: {
|
|
352
364
|
quantity: 'selectable' | 'single';
|
|
@@ -356,6 +368,29 @@ export declare interface MoonbaseOptions {
|
|
|
356
368
|
};
|
|
357
369
|
offers: {
|
|
358
370
|
label: string;
|
|
371
|
+
/**
|
|
372
|
+
* Apply an eligible offer to the cart line it targets without waiting for the buyer to press
|
|
373
|
+
* its upsell card. Applies to offers keyed off a single product; offers keyed off the cart as a
|
|
374
|
+
* whole have always applied themselves; see `cartWide` below.
|
|
375
|
+
*
|
|
376
|
+
* Off by default: an offer is a merchant's to give, and applying one unasked discounts a cart
|
|
377
|
+
* the buyer never asked to have discounted. Turn it on to close the one case the upsell cannot
|
|
378
|
+
* reach. The card is hidden once the offer's targets are in the cart, so a cart assembled in
|
|
379
|
+
* that order (target first, then the item that satisfies the offer's condition) leaves a real
|
|
380
|
+
* discount with no way of being claimed.
|
|
381
|
+
*
|
|
382
|
+
* Never adds anything to the cart, and never takes an offer the cart is still selling: an offer
|
|
383
|
+
* that names a product the buyer has not added keeps showing as a card and still takes a press,
|
|
384
|
+
* since an offer is good for one line only and spending it early would remove that card. Nor
|
|
385
|
+
* does it replace an offer a line already carries.
|
|
386
|
+
*
|
|
387
|
+
* That last part governs when an offer is taken, not where it stays. Remove one of the products
|
|
388
|
+
* that qualified an offer and it stays on the line it landed on, exactly as an offer claimed
|
|
389
|
+
* from the card would. A buyer can put a multi-target offer on one product and never add the
|
|
390
|
+
* other, so this is a cart they could have built by hand. Losing the discount because of an
|
|
391
|
+
* unrelated removal would be the surprising behaviour, not keeping it.
|
|
392
|
+
*/
|
|
393
|
+
autoApply: boolean;
|
|
359
394
|
/**
|
|
360
395
|
* Offers keyed off the cart as a whole, such as "10% off orders over $50", rather than off a single
|
|
361
396
|
* product. They apply themselves the moment the cart qualifies; there is nothing for the buyer
|