jQuery(function($){
"use strict";
if(afwssv_phpvars.afwssv_enable_toggle=='yes'){
$(".products .variations").wrap("<div class='showvar'></div>");
if(afwssv_phpvars.afwssv_toggle_text!=''){
$("<a class='exspands' href='javascript:void(0)'>"+afwssv_phpvars.afwssv_toggle_text+"</a>").insertBefore(".showvar");
}else{
$("<a class='exspands' href='javascript:void(0)'>Show/Hide Variations</a>").insertBefore(".showvar");
}
$('.exspands').on("click", function (){
var id=$(this).parent().attr('data-product_id');
$('.post-' + id + ' .showvar').toggle();
});
}
$(window).on('wc_prl_deployments_after_render', function(){
$('form.variations_form').each(function(){
$(this).wc_variation_form();
});
});
$(document).on('change','.variation_id',function(){
if($(this).closest('form').find('.exspands').length&&! $(this).closest('form').find('.af-pba-br').length){
$(this).closest('form').find('.single_variation_wrap').before('<br class="af-pba-br">');
$(this).closest('form').find('.qty').css('margin-bottom', '20px');
}else{
if(! $(this).closest('form').find('.af-pba-br').length){
$(this).closest('form').find('.single_variation_wrap').before('<br class="af-pba-br">');
$(this).closest('form').find('.qty').css('margin-bottom', '20px');
}}
});
});