Untitled
unknown
plain_text
3 years ago
1.5 kB
6
Indexable
// V1
(function () {
"use strict";
function PriceChanger() {
var discountPrice = jQuery('.totals.order-summary-section .savings').hasClass('d-none') ? 0 : jQuery('.total-savings .total-savings-amount:eq(0)').text().trim().split('$');
var originalPrice = jQuery('.grand-total-sum').text().trim().split('$');
var totalSum = '';
if (discountPrice == 0) {
totalSum = (parseFloat(originalPrice[1].replaceAll(',', '')) + parseFloat(discountPrice)).toFixed(2);
jQuery('.totals .order-total-summary .sub-total').text('$' + totalSum);
} else {
totalSum = (parseFloat(originalPrice[1].replaceAll(',', '')) + parseFloat(discountPrice[1])).toFixed(2);
jQuery('.totals .order-total-summary .sub-total').text('$' + totalSum);
}
jQuery('.order-receipt-label span[aria-label="Shipping Discount"]').text('Discount');
jQuery('.shipping-discount-total').text(discountPrice == 0 ? "-$" + discountPrice + '.00' : '- $' + discountPrice[1]);
}
var running = false;
var target = document.querySelector('.order-summary');
const config = { childList: true, characterData: true, subtree: true, attributes: true, };
const callback = function () {
if (running == true) return;
PriceChanger();
running = true;
setTimeout(function () { running = false }, 1000);
};
function Mutx(target, callback, config) {
const observer = new MutationObserver(callback);
observer.observe(target, config);
}
PriceChanger();
Mutx(target, callback, config);
})();Editor is loading...