This script shows how to read a custom attribute in BigCommerce and calculate the discount price
<script>
function CalcDiscount(originalprice, discount) {
var newprice = (originalprice * (1 - discount)).toFixed(2);
return newprice;
}
var __isp_options = {
isp_serp_with_product_attributes: 1,
isp_serp_callback: function isp_serp_callback() {
$('li.isp_grid_product').each(function (i,el) {
var productId = $(this).attr('product_id');
if (ISP_PRODUCTS[productId] && ISP_PRODUCTS[productId].att) {
var productAttributes = ISP_PRODUCTS[productId].att;
var price = ISP_PRODUCTS[productId].p;
var percent = null;
if ($(this).find('div.isp_product_info > .isp_product_name').length === 0) {
percent = productAttributes.find(function (a) {
return a[0] === 'bundle_discount';
}) || false;
if (percent) {
var result = parseFloat(percent[1]) / 100.0;
var newprice = CalcDiscount(price,result);
$(this).find(".isp_product_price").text("Staring At $" + newprice);
}
}
}
});
},
</script>