-
-
Save AaronGoldsmith/e821154dfd12a17d2d93a69f1b7ce5d3 to your computer and use it in GitHub Desktop.
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
`Where would this merchant have found this? | |
<!-- Begin Afterpay Stencil Snippet for BigCommerce v1.0.9 --> | |
{{#if product.price.with_tax}} | |
{{#if currency_selector.active_currency_code "==" "USD"}} | |
{{#if product.price.with_tax.value ">=" 35.00}} | |
{{#if product.price.with_tax.value "<=" 1000.00}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
<span class ="afterpay-text1"> or 4 installments of | |
<strong class="afterpay-instalments">${{toFixed (divide product.price.with_tax.value 4) 2}} {{currency_selector.active_currency_code}}</strong> | |
with </span> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span class="afterpay-text2"></span> | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">More info</u> </span> | |
</a> | |
</p> | |
{{else}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
<span class ="afterpay-text1">Installments by</span> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span class="afterpay-text2">available between $35.00 USD - $1000.00 USD</span> | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">Learn More</u> </span> | |
</a> | |
</p> | |
{{/if}} | |
{{else}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
<span class ="afterpay-text1">Installments by</span> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span class="afterpay-text2">available between $35.00 USD - $1000.00 USD</span> | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">Learn More</u> </span> | |
</a> | |
</p> | |
{{/if}} | |
{{else}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
or make 4 interest-free payments of | |
<strong class="afterpay-instalments">${{toFixed (divide product.price.with_tax.value 4) 2}} {{currency_selector.active_currency_code}}</strong> | |
fortnightly with | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">More info</u> </span> | |
</a> | |
</p> | |
{{/if}} | |
{{else}} | |
{{#if currency_selector.active_currency_code "==" "USD"}} | |
{{#if product.price.without_tax.value ">=" "35.00"}} | |
{{#if product.price.without_tax.value "<=" 1000.00}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
<span class ="afterpay-text1"> or 4 installments of | |
<strong class="afterpay-instalments">${{toFixed (divide product.price.without_tax.value 4) 2}} {{currency_selector.active_currency_code}}</strong> | |
with </span> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span class="afterpay-text2"></span> | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">More info</u> </span> | |
</a> | |
</p> | |
{{else}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
<span class ="afterpay-text1">Installments by</span> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span class="afterpay-text2">available between $35.00 USD - $1000.00 USD</span> | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">Learn More</u> </span> | |
</a> | |
</p> | |
{{/if}} | |
{{else}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
<span class ="afterpay-text1">Installments by</span> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span class="afterpay-text2">available between $35.00 USD - $1000.00 USD</span> | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">Learn More</u> </span> | |
</a> | |
</p> | |
{{/if}} | |
{{else}} | |
<p class="afterpay-paragraph" style="display:block; font-size:14px; text-transform:none;" data-currency={{currency_selector.active_currency_code}}> | |
or make 4 interest-free payments of | |
<strong class="afterpay-instalments">${{toFixed (divide product.price.without_tax.value 4) 2}} {{currency_selector.active_currency_code}}</strong> | |
fortnightly with | |
<a style="display:inline-block; margin-bottom:10px;" target="_blank" href="https://www.afterpay.com/terms"> | |
<img style="vertical-align:middle;" src="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png" srcset="https://static.afterpay.com/integration/product-page/logo-afterpay-colour.png 1x, https://static.afterpay.com/integration/product-page/[email protected] 2x, https://static.afterpay.com/integration/product-page/[email protected] 3x" width="100" height="21" alt="Afterpay"> | |
<span style="font-size:12px; display:inline-block; ;"> <u class="afterpay-link-inner">More info</u> </span> | |
</a> | |
</p> | |
{{/if}} | |
{{/if}} | |
<script type="text/javascript"> | |
if (typeof Afterpay === 'undefined') { | |
var Afterpay = {}; | |
Afterpay.loadScript = function(url, callback) { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
if (script.readyState) { // I.E. | |
script.onreadystatechange = function() { | |
if (script.readyState == 'loaded' || script.readyState == 'complete') { | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { // Others | |
script.onload = function() { | |
callback(); | |
}; | |
} | |
script.src = url; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
}; | |
Afterpay.$elements = null; | |
Afterpay.interval = null; | |
Afterpay.launchPopup = function($, event) { | |
event.preventDefault(); | |
var currency = $(".afterpay-paragraph").attr('data-currency'); | |
var $popup_wrapper, $popup_outer, $popup_inner, $a, $img, $close_button; | |
$popup_wrapper = $('#afterpay-popup-wrapper'); | |
if ($popup_wrapper.length > 0) { | |
$popup_wrapper.show(); | |
} else { | |
$popup_wrapper = $(document.createElement('div')) | |
.attr('id', 'afterpay-popup-wrapper') | |
.css({ | |
'position': 'fixed', | |
'z-index': 999999999, | |
'left': 0, | |
'top': 0, | |
'right': 0, | |
'bottom': 0, | |
'overflow': 'auto' | |
}) | |
.appendTo('body') | |
.on('click', function(event) { | |
Afterpay.closePopup($, event); | |
}); | |
$popup_outer = $(document.createElement('div')) | |
.attr('id', 'afterpay-popup-outer') | |
.css({ | |
'display': '-ms-flexbox', | |
'display': '-webkit-flex', | |
'display': 'flex', | |
'-webkit-justify-content': 'center', | |
'-ms-flex-pack': 'center', | |
'justify-content': 'center', | |
'-webkit-align-content': 'center', | |
'-ms-flex-line-pack': 'center', | |
'align-content': 'center', | |
'-webkit-align-items': 'center', | |
'-ms-flex-align': 'center', | |
'align-items': 'center', | |
'width': '100%', | |
'min-height': '100%', | |
'background-color': 'rgba(0, 0, 0, 0.80)' | |
}) | |
.appendTo($popup_wrapper); | |
$popup_inner = $(document.createElement('div')) | |
.attr('id', 'afterpay-popup-inner') | |
.css({ | |
'position': 'relative', | |
'background-color': '#fff' | |
}) | |
.appendTo($popup_outer); | |
$a = $(document.createElement('a')); | |
if (currency == 'USD') { | |
$a.attr('href', 'https://www.afterpay.com/purchase-payment-agreement'); | |
} else { | |
$a.attr('href', 'https://www.afterpay.com/terms'); | |
} | |
$a | |
.attr('target', '_blank') | |
.css({ | |
'display': 'block' | |
}) | |
.appendTo($popup_inner); | |
$img = $(document.createElement('img')); | |
if (currency == 'USD') { | |
if ($(window).width() > 640) { | |
$img.attr('src', 'https://static.afterpay.com/us-popup-medium.png'); | |
} else { | |
$img.attr('src', 'https://static.afterpay.com/us-popup-small.png'); | |
} | |
} else { | |
if ($(window).width() > 640) { | |
$img.attr('src', 'https://static.afterpay.com/lightbox-desktop.png'); | |
} else { | |
$img.attr('src', 'https://static.afterpay.com/lightbox-mobile.png'); | |
} | |
} | |
$img | |
.css({ | |
'display': 'block', | |
'width': '100%' | |
}) | |
.appendTo($a) | |
.on('click', function(event) { | |
event.stopPropagation(); | |
}); | |
$close_button = $(document.createElement('a')) | |
.attr('href', '#') | |
.css({ | |
'position': 'absolute', | |
'right': '8px', | |
'top': '8px' | |
}) | |
.html('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" version="1.1" width="32px" height="32px"><g id="surface1"><path style=" " d="M 16 3 C 8.832031 3 3 8.832031 3 16 C 3 23.167969 8.832031 29 16 29 C 23.167969 29 29 23.167969 29 16 C 29 8.832031 23.167969 3 16 3 Z M 16 5 C 22.085938 5 27 9.914063 27 16 C 27 22.085938 22.085938 27 16 27 C 9.914063 27 5 22.085938 5 16 C 5 9.914063 9.914063 5 16 5 Z M 12.21875 10.78125 L 10.78125 12.21875 L 14.5625 16 L 10.78125 19.78125 L 12.21875 21.21875 L 16 17.4375 L 19.78125 21.21875 L 21.21875 19.78125 L 17.4375 16 L 21.21875 12.21875 L 19.78125 10.78125 L 16 14.5625 Z "/></g></svg>') | |
.appendTo($popup_inner) | |
.on('click', function(event) { | |
Afterpay.closePopup($, event); | |
}); | |
} | |
}; | |
Afterpay.closePopup = function($, event) { | |
event.preventDefault(); | |
$('#afterpay-popup-wrapper').hide(); | |
}; | |
Afterpay.init = function($) { | |
$('.afterpay-paragraph a').on('click', function(event) { | |
Afterpay.launchPopup($, event); | |
}); | |
{{#if product.price.with_tax}} | |
var price_selector = '.productView-price .price--withTax'; | |
{{else}} | |
var price_selector = '.productView-price .price--withoutTax'; | |
{{/if}} | |
Afterpay.$elements = $(price_selector); | |
if (Afterpay.$elements.length > 0) { | |
Afterpay.interval = setInterval(function() { | |
Afterpay.$elements.each(function(index, element) { | |
var $element = $(element); | |
var currency = $(".afterpay-paragraph").attr('data-currency'); | |
var amount = $element.text().replace(/[a-zA-Z$]+/g,''); | |
if (amount >= 35.00 && amount <= 1000.00 && currency =='USD') { | |
$(".afterpay-paragraph").show(); | |
var instalment_amount_in_cents = Math.round((amount / 4) * 100); | |
var instalment_amount = (instalment_amount_in_cents / 100).toFixed(2); | |
$(".afterpay-paragraph").find(".afterpay-text1").html("or 4 installments of <strong class='afterpay-instalments'>$"+instalment_amount+" "+currency+"</strong> with"); | |
$(".afterpay-paragraph").find(".afterpay-text2").html(""); | |
$(".afterpay-paragraph").find(".afterpay-link-inner").html('More Info'); | |
}else if (amount >= 0.04 && amount <= 1000.00 && currency != 'US' ) { | |
$(".afterpay-paragraph").show(); | |
var instalment_amount_in_cents = Math.round((amount / 4) * 100); | |
var instalment_amount = (instalment_amount_in_cents / 100).toFixed(2); | |
$(".afterpay-instalments").html("$" + instalment_amount + " "+currency); | |
} else if(currency == 'USD' && (amount <= 35.00 || amount >= 1000.00)) { | |
$(".afterpay-paragraph").show(); | |
$(".afterpay-paragraph").find(".afterpay-text1").html("Installments by"); | |
$(".afterpay-paragraph").find(".afterpay-text2").html("available between $35.00 USD - $1000.00 USD"); | |
$(".afterpay-paragraph").find(".afterpay-link-inner").html('Learn More'); | |
} else { | |
$(".afterpay-paragraph").hide(); | |
} | |
}); | |
}, 500); | |
} | |
}; | |
} else { | |
if (Afterpay.interval !== null) { | |
clearInterval(Afterpay.interval); | |
} | |
} | |
if (typeof jQuery_1_12_4 === 'function') { | |
Afterpay.init(jQuery_1_12_4); | |
} else if (typeof jQuery === 'undefined' || parseFloat(jQuery.fn.jquery) < 1.7) { | |
var jQuery_1_12_4; | |
Afterpay.loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', function() { | |
jQuery_1_12_4 = jQuery.noConflict(true); | |
Afterpay.init(jQuery_1_12_4); | |
}); | |
} else { | |
Afterpay.init(jQuery); | |
} | |
</script> | |
<!-- End Afterpay Stencil Snippet for BigCommerce v1.0.9 --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment