diff --git a/controllers/OrderController.php b/controllers/OrderController.php index bbc5ff8..4534412 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -315,22 +315,14 @@ * @var Variant[] $variants */ $variants = Variant::find() - ->joinWith('lang', false) ->joinWith('product.lang', false) - ->andWhere( + ->where( [ 'like', 'product_lang.title', $q, ] ) - ->orWhere( - [ - 'like', - 'variant_lang.title', - $q, - ] - ) ->orWhere([ 'variant.sku' => $q ]) ->all(); foreach ($variants as $variant) { diff --git a/views/order/_form.php b/views/order/_form.php index 01bd850..4fb4959 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -150,8 +150,8 @@
isNewRecord) { - $sum = 0; foreach ($model->orderProducts as $index => $orderProduct) { $sum += ( $orderProduct->count * $orderProduct->price ); echo $this->render( @@ -171,7 +171,7 @@
Итого: " . $sum . "" ); + echo( "
Итого: " . $sum . "
" ); ?> diff --git a/web/js/order.js b/web/js/order.js index 7e60da9..eb23356 100755 --- a/web/js/order.js +++ b/web/js/order.js @@ -3,7 +3,8 @@ $(function() { .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()); + console.log(current_price); + var number = parseInt($(this).parents('.row-order-product').children('.col-md-2').children('.form-group').children('input').val()); var id = $(this) .data('id'); var variant = $(this) @@ -11,14 +12,11 @@ $(function() { $(this) .parents('.row-order-product') .remove(); - var total_price = parseInt($(".sum_all") - .children('p') - .text()); + var total_price = parseInt($("#total-sum").text()); + console.log(total_price); total_price = total_price - (current_price * number); console.log(number); - $(".sum_all") - .children('p') - .text(total_price); + $("#total-sum").text(total_price); }); $('#count-to-order').keypress(function(e) { if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; @@ -50,11 +48,9 @@ $(function() { order: order }, function(data) { if (data.success) { - var sum = $(".sum_all") - .children('p') - .text(); - $(".sum_all") - .children('p') + var sum = $('#total-sum').text(); + console.log(sum); + $('#total-sum') .html(parseInt(sum) + parseInt(data.price)); $('#product-rows') .append(data.row); @@ -69,10 +65,10 @@ $(function() { console.log(count_old); 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()); + var total_price = parseInt($("#total-sum").text()); total_price = total_price - (count_old * current_price) + (count_new * current_price); this.defaultValue = this.value; - $(".sum_all").children('p').text(total_price); + $("#total-sum").text(total_price); }) }); function showLoader(container) { -- libgit2 0.21.4