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()| 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; // 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
- 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 listeners (like cartUpdated) to 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.
- Must be executed inside Vajro.ready() to ensure SDK context availability.
Updated about 1 month ago