field($orderProduct, "[$index]variant_id")
@@ -134,7 +134,7 @@ JS;
field($orderProduct, "[$index]count")
- ->textInput()
+ ->textInput(['class' => 'count'])
->label(false);
?>
diff --git a/web/js/order.js b/web/js/order.js
index 48be52e..3b473e1 100755
--- a/web/js/order.js
+++ b/web/js/order.js
@@ -2,9 +2,15 @@ $(function() {
$(document)
.on('click', '.remove-order-product', function(e) {
e.preventDefault();
+ var current_price = parseInt($(this).parents('.row-order-product').data('price'));
+ var number = parseInt($(this).parents('.row-order-product').children('.col-md-3').children('.form-group').children('input').val());
$(this)
.parents('.row-order-product')
.remove();
+ var total_price = parseInt($(".sum_all").children('p').text());
+ total_price = total_price - (current_price * number);
+ console.log(number);
+ $(".sum_all").children('p').text(total_price);
});
$(document)
.on('click', '.variant-to-order', function(e) {
@@ -36,6 +42,15 @@ $(function() {
.trigger('change');
}
});
+ $(document).on('change', '.count', function() {
+ var count_old = parseInt(this.defaultValue);
+ var count_new = parseInt(this.value);
+ var current_price = parseInt($(this).parents('.row-order-product').data('price'));
+ var total_price = parseInt($(".sum_all").children('p').text());
+ total_price = total_price - (count_old * current_price) + (count_new * current_price);
+ this.defaultValue = this.value;
+ $(".sum_all").children('p').text(total_price);
+ })
});
function showLoader(container) {
$(container)
--
libgit2 0.21.4