...
This example shows a 3rd-Party party script being loaded, and then waited for the code waiting for the external script and the orderSummary object to exist before being invoked. This example would be appropriate on the ConfirmationExtra-mobile PagePart.
Code Block | ||||
---|---|---|---|---|
| ||||
<script type="text/javascript" src="//www.some-shopping-cart-tracker.com/script.js"></script> <script type="text/javascript"> ( function _trackerScript() { if (typeof (MyTracker) == "undefined") || if (typeof (MyTrackerPF.orderSummary.total) == "undefined") { setTimeout(function () { _trackerScript(); }, 500); } else { MyTracker.TrackOrder(PF.orderSummary.confirmation, PF.orderSummary.total); } })(); </script> |
Change a text string on a page
Info |
---|
This example |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script type="text/javascript">
var swapTextCount = 0;
function swapPageText(htmlSelector, originalText, newText)
{
var foundIt = false;
swapTextCount++;
if ( htmlSelector.length > 0 && originalText.length > 0 ) {
$(htmlSelector).each(function() {
try {
var htmlString = $( this ).html();
if ( htmlString.includes( originalText ) ) {
foundIt = true;
var newHtmlString = htmlString.replace( originalText, newText );
$( this ).html( newHtmlString );
}
}
finally { }
});
if ((!foundIt) && (swapTextCount < 20)) {
setTimeout( swapPageText, 150, htmlSelector, originalText, newText );
}
}
}
$(document).on("$pf-url-visited", function (event, url)
{
if ((url == "/cart") || (url == "/checkout/promotions") || (url == "/checkout/submit"))
{
swapTextCount = 0;
setTimeout( swapPageText, 100, "span", "Service charge", "$5 Minimum Order" );
}
});
</script> has been removed. The platform now has a built-in method (introduced in v17.1) for customizing text strings for a Dealer site, so the JavaScript workaround is no longer needed or recommended. |