Caresupp Store Order Form

Today: 0
Chronic Acute
Store Online
Store Pickup Home Delivery
Rs 50 Rs 100 Rs 500 Other
0% 10% 15% 20% Other
Hemant Arun Bharat Heena Mahima Other

Order Recorded!

Saved to your Google Sheet.

Send WhatsApp to Customer
', '' ].join(''); } function printThermal() { if (!lastOrder) return; const popup = window.open('', '_blank', 'width=420,height=840'); if (!popup) { setStatus('Popup blocked. Allow popups to print the thermal receipt.', true); return; } popup.document.open(); popup.document.write(buildThermalDocument(lastOrder)); popup.document.close(); } async function submitOrder() { if (!validateOrder()) return; const data = collectOrder(); const submitButton = $('#bsub'); submitButton.disabled = true; $('#spin').style.display = 'inline-block'; $('#blbl').textContent = 'Saving...'; setStatus('', false); const body = new URLSearchParams(); body.append(E.number, data.number); body.append(E.name, data.name); body.append(E.orderType, data.orderType); body.append(E.custType, data.custType); body.append(E.delivery, data.delivery); body.append(E.address, data.address); body.append(E.medicine, data.meds.join('\n')); if (data.advance === '__other_option__') { body.append(E.advance, '__other_option__'); body.append(E.advOther, data.advOther); } else if (data.advance) { body.append(E.advance, data.advance); } if (data.discount === '__other_option__') { body.append(E.discount, '__other_option__'); body.append(E.discOther, data.discOther); } else if (data.discount) { body.append(E.discount, data.discount); } if (data.salesPerson === '__other_option__') { body.append(E.salesPerson, '__other_option__'); body.append(E.spOther, data.spOther); } else { body.append(E.salesPerson, data.salesPerson); } try { await fetch(FORM_URL, { method: 'POST', mode: 'no-cors', body: body }); } catch (error) { submitButton.disabled = false; $('#spin').style.display = 'none'; $('#blbl').textContent = 'Submit Order'; setStatus('Submission failed from this Shopify page. This is often caused by theme/app CSP rules blocking Google Forms.', true); return; } orderCount += 1; localStorage.setItem(storageCountKey, String(orderCount)); $('#cnt').textContent = String(orderCount); submitButton.disabled = false; $('#spin').style.display = 'none'; $('#blbl').textContent = 'Submit Order'; lastOrder = data; updateModal(data); $('#overlay').classList.add('show'); } function clearOrderForm() { ['f-num', 'f-name', 'f-addr', 'f-adv-o', 'f-disc-o', 'f-sp-o'].forEach((id) => { const field = $('#' + id); if (field) field.value = ''; }); $$('.cs-chip').forEach((chip) => chip.classList.remove('on')); $$('.cs-other-box').forEach((input) => input.classList.remove('show')); $('#addr-wrap').classList.remove('show'); $('#meds').innerHTML = [ '
', '', '', '
' ].join(''); clearErrors(); setStatus('', false); } function startNewOrder() { $('#overlay').classList.remove('show'); clearOrderForm(); } $('#f-num').addEventListener('input', function () { this.value = this.value.replace(/\D/g, '').slice(0, 10); }); $$('.cs-chips').forEach((group) => { group.addEventListener('click', function (event) { const chip = event.target.closest('.cs-chip'); if (!chip || !group.contains(chip)) return; handleChipClick(group, chip); }); }); root.addEventListener('click', function (event) { const deleteButton = event.target.closest('[data-del-med]'); if (deleteButton) { deleteMedicineRow(deleteButton); } }); $('#add-med-btn').addEventListener('click', addMedicineRow); $('#clear-btn').addEventListener('click', clearOrderForm); $('#bsub').addEventListener('click', submitOrder); $('#print-btn').addEventListener('click', printThermal); $('#new-btn').addEventListener('click', startNewOrder); $('#overlay').addEventListener('click', function (event) { if (event.target === $('#overlay')) $('#overlay').classList.remove('show'); }); })();