@shopify/shop-minis-platform 0.21.0 → 0.22.0
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/package.json
CHANGED
|
@@ -248,6 +248,89 @@ export type AddToCartProductVariantResult =
|
|
|
248
248
|
| AddToCartAddedResult
|
|
249
249
|
| AddToCartNavigatedToProductResult
|
|
250
250
|
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// Buy Now Intent — buy_now:shopify/ProductVariant
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Data payload for the `buy_now:shopify/ProductVariant` intent.
|
|
257
|
+
*
|
|
258
|
+
* Sends the user to express checkout for a variant, bypassing the cart. If
|
|
259
|
+
* `productVariantId` is omitted (or `forceShow` is `true`), the host opens
|
|
260
|
+
* the same native variant selector sheet as the other variant intents — the
|
|
261
|
+
* user picks a variant and quantity, and the host then creates the checkout
|
|
262
|
+
* on confirm.
|
|
263
|
+
*
|
|
264
|
+
* For products outside Shop's catalog (referral products), the host
|
|
265
|
+
* navigates the user to the product's PDP instead.
|
|
266
|
+
*
|
|
267
|
+
* @publicDocs
|
|
268
|
+
*/
|
|
269
|
+
export interface BuyNowProductVariantParams {
|
|
270
|
+
/** The GID of the product. E.g. `gid://shopify/Product/123`. */
|
|
271
|
+
productId: string
|
|
272
|
+
/**
|
|
273
|
+
* The GID of the variant to buy. When provided, the host creates the
|
|
274
|
+
* checkout directly without showing the sheet. Omit to let the user pick.
|
|
275
|
+
*/
|
|
276
|
+
productVariantId?: string
|
|
277
|
+
/** Quantity to buy. Defaults to `1`. */
|
|
278
|
+
quantity?: number
|
|
279
|
+
/** Discount code to apply to the checkout. */
|
|
280
|
+
discountCode?: string
|
|
281
|
+
/** Allow-list of variant GIDs surfaced in the sheet. */
|
|
282
|
+
includedProductVariantGIDs?: string[]
|
|
283
|
+
/** Variant initially highlighted in the picker. */
|
|
284
|
+
initialVariantId?: string
|
|
285
|
+
/** Initial quantity in the stepper. Defaults to `quantity ?? 1`. */
|
|
286
|
+
initialQuantity?: number
|
|
287
|
+
/** Max quantity selectable in the stepper. */
|
|
288
|
+
maxQuantity?: number
|
|
289
|
+
/** Whether to show the quantity stepper. Defaults to `true`. */
|
|
290
|
+
showQuantity?: boolean
|
|
291
|
+
/**
|
|
292
|
+
* When `true`, always render the sheet — even for single-variant products
|
|
293
|
+
* or when `productVariantId` is supplied. Defaults to `false`.
|
|
294
|
+
*/
|
|
295
|
+
forceShow?: boolean
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Checkout opened for a concrete variant by `buy_now:shopify/ProductVariant`.
|
|
300
|
+
*/
|
|
301
|
+
export interface BuyNowCheckoutOpenedResult extends ProductVariantSelection {
|
|
302
|
+
/** Discriminator. The host opened express checkout for a variant. */
|
|
303
|
+
outcome: 'checkout_opened'
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Returned when the product cannot be bought from the mini (e.g. referral
|
|
308
|
+
* products outside Shop's catalog) and the host instead sent the user to
|
|
309
|
+
* the product's PDP. The mini should treat this as a successful hand-off.
|
|
310
|
+
*/
|
|
311
|
+
export interface BuyNowNavigatedToProductResult {
|
|
312
|
+
/** Discriminator. The host navigated the user to the PDP instead. */
|
|
313
|
+
outcome: 'navigated_to_product'
|
|
314
|
+
/** GID of the product the host navigated to. */
|
|
315
|
+
productId: string
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Successful payload returned from `buy_now:shopify/ProductVariant`.
|
|
320
|
+
*
|
|
321
|
+
* Discriminate via `data.outcome`:
|
|
322
|
+
* - `'checkout_opened'` — express checkout opened for a concrete variant;
|
|
323
|
+
* selection fields (`productVariantId`, `quantity`, `source`) are present.
|
|
324
|
+
* - `'navigated_to_product'` — the host could not buy this product (e.g.
|
|
325
|
+
* referral product on another merchant's storefront) and instead sent
|
|
326
|
+
* the user to the PDP. Only `productId` is present.
|
|
327
|
+
*
|
|
328
|
+
* @publicDocs
|
|
329
|
+
*/
|
|
330
|
+
export type BuyNowProductVariantResult =
|
|
331
|
+
| BuyNowCheckoutOpenedResult
|
|
332
|
+
| BuyNowNavigatedToProductResult
|
|
333
|
+
|
|
251
334
|
// ---------------------------------------------------------------------------
|
|
252
335
|
// Intent Registry
|
|
253
336
|
// ---------------------------------------------------------------------------
|
|
@@ -277,6 +360,12 @@ export interface IntentDefinitions {
|
|
|
277
360
|
data: AddToCartProductVariantParams
|
|
278
361
|
result: AddToCartProductVariantResult
|
|
279
362
|
}
|
|
363
|
+
buyNowProductVariant: {
|
|
364
|
+
action: 'buy_now'
|
|
365
|
+
type: 'shopify/ProductVariant'
|
|
366
|
+
data: BuyNowProductVariantParams
|
|
367
|
+
result: BuyNowProductVariantResult
|
|
368
|
+
}
|
|
280
369
|
}
|
|
281
370
|
|
|
282
371
|
export type IntentKey = keyof IntentDefinitions
|
|
@@ -296,6 +385,10 @@ export const INTENT_REGISTRY = {
|
|
|
296
385
|
action: 'add_to_cart',
|
|
297
386
|
type: 'shopify/ProductVariant',
|
|
298
387
|
},
|
|
388
|
+
buyNowProductVariant: {
|
|
389
|
+
action: 'buy_now',
|
|
390
|
+
type: 'shopify/ProductVariant',
|
|
391
|
+
},
|
|
299
392
|
} as const satisfies {
|
|
300
393
|
[K in IntentKey]: {
|
|
301
394
|
action: IntentDefinitions[K]['action']
|