'
)
// SET INBOUND VARIANT TO SELECTED
$('.wbp_sizes span').each(function(){
if ( $(this).attr('data-id') == inboundVariant ){
if ( $(this).attr('data-inventory') > 0 ){
$('.wbp_sizes span').removeClass('selected')
firstAvailableVariant = $(this).attr('data-id') // THIS PASSES THROUGH TO FORM
salePrice( $(this) )
$(this).addClass('selected')
}
}
})
$('.wbp_colors span').click(function(){
location.href = $(this).attr('data-url')
})
// SIZE CLICK FUNCTION
$('.wbp_sizes span.available').click(function(){
$('.wbp_sizes span').removeClass('selected')
$(this).toggleClass('selected')
$('#wbp_pdp_select').html('')
// UPDATE URL AND HISTORY
var newVariant = $(this).attr('data-id')
var currentURL = location.pathname + location.search + location.hash;
if (currentURL.indexOf('variant=') > -1) {
currentURL = currentURL.replace(/variant=\d+/, 'variant=' + newVariant);
} else {
var sep = currentURL.indexOf('?') > -1 ? '&' : '?';
currentURL += sep + 'variant=' + newVariant;
}
salePrice( $(this) )
window.history.replaceState({}, '', currentURL);
})
cb(firstAvailableVariant,soldOut)
}
function salePrice($sel){
// RESPECT SALE PRICE
var thePrice = $sel.attr('data-price')
if ( $sel.attr('data-compare-at-price') ){
$('.wbp_price').html(''+$sel.attr('data-compare-at-price')+' '+ thePrice )
} else {
$('.wbp_price').text(thePrice)
}
}
function drawProductInfo(inboundVariant,cb){
var description = productObject.product.description.replace(/\+/g,' ')
description = decodeURIComponent(description)
var price = productObject.variants_obj[inboundVariant].price
var priceHtml = price
if ( productObject.variants_obj[inboundVariant].compare_at_price ){
priceHtml = ''+productObject.variants_obj[inboundVariant].compare_at_price+' '+ price
}
$('.wbp').append(
'
\
'+productObject.product.title+'
\
'+priceHtml+'
\
\
'+description+'
\
\
'
)
cb()
}
function page_variant(cb){
// LOAD FIRST AVAILABLE VARIANT WITH INVENTORY > 0
if ( location.href.indexOf('variant=') 0 ){
if ( location.href.indexOf('?')