Created
December 5, 2012 11:19
-
-
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
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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is probably a stupid question but where do you paste the code?