Hide payment methods when order total is $0

When discount brings total to zero, hide the payment method selector
and change button from "Continue to Secure Payment" to "Place Free Order".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-22 01:32:30 -05:00
parent a8cdfc65f6
commit bf0c6dc85e

View file

@ -344,10 +344,22 @@ function renderServices() {
if(hasPromo&&promoDisc>0) rows+='<div class="flex justify-between text-sm text-green-700 mb-1"><span>Discount — code '+promoFromUrl.toUpperCase()+(window._promoInfo?(" ("+window._promoInfo.description+")"):"")+'</span><span>-'+usd(promoDisc)+'</span></div>';
else if(hasDisc) rows+='<div class="flex justify-between text-sm text-green-700 mb-1"><span>Bundle discount (15%)</span><span>-'+usd(disc)+'</span></div>';
var totalDisc=hasPromo?promoDisc:disc;
rows+='<div class="flex justify-between font-bold text-base border-t border-gray-300 pt-2 mt-1"><span>Total</span><span>'+usd(subtotal-totalDisc)+'</span></div>';
var finalTotal=subtotal-totalDisc;
rows+='<div class="flex justify-between font-bold text-base border-t border-gray-300 pt-2 mt-1"><span>Total</span><span>'+usd(finalTotal)+'</span></div>';
summary.innerHTML=rows;
listEl.appendChild(summary);
// Hide payment methods and change button text when total is $0
var paySection=document.getElementById("pw-payment-section");
var submitBtn=document.getElementById("pw-submit");
if(finalTotal<=0){
if(paySection)paySection.style.display="none";
if(submitBtn)submitBtn.textContent="Place Free Order \u2192";
}else{
if(paySection)paySection.style.display="";
if(submitBtn)submitBtn.textContent="Continue to Secure Payment \u2192";
}
// FCC penalty warning
var penaltyBox=document.createElement("div");
penaltyBox.className="mt-3 p-4 bg-red-50 border border-red-200 rounded-lg";
@ -386,13 +398,14 @@ function renderServices() {
'<div><label class="block text-xs font-medium text-gray-600 mb-1">Referral / discount code</label>' +
'<input type="text" id="pw-promo" placeholder="Optional" class="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg outline-none uppercase"></div>' +
'</div>' +
'<div id="pw-payment-section">' +
'<h4 class="text-sm font-semibold text-gray-900">Payment Method</h4>' +
'<div class="space-y-2">' +
'<label class="flex items-center gap-3 p-3 rounded-lg border border-gray-200 cursor-pointer hover:border-pw-400 has-[:checked]:border-pw-500 has-[:checked]:bg-pw-50"><input type="radio" name="pw_pay" value="card" checked><span class="text-sm font-medium text-gray-800">Credit / Debit Card</span><span class="ml-auto text-xs text-gray-400">Visa, MC, Amex, Discover</span></label>' +
'<label class="flex items-center gap-3 p-3 rounded-lg border border-gray-200 cursor-pointer hover:border-pw-400 has-[:checked]:border-pw-500 has-[:checked]:bg-pw-50"><input type="radio" name="pw_pay" value="ach"><span class="text-sm font-medium text-gray-800">ACH Bank Transfer</span><span class="ml-auto text-xs text-green-600 font-medium">No processing fee</span></label>' +
'<label class="flex items-center gap-3 p-3 rounded-lg border border-gray-200 cursor-pointer hover:border-pw-400 has-[:checked]:border-pw-500 has-[:checked]:bg-pw-50"><input type="radio" name="pw_pay" value="paypal"><span class="text-sm font-medium text-gray-800">PayPal</span></label>' +
'<label class="flex items-center gap-3 p-3 rounded-lg border border-gray-200 cursor-pointer hover:border-pw-400 has-[:checked]:border-pw-500 has-[:checked]:bg-pw-50"><input type="radio" name="pw_pay" value="crypto"><span class="text-sm font-medium text-gray-800">Cryptocurrency</span><span class="ml-auto text-xs text-gray-400">BTC, ETH, USDC</span></label>' +
'</div>' +
'</div></div>' +
'<label class="flex items-start gap-2 p-3 mt-2 rounded-lg border border-gray-200 cursor-pointer text-xs text-gray-600 leading-relaxed"><input type="checkbox" id="pw-engage" required class="mt-0.5 rounded border-gray-300 text-pw-600 focus:ring-pw-500"><span>I authorize Performance West to prepare and file on my behalf. <a href="/terms" target="_blank" class="text-pw-600 underline">Terms</a></span></label>' +
'<button type="submit" id="pw-submit" class="w-full py-3.5 rounded-lg bg-green-600 text-white font-bold text-base hover:bg-green-700 transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed shadow-lg" style="box-shadow:0 4px 14px rgba(22,163,74,0.4)">Continue to Secure Payment \u2192</button>' +
'<div class="flex items-center justify-center gap-4 mt-2 text-xs text-gray-400">' +