Skip to content

Instantly share code, notes, and snippets.

@riq363
Last active September 11, 2015 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riq363/35efada29056b84320fc to your computer and use it in GitHub Desktop.
Save riq363/35efada29056b84320fc to your computer and use it in GitHub Desktop.
Add link to email to product details page. Sends SKU in the body of email and 'I want to pre-order' in the subject
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
Ecwid.OnPageLoaded.add(function(page){
setTimeout(function hidePrice() {
if(page.type == "CATEGORY") {
$(".ecwid-BuyNow-outOfStockLabel").each(function(idx, el){
$(el).after('<br/>Click to pre-order');
});
}
if (page.type == "PRODUCT") {
var sku = $('.ecwid-productBrowser-sku').text();
if($('div').hasClass('ecwid-productBrowser-details-outOfStockLabel') && !$('a').hasClass('pre-order')) {
$('<a class="pre-order" href="mailto:mail@example.com?subject=I want to pre-order&body='+sku+'">Email to pre-order</a>').insertAfter('.ecwid-productBrowser-details-outOfStockLabel');
added = true;
}
else if ($('div').hasClass('ecwid-productBrowser-details-inStockLabel') && $('a').hasClass('pre-order')) {
$('.pre-order').remove();
}
}
}, 200);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment