diff --git a/common/models/ProductLang.php b/common/models/ProductLang.php
index c198987..1b41eff 100644
--- a/common/models/ProductLang.php
+++ b/common/models/ProductLang.php
@@ -57,7 +57,7 @@ class ProductLang extends ActiveRecord
'targetAttribute' => [ 'language_id' => 'id' ],
],
[
- [ 'tile_id' ],
+ [ 'product_id' ],
'exist',
'skipOnError' => true,
'targetClass' => Product::className(),
diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php
index ecb9de2..8ffcc6f 100755
--- a/frontend/controllers/SiteController.php
+++ b/frontend/controllers/SiteController.php
@@ -102,8 +102,8 @@
->orderBy('id')
->limit(4)
->all();
- $productsCompany = Product::find()->where(['!=','type',Product::TYPE_PRIVATE])->all();
- $productsPrivate = Product::find()->where(['!=','type',Product::TYPE_COMPANY])->all();
+ $productsCompany = Product::find()->with(['lang', 'image'])->where(['!=','type',Product::TYPE_PRIVATE])->all();
+ $productsPrivate = Product::find()->with(['lang', 'image'])->where(['!=','type',Product::TYPE_COMPANY])->all();
return $this->render(
'index',
[
diff --git a/frontend/views/site/_product.php b/frontend/views/site/_product.php
index a940eb1..64a86ef 100644
--- a/frontend/views/site/_product.php
+++ b/frontend/views/site/_product.php
@@ -1,11 +1,21 @@
+
\ No newline at end of file
diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php
index 6a7e1e0..f4aeab7 100755
--- a/frontend/views/site/index.php
+++ b/frontend/views/site/index.php
@@ -550,8 +550,6 @@ $coordinates['lon'] = empty($settings->lon) ? 0 : $settings->lon;
width="100%" height="380" style="border:0;" allowfullscreen="" loading="lazy">
-
- Получить консультацию
diff --git a/frontend/web/js/product.js b/frontend/web/js/product.js
index 9777ec1..18f2003 100644
--- a/frontend/web/js/product.js
+++ b/frontend/web/js/product.js
@@ -1,18 +1,22 @@
var phoneInput = document.querySelector('#cardProduct [type="tel"]');
var counter = document.querySelector('#cardProduct .product-counter__input');
-
+var price = 0;
if (phoneInput) {
phoneInput.addEventListener('input', phoneHandleInput);
}
$('#cardProduct').on('show.bs.modal', function (e) {
- var button = $(e.relatedTarget)
- console.log(button.data('boo'));
+ var button = $(e.relatedTarget);
+ price = button.data('price');
+ $('#cardProduct .product-counter__value').data('price', price);
+ var itemPrice = counter.parentElement.querySelector('.product-counter__value');
+ itemPrice.innerHTML = `${price} ${itemPrice.dataset.currency}`;
+ counter.querySelector('input').value = 1;
})
-
-if (counter) {
- counterFunc(counter);
+if(counter){
+ counterFunc(counter);
}
+
function phoneHandleInput(e) {
e.target.value = phoneMasks(e.target.value);
}
@@ -27,8 +31,8 @@ function phoneMasks(phone) {
}
function counterFunc(counter) {
- let itemPrice = counter.parentElement.querySelector('.product-counter__value');
- itemPrice.innerHTML = `${itemPrice.dataset.price} ${itemPrice.dataset.currency}`;
+ var itemPrice = counter.parentElement.querySelector('.product-counter__value');
+ itemPrice.innerHTML = `${price} ${itemPrice.dataset.currency}`;
counter.querySelector('input').value = 1;
counter.addEventListener('input', counterHandleInput);
@@ -42,7 +46,7 @@ function counterFunc(counter) {
}
function counterHandleChange(e) {
- const value = e.target.value.replace(/\D/g, '');
+ var value = e.target.value.replace(/\D/g, '');
if (value == 0) {
e.target.value = 1;
}
@@ -51,14 +55,16 @@ function counterFunc(counter) {
function increment(e) {
e.preventDefault();
- const value = Number(counter.querySelector('input').value);
+ var value = Number(counter.querySelector('input').value);
+ //console.log(value);
counter.querySelector('input').value = value + 1;
+ console.log(value);
updateSummary();
}
function decrement(e) {
e.preventDefault();
- const value = Number(counter.querySelector('input').value);
+ var value = Number(counter.querySelector('input').value);
if (value > 1) {
counter.querySelector('input').value = value - 1;
updateSummary();
@@ -66,11 +72,11 @@ function counterFunc(counter) {
}
function updateSummary() {
- const amount = counter.querySelector('input').value;
+ var amount = counter.querySelector('input').value;
if (amount >= 1) {
- const oldSum = Number(itemPrice.dataset.price) * 10;
- const newSum = String(oldSum * amount);
- itemPrice.innerHTML = `${newSum.slice(0, -2)}.${newSum.slice(-2)} ${itemPrice.dataset.currency}`;
+ var oldSum = Number(price);
+ var newSum = String(oldSum * amount);
+ itemPrice.innerHTML = `${newSum} ${itemPrice.dataset.currency}`;
}
}
}
\ No newline at end of file
--
libgit2 0.21.4