Originally Posted by
preluvbags
Hi Chrome,
A big thank you for this marvellous plugin! I've installed it on zc ver 1.5.5f and it is working as designed for.
I need some help for my custom script. I've added plus and minus buttons to the product quantity and uses jquery to update the quantity input. My custom script is still working but I couldn't get it to update the price. Could you help me please?
HTML Code:
Code:
<div id="cartAdd">
<h2 id="productPrices" class="productGeneral">S$8.00</h2>
<span id="button-minus" class="addqty-minus">-</span>
<input id="addqty" class="addqtycart" type="text" name="cart_quantity" value="1" maxlength="6" size="4">
<span id="button-plus" class="addqty-plus">+</span>
<input type="hidden" name="products_id" value="1">
<input class="cssButton submit_button button button_in_cart" onmouseover="this.className='cssButtonHover button_in_cart button_in_cartHover'" onmouseout="this.className='cssButton submit_button button button_in_cart'" type="submit" value="Add to Cart">
</div>
Javascript
:
Code:
$(document).ready(function() {
var chkqty = $('#addqty').val();
$("#button-minus").click(function(){
var addqty = $('#addqty').val();
if(parseInt(addqty)>1) {
var newval = parseInt(addqty) - 1;
$('#addqty').val(newval);
return true;
}else{
return false;
}
});
$('#button-plus').click(function(){
var addqty = $('#addqty').val();
var newval = parseInt(addqty) + 1;
$('#addqty').val(newval);
return true;
});
});
Hope you or someone could help me, thank you guys!
The javascript code that has been added to modify some number related to the overall product quantity, does not force the actions to occur for the updated entry. In the above code, the val is updated, but javascript does not take action on that programattic change. It would take action if the user had specifically modified the field directly. I have also not forced a change of the val to cause such an update, leaving someone that writes such additional code to incorporate the necessary action.
See below (untested) what I think would fix this issue for your site:
Code:
$(document).ready(function() {
var chkqty = $('#addqty').val();
$("#button-minus").click(function(){
var addqty = $('#addqty').val();
if(parseInt(addqty)>1) {
var newval = parseInt(addqty) - 1;
$('#addqty').val(newval);
$('#addqty').change();
return true;
}else{
return false;
}
});
$('#button-plus').click(function(){
var addqty = $('#addqty').val();
var newval = parseInt(addqty) + 1;
$('#addqty').val(newval);
$('#addqty').change();
return true;
});
});
I added a manual call to the change event for the field being edited by the addition of:
Code:
$('#addqty').change();
Bookmarks