Show per-item discount amounts on order page
Each service line item now shows its price and a green -$X discount next to it when a coupon is applied. Non-discountable items (BOC-3, D&A, MC Authority) show price only. Gov fees shown as sub-items. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4e7493b088
commit
e6150bcdce
1 changed files with 25 additions and 2 deletions
|
|
@ -485,8 +485,31 @@ function updateTotal() {
|
|||
discountAmt = Math.min(activeDiscount.discount_value * 100, discountable);
|
||||
}
|
||||
|
||||
var html = '<div class="flex justify-between text-sm mb-1"><span>' + selected.length + ' service' + (selected.length > 1 ? 's' : '') + '</span><span>' + usd(svcTotal) + '</span></div>';
|
||||
if (govTotal > 0) html += '<div class="flex justify-between text-sm text-gray-500 mb-1"><span>Government fees (passthrough)</span><span>' + usd(govTotal) + '</span></div>';
|
||||
// Build itemized list
|
||||
var html = '';
|
||||
checkboxes.forEach(function(cb) {
|
||||
if (!cb.checked) return;
|
||||
var price = parseInt(cb.dataset.price) || 0;
|
||||
var gov = parseInt(cb.dataset.govfee) || 0;
|
||||
var slug = cb.dataset.slug;
|
||||
var label = cb.closest("label");
|
||||
var name = label ? (label.querySelector(".font-semibold.text-gray-900") || {}).textContent || slug : slug;
|
||||
var canDiscount = !nonDiscountable[slug] && activeDiscount;
|
||||
var itemDiscount = 0;
|
||||
if (canDiscount && activeDiscount.discount_type === "percent") {
|
||||
itemDiscount = Math.round(price * activeDiscount.discount_value / 100);
|
||||
}
|
||||
html += '<div class="flex justify-between text-sm mb-1"><span>' + name + '</span>';
|
||||
if (itemDiscount > 0) {
|
||||
html += '<span>' + usd(price) + ' <span style="color:#059669;font-size:12px;font-weight:600">-' + usd(itemDiscount) + '</span></span>';
|
||||
} else {
|
||||
html += '<span>' + usd(price) + '</span>';
|
||||
}
|
||||
html += '</div>';
|
||||
if (gov > 0) html += '<div class="flex justify-between text-xs text-gray-400 mb-1 pl-2"><span>Gov fee</span><span>' + usd(gov) + '</span></div>';
|
||||
});
|
||||
|
||||
if (govTotal > 0) html += '<div class="flex justify-between text-sm text-gray-500 mb-1 border-t border-gray-100 pt-1 mt-1"><span>Government fees</span><span>' + usd(govTotal) + '</span></div>';
|
||||
if (discountAmt > 0) {
|
||||
html += '<div class="flex justify-between text-sm text-green-600 font-semibold mb-1"><span>' + activeDiscount.code + ' (' + activeDiscount.discount_value + '% off)</span><span>-' + usd(discountAmt) + '</span></div>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue