I need help with changing the text of a textbox that is connected to a dataset under instock(boolean). If the value is true(1 or more in inventory of a product) then show In Stock. If the value is false (0 in inventory of a product) then show Out of Stock. I’m working on a code below but my text doesn’t seem to show In Stock or Out of Stock, only true or false.
I’ve also tested to see if whether the value changes from true to false and vice versa depending on if the product has inventory or not.
import wixData from 'wix-data';
$w.onReady(function () {
const productId = "53dc7590-ea01-733a-e71a-d79f4473584f";
wixData.get("The Edit", productId)
.then((result) => {
const inStock = result.inStock;
const element = $w("#inStockText");
if (inStock) {
element.text = "In stock";
} else {
element.text = "Out of stock";
}
})
.catch((error) => {
console.log(error);
});
});