salla-quick-buy

An Apple Pay "buy now" button for one product.

An Apple Pay "buy now" button for one product. It renders Apple's apple-pay-button and shows it only when the store allows Apple Pay and this browser and currency can pay with it; otherwise it renders nothing. salla-add-product-button places it next to the add-to-cart button when quick buy is enabled, so a theme rarely uses it directly.

On click: a guest is asked to log in first (requireLogin), unless guest checkout is allowed. The product options on the page are then validated (validationFailed when something required is missing), and the Apple Pay session starts. Order options and free offer products, if the product has them, are collected before the payment is submitted.

Use it

In HTML or JSX, use the tag <salla-quick-buy> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).

import { SallaQuickBuy } from '@salla.sa/twilight-components-react/quick-buy';

Client-only. On the server this wrapper renders a placeholder (a skeleton, or nothing), and the real component mounts in the browser. Do not rely on it for content that search engines must see.

Example

import { SallaQuickBuy } from '@salla.sa/twilight-components-react/quick-buy';

export function Example() {
  return (
    <SallaQuickBuy productId="123" amount={150} currency="SAR" />
  );
}

Properties

PropertyAttributeDescriptionTypeDefault
amountamountProduct amount in base currency (SAR).number
applePayOnlyapple-pay-onlyShow Apple Pay onlyboolean
cartIdcart-idCart ID, when you need to applePay for existed cartstring
currencycurrencybase currencystring
isRequireShippingis-require-shippingTo be passed to purchaseNow requestboolean
optionsoptionsProduct options, if is empty will get the data from the document.querySelector('salla-product-options[product-id="X"]'){}{}
productIdproduct-idProduct ID.string
productTypeproduct-typeProduct type.string'product'
supportedCountriessupported-countriesApple Pay supported countries. Same array override/fallback semantics as supportedNetworks.string[]
supportedNetworkssupported-networksApple Pay supported card networks. Optional array override for surfaces that already hold the unified backend value (e.g. mini-checkout property-binds payments.gateways.applePay.supportedNetworks). When unset/empty, falls back to the PDP store.settings.buy_now.supportedNetworks config.string[]
typetypeButton type."book" | "buy" | "donate" | "order" | "pay" | "plain"'buy'
validateHostvalidate-hostCustom host for Apple Pay validate merchant URL. When set, the validate URL will use this host instead of the store URL.string

Events

Listen with addEventListener, or the on prop of the React wrapper (for example onModalBack).

EventDescriptionDetail
requireLoginEmitted when Apple Pay button is clicked but user is not logged in.{ productId: string; }
validationFailedEmitted when Apple Pay button is clicked but form validation fails.{ productId: string; }

Renders: <salla-order-options-modal>.

Used inside: <salla-add-product-button>.

On this page