Created
January 30, 2015 14:38
-
-
Save devjosh12/cc5997f568b3550b353a to your computer and use it in GitHub Desktop.
quantity increment / decrement from category page magento
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$j(".plus_sign").click(function() { | |
var catcount = 9; | |
var cartitems = 0; | |
$j('.firstload').css("display","none"); | |
var id = $j(this).attr('rel'); | |
var text_val = $j('#qty_'+id).val(); | |
//var checkidval = $j('#qty_'+id).val(); | |
var divcounter = $j('#qty_counter'+id).text(); | |
var currentVal = $j('.myinput').val(); | |
var count = $j('.mycount').val(); | |
if(count == catcount) { | |
$j("#upcounter").html(+count+" of "+catcount+" meals selected"); | |
return false; | |
} else { | |
$j('#qty_'+id).val(parseInt(text_val)+1); | |
$j('#qty_counter'+id).html(parseInt(text_val)+1); | |
$j("#upcounter").html(parseInt(count)+1+" of "+catcount+" meals selected"); | |
$j("#left_count").html(parseInt(count)+1); | |
$j('.mycount').val(++count); | |
} | |
}); | |
$j(".minus_sign").click(function() { | |
var id = $j(this).attr('rel'); | |
var check_val = $j('#qty_'+id).val(); | |
//alert(check_val); | |
if(check_val == 0) { | |
return false; | |
} else { | |
$j('.firstload').css("display","none"); | |
var totalcatcount = 9; | |
var id = $j(this).attr('rel'); | |
var qty_val = $j('#qty_'+id).val(); | |
var cartitems = $j('.mycount').val(); | |
$j('#qty_'+id).val(parseInt(qty_val)-1); | |
$j('#qty_counter'+id).html(parseInt(qty_val)-1); | |
$j("#upcounter").html(parseInt(cartitems)-1+" of "+totalcatcount+" meals selected"); | |
$j("#left_count").html(parseInt(cartitems)-1); | |
$j('.mycount').val(--cartitems); | |
} | |
}); | |
/*function setLocationAjax(url,id){ | |
var qty = $j('#qty_'+id).val(); | |
if(qty == 0) { | |
return false; | |
} | |
//url += '?isAjax=1&qty='+qty; | |
try { | |
$j.ajax( { | |
type:'post', | |
url : url, | |
data : {qty:qty}, | |
success : function(data) { | |
if(data) { | |
//window.location.href = window.location.href; | |
window.location.reload(true); | |
} | |
setAjaxData(data,false); | |
} | |
}); | |
} | |
catch (e) { | |
alert(e); | |
} | |
}*/ | |
$j(".chkout_btn").click(function(){ | |
var categorycount = 9; | |
var totalclickcount = $j('.mycount').val(); | |
//alert(categorycount);alert(totalclickcount); | |
if(categorycount==totalclickcount){ | |
$j(".fme_loading_filters").css("display","block"); | |
$j.ajax({ | |
url: "http://www.xyz.com/index.php/checkout/index/cartadd/", | |
type: 'POST', | |
data: $j("#listform").serializeArray(), | |
success: function(data) { | |
$j(".fme_loading_filters").css("display","none"); | |
//alert("All meals have been added to the cart"); | |
location.reload(); | |
//if(data='success') | |
//window.location.href="http://www.xyz.com/index.php/checkout/cart/"; | |
}, | |
error: function(e) { | |
console.log(e.message); | |
} | |
}); | |
}else{ | |
alert("Please Choose "+categorycount+" meals for "+categorycount+" Meal Plan"); | |
} | |
}); | |
$j(document).ready (function(){ | |
$j(".more").click(function() { | |
$j(".mtext-row").html($j(this).attr('rel')); | |
$j('.morepop').show(); | |
$j('.pop-layer').fadeIn(); | |
$j('.morepop .inisde-pop').fadeIn(); | |
}); | |
$j(".morepop a.pop-close").click(function() { | |
$j('.morepop').hide(); | |
$j('.pop-layer').fadeOut(); | |
$j('.morepop .inisde-pop').fadeOut(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment