Hi Jeff,
Quote:
Originally Posted by jefferis1
Maybe it should be category.number???
|
It should be the "
categoryId" property of the "
page" object. So, if you want to apply some code to products in a particular category, a script will look like as follows:
Code:
<script>
Ecwid.OnPageLoad.add(function (page) {
if (page.type === "PRODUCT" && page.categoryId === CATEGORYID) {
ecwidMessages = {
"ProductDetails.out_of_stock":"Price On Request"
}
Ecwid.Cart.calculateTotal(function () { });
}
});
</script>
The
CATEGORYID marked in red should be replaced with an actual category ID. Feel free to
take a look at our article on how to get a product or category ID if you don't know it already. Also, you can see the
calculateTotal method at the end of the script. I've added it because if you want to apply the
custom translations code to the storefront dynamically, you'll have to force Ecwid refresh its DOM and calling the
calculateTotal method allows us to do that.
There's an alternative solution that's a bit faster. I've used jQuery to make the script simpler:
Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script>
Ecwid.OnPageLoad.add(function (page) {
if (page.type === "PRODUCT" && page.categoryId === CATEGORYID) {
$(".ecwid-productBrowser-details-outOfStockLabel").text("Price On Request");
});
</script>
Also, I suggest you
check out our docs on the JavaScript API. They describe all properties, methods, objects you can use in your scripts.
Hope this was helpful.