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()
ParameterTypeRequiredDescription
NilNilNilThis action does not require any parameter.

Structure of Response

StatusResponse
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

  1. Use before long-running or async processes like API validation or stock checks.
  2. Always re-enable checkout once the operation completes successfully.
  3. Inform the user when checkout is disabled to prevent confusion.
  4. Combine with Superfans.listeners.onCartUpdated and re-read Superfans.variables.cart to handle cart changes dynamically.

Caveats

  1. The checkout button remains disabled until explicitly re-enabled using enableCheckoutButton().
  2. Does not affect other UI buttons — only the native checkout control.
  3. Avoid leaving the button disabled without notifying the user.
  4. The SDK is available in the custom block. Call this action directly.

Did this page help you?