This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// Add this to Upcart's beforeLoad. This should then just be assigned ONCE. | |
window.upcartEl = window.upcartDocumentOrShadowRoot; | |
function injectOriginalPrice(cart) { | |
// 1) Compute compare-at total | |
let compareTotal = 0; | |
for (const item of cart.items) { | |
const base = item.compare_at_price ?? item.final_price; | |
compareTotal += base * item.quantity; |