Disable Checkout Button
Disabled Checkout button on Cart Page
Description
Use the disableCheckoutButton to disable the checkout button on the cart page. If the checkout button is already disabled, calling this action makes no difference. When the checkout button is enabled, this action disables the checkout button.
Function Signature
await Superfans.actions.disableCheckoutButton()| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This action does not require any parameter. |
Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Checkout button diabled successfully" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
const MINIMUM_ORDER_AMOUNT = 50;
function updateCheckoutButton() {
const cart = Superfans.variables.cart;
const cartTotal = cart?.subtotal || 0;
if (cartTotal >= MINIMUM_ORDER_AMOUNT) {
Superfans.actions.enableCheckoutButton();
} else {
Superfans.actions.disableCheckoutButton();
}
}
Superfans.listeners.onCartUpdated(() => {
updateCheckoutButton();
});Best Practices
- Use before long-running or async processes like API validation or stock checks.
- Always re-enable checkout once the operation completes successfully.
- Inform the user when checkout is disabled to prevent confusion.
- Combine with
Superfans.listeners.onCartUpdatedand re-readSuperfans.variables.cartto handle cart changes dynamically.
Caveats
- The checkout button remains disabled until explicitly re-enabled using
enableCheckoutButton(). - Does not affect other UI buttons — only the native checkout control.
- Avoid leaving the button disabled without notifying the user.
- The SDK is available in the custom block. Call this action directly.
Updated about 1 month ago
Did this page help you?