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

VajroSDK.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; // Minimum order amount to enable checkout
let cartTotal = VajroSDK.variables.cart.subtotal || 0;
function updateCheckoutButton() { 
    cartTotal = VajroSDK.variables.cart.subtotal || 0;
    if (cartTotal >= MINIMUM_ORDER_AMOUNT) {
        VajroSDK.actions.enableCheckoutButton();
    }
    else {
        VajroSDK.actions.disableCheckoutButton()
    }
}
VajroSDK.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 listeners (like cartUpdated) 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. Must be executed inside Vajro.ready() to ensure SDK context availability.