BuyNowButton Component
The BuyNowButton component renders a button that adds an item to the cart and redirects the customer to checkout. It must be a child of a CartProvider component.
Usage
import React from "react";
import { BuyNowButton } from "@airsoko/react";
const MyComponent = () => {
return (
<BuyNowButton
productId="your-product-id"
variantId="your-variant-id"
quantity={1}
attributes={[{ key: "attributeKey", value: "attributeValue" }]}
>
Buy Now
</BuyNowButton>
);
};
export default MyComponent;Props
| Name | Type | Default | Description |
|---|---|---|---|
quantity | number | 1 | The item quantity. Defaults to 1. |
variantId | string | The ID of the variant. | |
productId | string | The ID of the product. | |
attributes | { key: string; value: string; }[] | An array of cart line attributes that belong to the item being added to the cart. |