Last active
September 11, 2015 10:18
-
-
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
This file contains 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 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