Skip to content

Instantly share code, notes, and snippets.

@dpdexter
Created December 4, 2012 19:14
Show Gist options
  • Save dpdexter/4207649 to your computer and use it in GitHub Desktop.
Save dpdexter/4207649 to your computer and use it in GitHub Desktop.
BrilliantRetail - Change product display price when options are selected.
{exp:brilliant_retail:js}
var price,newPrice,qty,opt,adj;
$(function(){
price = parseInt($('p.price').html().replace('$',''))*1;
$('select','.product-options')
.change(function(){
qty = $('option:selected','#qty_select').val();
newPrice = price;
$('select','.product-options').each(function(){
opt = $(this).find('option:selected').text();
mat = opt.match(/\$\d+.\d+/);
if(mat){
adj = mat[0].replace("$","");
adj = adj * 1;
newPrice += adj;
}
});
var num = parseFloat(qty*newPrice).toFixed(2);
$('p.price').html('$'+num);
});
});
{/exp:brilliant_retail:js}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment