Skip to content

Instantly share code, notes, and snippets.

@makfruit
Created December 5, 2012 11:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makfruit/4214827 to your computer and use it in GitHub Desktop.
Save makfruit/4214827 to your computer and use it in GitHub Desktop.
A script for Ecwid to display the 'Preorder' label instead of 'In stock' when a product has unlimited stock quantity
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
if (typeof(Ecwid) == 'object') {
Ecwid.OnAPILoaded.add(function() {
var preorderLabel = "Preorder";
function checkPreorder() {
if (
!jQuery(".ecwid-productBrowser-details-qtyAvailInfo").is(':visible')
&& jQuery(".ecwid-productBrowser-details-outOfStockLabel").length == 0
) {
// The item's stock quantity is unlimited, let's show preorder label
jQuery('.ecwid-productBrowser-details-inStockLabel').first().text(preorderLabel);
}
}
Ecwid.OnPageLoaded.add(function(page) {
if ('PRODUCT' == page.type) {
checkPreorder();
jQuery('.ecwid-productBrowser-details-optionsPanel input[type=radio]').each(function() {
jQuery(this).click(function() {
setTimeout(checkPreorder, 500);
});
});
jQuery('.ecwid-productBrowser-details-optionsPanel select').each(function() {
jQuery(this).change(function() {
setTimeout(checkPreorder, 500);
});
});
}
});
});
}
</script>
@ClubSoulErik
Copy link

This is probably a stupid question but where do you paste the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment