I'm trying to edit a script so that I can format the output using HTML but unsure how to properly format it. At the moment the script is as below, but what I would like to achieve is as per the second script below. I know that the second script doesn't make sense but I'm just trying to show what I'd basically like to achieve, but not sure how to go about achieving it. If anyone could help I'd appreciate it.
Original script:
var selectCallback = function(variant, selector) {
timber.productPage({
money_format: "{{ shop.money_format }}",
variant: variant,
selector: selector
});
if (variant) {
if (variant.inventory_management == "shopify" && variant.inventory_policy != "continue") {
if (variant.inventory_quantity > 0) {
jQuery('#variant-inventory').text('We have ' + variant.inventory_quantity + ' in stock.');
} else {
jQuery('#variant-inventory').text("This product is sold out");
}
} else {
jQuery('#variant-inventory').text("In stock - order now");
}
} else {
jQuery('#variant-inventory').text("");
}
};
What I'm trying to achieve:
var selectCallback = function(variant, selector) {
timber.productPage({
money_format: "{{ shop.money_format }}",
variant: variant,
selector: selector
});
if (variant) {
if (variant.inventory_management == "shopify" && variant.inventory_policy != "continue") {
if (variant.inventory_quantity > 0) {
jQuery('#variant-inventory').text('<div class="stock">We have ' + variant.inventory_quantity + ' in stock.</div>');
} else {
jQuery('#variant-inventory').text("<div class="sold-out">This product is sold out</div> - <a href="link">contact us</a>");
}
} else {
jQuery('#variant-inventory').text("<div class="in-stock">In stock</div> - order now");
}
} else {
jQuery('#variant-inventory').text("");
}
};