Terms & Conditions Checkbox
<div class="terms-container">
<label class="checkbox-wrapper">
<input type="checkbox" id="terms-checkbox" checked="">
<span class="custom-checkbox">
<svg class="checkmark" viewBox="0 0 24 24" fill="none">
<path d="M5 13L9 17L19 7" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
<t5 class="checkbox-text">I agree to the terms and conditions.</t5>
</label>
<t5 class="terms-description">
Thanks for shopping with Vintage Boho Bags! If you are not entirely satisfied with your purchase, we’re here to
help.
Please refer to our <a href="#">Return Policy</a> to review the terms and our full disclaimer.
Vintage Boho Bags is not affiliated with Louis Vuitton.
</t5>
</div>.terms-container {
color: #111;
padding: 16px;
}
.checkbox-wrapper {
display: flex;
align-items: center;
margin-bottom: 16px;
cursor: pointer;
}
.checkbox-wrapper input[type="checkbox"] {
display: none;
}
.custom-checkbox {
width: 16px;
height: 16px;
min-width: 16px;
background-color: transparent;
border: 1.5px solid #131313;
border-radius: 4px;
display: inline-flex;
align-items: center;
justify-content: center;
margin-right: 8px;
}
input[type="checkbox"]:checked+.custom-checkbox {
background-color: #F74480;
border-color: #F74480;
}
.checkmark {
width: 12px;
height: 12px;
display: none;
}
input[type="checkbox"]:checked+.custom-checkbox .checkmark {
display: block;
}
.checkbox-text {
font-weight: 500;
}
.terms-description {
line-height: 18px;
color: #111;
}
.terms-description a {
font-weight: 700;
color: inherit;
text-decoration: none;
}const termsCheckbox = document.getElementById('terms-checkbox');
/**
* ✅ Show SDK alert on error
*/
function handleError(title, error) {
console.error(`❌ ${title}:`, error);
VajroSDK.actions.showAlert({
title,
message: error?.message || "An unexpected error occurred. Please try again.",
});
}
/**
* ✅ Toggle checkout button based on checkbox state
*/
async function toggleCheckout(enable) {
try {
const action = enable
? VajroSDK.actions.enableCheckoutButton
: VajroSDK.actions.disableCheckoutButton;
await action();
console.log(enable ? "✅ Checkout button enabled" : "❌ Checkout button disabled");
} catch (error) {
handleError(enable ? "Error enabling checkout" : "Error disabling checkout", error);
}
}
/**
* ✅ Initialize on load (set checked = true and enable checkout)
*/
async function initializeCheckout() {
try {
termsCheckbox.checked = true;
await VajroSDK.actions.enableCheckoutButton();
console.log("🚀 Checkout button enabled by default");
} catch (error) {
handleError("Error enabling checkout on load", error);
}
}
// ✅ Listen for checkbox toggle
termsCheckbox.addEventListener("change", () => {
toggleCheckout(termsCheckbox.checked);
});
// ✅ Run on load
document.addEventListener("DOMContentLoaded", initializeCheckout);Updated 4 months ago