Commit ac6e2c678d15730f6fbd5a5b4864e638f709d186
1 parent
db63ba79
-Cabinet ready
Showing
7 changed files
with
416 additions
and
223 deletions
Show diff stats
frontend/assets/AppAsset.php
@@ -30,6 +30,7 @@ | @@ -30,6 +30,7 @@ | ||
30 | 'js/script.js', | 30 | 'js/script.js', |
31 | ]; | 31 | ]; |
32 | public $depends = [ | 32 | public $depends = [ |
33 | + 'hiqdev\assets\pnotify\PNotifyAsset', | ||
33 | 'yii\web\YiiAsset', | 34 | 'yii\web\YiiAsset', |
34 | 'rmrevin\yii\fontawesome\AssetBundle', | 35 | 'rmrevin\yii\fontawesome\AssetBundle', |
35 | 'yii\bootstrap\BootstrapPluginAsset', | 36 | 'yii\bootstrap\BootstrapPluginAsset', |
frontend/controllers/AccountController.php
@@ -5,9 +5,13 @@ | @@ -5,9 +5,13 @@ | ||
5 | use artbox\order\models\Customer; | 5 | use artbox\order\models\Customer; |
6 | use artbox\order\models\Order; | 6 | use artbox\order\models\Order; |
7 | use artbox\order\models\PasswordForm; | 7 | use artbox\order\models\PasswordForm; |
8 | + use artbox\order\models\Wishlist; | ||
9 | + use yii\data\ActiveDataProvider; | ||
10 | + use yii\db\ActiveQuery; | ||
8 | use yii\web\Controller; | 11 | use yii\web\Controller; |
9 | use yii\web\ForbiddenHttpException; | 12 | use yii\web\ForbiddenHttpException; |
10 | use yii\web\NotFoundHttpException; | 13 | use yii\web\NotFoundHttpException; |
14 | + use yii\web\Response; | ||
11 | 15 | ||
12 | /** | 16 | /** |
13 | * Class AccountController | 17 | * Class AccountController |
@@ -82,6 +86,43 @@ | @@ -82,6 +86,43 @@ | ||
82 | ); | 86 | ); |
83 | } | 87 | } |
84 | 88 | ||
89 | + public function actionWishlist() | ||
90 | + { | ||
91 | + /** | ||
92 | + * @var Customer $user | ||
93 | + */ | ||
94 | + $user = \Yii::$app->user->identity; | ||
95 | + $query = $user->getWishVariants() | ||
96 | + ->with( | ||
97 | + [ | ||
98 | + 'lang', | ||
99 | + 'product' => function (ActiveQuery $query) { | ||
100 | + $query->with( | ||
101 | + [ | ||
102 | + 'lang', | ||
103 | + 'image', | ||
104 | + ] | ||
105 | + ); | ||
106 | + }, | ||
107 | + ] | ||
108 | + ); | ||
109 | + $dataProvider = new ActiveDataProvider( | ||
110 | + [ | ||
111 | + 'query' => $query, | ||
112 | + 'pagination' => [ | ||
113 | + 'pageSize' => 8, | ||
114 | + ], | ||
115 | + ] | ||
116 | + ); | ||
117 | + | ||
118 | + return $this->render( | ||
119 | + 'wishlist', | ||
120 | + [ | ||
121 | + 'dataProvider' => $dataProvider, | ||
122 | + ] | ||
123 | + ); | ||
124 | + } | ||
125 | + | ||
85 | public function actionChangePassword() | 126 | public function actionChangePassword() |
86 | { | 127 | { |
87 | /** | 128 | /** |
@@ -130,7 +171,7 @@ | @@ -130,7 +171,7 @@ | ||
130 | * @var Customer $model | 171 | * @var Customer $model |
131 | */ | 172 | */ |
132 | $model = \Yii::$app->user->identity; | 173 | $model = \Yii::$app->user->identity; |
133 | - | 174 | + |
134 | if ($model->load(\Yii::$app->request->post())) { | 175 | if ($model->load(\Yii::$app->request->post())) { |
135 | // VarDumper::dump($model, 10, 1);die(); | 176 | // VarDumper::dump($model, 10, 1);die(); |
136 | $model->markAttributeDirty('birthday'); | 177 | $model->markAttributeDirty('birthday'); |
@@ -146,4 +187,35 @@ | @@ -146,4 +187,35 @@ | ||
146 | ] | 187 | ] |
147 | ); | 188 | ); |
148 | } | 189 | } |
190 | + | ||
191 | + public function actionWishlistDelete() | ||
192 | + { | ||
193 | + \Yii::$app->response->format = Response::FORMAT_JSON; | ||
194 | + if (\Yii::$app->request->isPost) { | ||
195 | + $model = Wishlist::find() | ||
196 | + ->where( | ||
197 | + [ | ||
198 | + 'user_id' => \Yii::$app->request->post('user'), | ||
199 | + ] | ||
200 | + ) | ||
201 | + ->andWhere( | ||
202 | + [ | ||
203 | + 'variant_id' => \Yii::$app->request->post('variant'), | ||
204 | + | ||
205 | + ] | ||
206 | + ) | ||
207 | + ->one(); | ||
208 | + if (!empty($model) && $model->delete()) { | ||
209 | + return [ | ||
210 | + 'success' => true, | ||
211 | + 'message' => 'ะขะพะฒะฐั ัะดะฐะปะตะฝ ะธะท ะธะทะฑัะฐะฝะฝะพะณะพ', | ||
212 | + ]; | ||
213 | + } | ||
214 | + | ||
215 | + return [ | ||
216 | + 'success' => false, | ||
217 | + 'message' => 'ะัะธะฑะบะฐ', | ||
218 | + ]; | ||
219 | + } | ||
220 | + } | ||
149 | } | 221 | } |
150 | \ No newline at end of file | 222 | \ No newline at end of file |
frontend/controllers/ProductController.php
@@ -3,10 +3,14 @@ | @@ -3,10 +3,14 @@ | ||
3 | 3 | ||
4 | use artbox\catalog\models\Product; | 4 | use artbox\catalog\models\Product; |
5 | use artbox\core\components\SeoComponent; | 5 | use artbox\core\components\SeoComponent; |
6 | + use artbox\order\models\Wishlist; | ||
6 | use yii\db\ActiveQuery; | 7 | use yii\db\ActiveQuery; |
8 | + use yii\helpers\Html; | ||
9 | + use yii\helpers\Url; | ||
7 | use yii\web\Controller; | 10 | use yii\web\Controller; |
8 | use yii\web\NotFoundHttpException; | 11 | use yii\web\NotFoundHttpException; |
9 | use Yii; | 12 | use Yii; |
13 | + use yii\web\Response; | ||
10 | 14 | ||
11 | /** | 15 | /** |
12 | * Class ProductController | 16 | * Class ProductController |
@@ -77,7 +81,7 @@ | @@ -77,7 +81,7 @@ | ||
77 | ) | 81 | ) |
78 | ->where([ 'id' => $id ]) | 82 | ->where([ 'id' => $id ]) |
79 | ->one(); | 83 | ->one(); |
80 | - if (!empty( $model )) { | 84 | + if (!empty($model)) { |
81 | if ($model->lang->alias_id !== $seo->aliasId) { | 85 | if ($model->lang->alias_id !== $seo->aliasId) { |
82 | throw new NotFoundHttpException('Wrong language'); | 86 | throw new NotFoundHttpException('Wrong language'); |
83 | } | 87 | } |
@@ -86,4 +90,114 @@ | @@ -86,4 +90,114 @@ | ||
86 | throw new NotFoundHttpException('Model not found'); | 90 | throw new NotFoundHttpException('Model not found'); |
87 | } | 91 | } |
88 | } | 92 | } |
93 | + | ||
94 | + public function actionWishlistRm() | ||
95 | + { | ||
96 | + \Yii::$app->response->format = Response::FORMAT_JSON; | ||
97 | + if (\Yii::$app->request->isPost) { | ||
98 | + $model = Wishlist::find() | ||
99 | + ->where( | ||
100 | + [ | ||
101 | + 'user_id' => \Yii::$app->request->post('user'), | ||
102 | + ] | ||
103 | + ) | ||
104 | + ->andWhere( | ||
105 | + [ | ||
106 | + 'variant_id' => \Yii::$app->request->post('variant'), | ||
107 | + | ||
108 | + ] | ||
109 | + ) | ||
110 | + ->one(); | ||
111 | + if (!empty($model) && $model->delete()) { | ||
112 | + return [ | ||
113 | + 'button' => Html::button( | ||
114 | + Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]), | ||
115 | + [ | ||
116 | + 'title' => 'ะะพะฑะฐะฒะธัั ะฒ ะธะทะฑัะฐะฝะฝะพะต', | ||
117 | + 'data' => [ | ||
118 | + 'toggle' => 'tooltip', | ||
119 | + 'placement' => 'top', | ||
120 | + 'product' => \Yii::$app->request->post('product'), | ||
121 | + 'variant' => \Yii::$app->request->post('variant'), | ||
122 | + 'user' => \Yii::$app->request->post('user'), | ||
123 | + 'url' => Url::to([ 'product/wishlist-add' ]), | ||
124 | + ], | ||
125 | + 'class' => 'wishlist-add btn btn-success pull-right', | ||
126 | + ] | ||
127 | + ), | ||
128 | + 'message' => 'ะขะพะฒะฐั ัะฑัะฐะฝ ะธะท ะธะทะฑัะฐะฝะฝะพะณะพ', | ||
129 | + ]; | ||
130 | + } | ||
131 | + | ||
132 | + return [ | ||
133 | + 'button' => Html::button( | ||
134 | + Html::tag('i', '', [ 'class' => 'fa fa-heart' ]), | ||
135 | + [ | ||
136 | + 'title' => 'ะฃะฑัะฐัั ะธะท ะธะทะฑัะฐะฝะฝะพะณะพ', | ||
137 | + 'data' => [ | ||
138 | + 'toggle' => 'tooltip', | ||
139 | + 'placement' => 'top', | ||
140 | + 'product' => \Yii::$app->request->post('product'), | ||
141 | + 'variant' => \Yii::$app->request->post('variant'), | ||
142 | + 'user' => \Yii::$app->request->post('user'), | ||
143 | + 'url' => Url::to([ 'product/wishlist-rm' ]), | ||
144 | + ], | ||
145 | + 'class' => 'wishlist-rm btn btn-success pull-right', | ||
146 | + ] | ||
147 | + ), | ||
148 | + 'message' => 'ะขะพะฒะฐั ะฝะต ะฝะฐะนะดะตะฝ', | ||
149 | + ]; | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
153 | + public function actionWishlistAdd() | ||
154 | + { | ||
155 | + \Yii::$app->response->format = Response::FORMAT_JSON; | ||
156 | + if (\Yii::$app->request->isPost) { | ||
157 | + $model = new Wishlist(); | ||
158 | + $model->user_id = \Yii::$app->request->post('user'); | ||
159 | + $model->variant_id = \Yii::$app->request->post('variant'); | ||
160 | + $model->product_id = \Yii::$app->request->post('product'); | ||
161 | + | ||
162 | + if ($model->save()) { | ||
163 | + return [ | ||
164 | + 'button' => Html::button( | ||
165 | + Html::tag('i', '', [ 'class' => 'fa fa-heart' ]), | ||
166 | + [ | ||
167 | + 'title' => 'ะฃะฑัะฐัั ะธะท ะธะทะฑัะฐะฝะฝะพะณะพ', | ||
168 | + 'data' => [ | ||
169 | + 'toggle' => 'tooltip', | ||
170 | + 'placement' => 'top', | ||
171 | + 'product' => \Yii::$app->request->post('product'), | ||
172 | + 'variant' => \Yii::$app->request->post('variant'), | ||
173 | + 'user' => \Yii::$app->request->post('user'), | ||
174 | + 'url' => Url::to([ 'product/wishlist-rm' ]), | ||
175 | + ], | ||
176 | + 'class' => 'wishlist-rm btn btn-success pull-right', | ||
177 | + ] | ||
178 | + ), | ||
179 | + 'message' => 'ะขะพะฒะฐั ะดะพะฑะฐะฒะปะตะฝ ะฒ ะธะทะฑัะฐะฝะฝะพะต', | ||
180 | + ]; | ||
181 | + } | ||
182 | + | ||
183 | + return [ | ||
184 | + 'button' => Html::button( | ||
185 | + Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]), | ||
186 | + [ | ||
187 | + 'title' => 'ะะพะฑะฐะฒะธัั ะฒ ะธะทะฑัะฐะฝะฝะพะต', | ||
188 | + 'data' => [ | ||
189 | + 'toggle' => 'tooltip', | ||
190 | + 'placement' => 'top', | ||
191 | + 'product' => \Yii::$app->request->post('product'), | ||
192 | + 'variant' => \Yii::$app->request->post('variant'), | ||
193 | + 'user' => \Yii::$app->request->post('user'), | ||
194 | + 'url' => Url::to([ 'product/wishlist-add' ]), | ||
195 | + ], | ||
196 | + 'class' => 'wishlist-add btn btn-success pull-right', | ||
197 | + ] | ||
198 | + ), | ||
199 | + 'message' => 'ะขะพะฒะฐั ะดะพะฑะฐะฒะธัั ะฝะต ะฒััะปะพ', | ||
200 | + ]; | ||
201 | + } | ||
202 | + } | ||
89 | } | 203 | } |
90 | \ No newline at end of file | 204 | \ No newline at end of file |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\catalog\models\Variant; | ||
4 | + use artbox\core\helpers\ImageHelper; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\helpers\Url; | ||
7 | + use yii\web\View; | ||
8 | + | ||
9 | + /** | ||
10 | + * @var View $this | ||
11 | + * @var Variant $model | ||
12 | + */ | ||
13 | + | ||
14 | +?> | ||
15 | + | ||
16 | +<div class="col-md-3 col-sm-4"> | ||
17 | + <div class="product"> | ||
18 | + <div class="image"> | ||
19 | + <a href="<?= Url::to( | ||
20 | + [ | ||
21 | + 'product/view', | ||
22 | + 'id' => $model->product->id, | ||
23 | + ] | ||
24 | + ) ?>"> | ||
25 | + <?= Html::a( | ||
26 | + Html::tag( | ||
27 | + 'i', | ||
28 | + '', | ||
29 | + [ | ||
30 | + 'class' => 'fa fa-close', | ||
31 | + ] | ||
32 | + ), | ||
33 | + '#', | ||
34 | + [ | ||
35 | + 'class' => 'wishlist-delete', | ||
36 | + 'data' => [ | ||
37 | + 'user' => \Yii::$app->user->identity->getId(), | ||
38 | + 'variant' => $model->id, | ||
39 | + 'product' => $model->product->id, | ||
40 | + 'url' => Url::to([ 'account/wishlist-delete' ]), | ||
41 | + ], | ||
42 | + ] | ||
43 | + ) ?> | ||
44 | + <?= ImageHelper::set( | ||
45 | + empty($model->product->image) ? '@frontend/web/img/no-image.png' : $model->product->image->getPath() | ||
46 | + ) | ||
47 | + ->cropResize(190, 190) | ||
48 | + ->renderImage( | ||
49 | + [ | ||
50 | + 'class' => 'img-responsive image1', | ||
51 | + ] | ||
52 | + ) ?> | ||
53 | + </a> | ||
54 | + </div> | ||
55 | + <!-- /.image --> | ||
56 | + <div class="text"> | ||
57 | + <h3><a href="<?= Url::to( | ||
58 | + [ | ||
59 | + 'product/view', | ||
60 | + 'id' => $model->product->id, | ||
61 | + ] | ||
62 | + ) ?>"><?= $model->product->lang->title ?></a></h3> | ||
63 | + <p class="price">ะฆะตะฝะฐ: <?= $model->price ?> ะณัะฝ.</p> | ||
64 | + <p class="buttons"> | ||
65 | + <?php | ||
66 | + if ($model->canBuy()) { | ||
67 | + echo Html::a( | ||
68 | + Html::tag( | ||
69 | + 'i', | ||
70 | + '', | ||
71 | + [ | ||
72 | + 'class' => 'fa fa-shopping-cart', | ||
73 | + ] | ||
74 | + ) . \Yii::t('app', 'ะ ะบะพัะทะธะฝั'), | ||
75 | + '#', | ||
76 | + [ | ||
77 | + 'class' => 'btn btn-template-main add-to-basket', | ||
78 | + 'data-id' => $model->id, | ||
79 | + ] | ||
80 | + ); | ||
81 | + } else { | ||
82 | + echo Html::a( | ||
83 | + \Yii::t('app', 'ะะตั ะฒ ะฝะฐะปะธัะธะธ'), | ||
84 | + '#', | ||
85 | + [ | ||
86 | + 'class' => 'btn btn-info disabled', | ||
87 | + 'data-id' => $model->id, | ||
88 | + ] | ||
89 | + ); | ||
90 | + } | ||
91 | + ?> | ||
92 | + </p> | ||
93 | + </div> | ||
94 | + <!-- /.text --> | ||
95 | + </div> | ||
96 | + <!-- /.product --> | ||
97 | +</div> |
frontend/views/account/wishlist.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | + use yii\data\ActiveDataProvider; | ||
3 | use yii\web\View; | 4 | use yii\web\View; |
5 | + use yii\widgets\ListView; | ||
6 | + use yii\widgets\Pjax; | ||
4 | 7 | ||
5 | /** | 8 | /** |
6 | - * @var View $this | 9 | + * @var View $this |
10 | + * @var ActiveDataProvider $dataProvider | ||
7 | */ | 11 | */ |
8 | - | 12 | + |
13 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'ะะพะธ ะฟะพะถะตะปะฐะฝะธั'); | ||
9 | ?> | 14 | ?> |
10 | 15 | ||
11 | <div id="content"> | 16 | <div id="content"> |
@@ -19,221 +24,23 @@ _________________________________________________________ --> | @@ -19,221 +24,23 @@ _________________________________________________________ --> | ||
19 | <div class="col-md-9 clearfix"> | 24 | <div class="col-md-9 clearfix"> |
20 | 25 | ||
21 | <div class="row products"> | 26 | <div class="row products"> |
27 | + <?php | ||
28 | + Pjax::begin( | ||
29 | + [ | ||
30 | + 'id' => 'wishlist-products', | ||
31 | + ] | ||
32 | + ); | ||
33 | + echo ListView::widget( | ||
34 | + [ | ||
35 | + 'dataProvider' => $dataProvider, | ||
36 | + 'itemView' => '_product', | ||
37 | + 'layout' => '{items}{pager}', | ||
38 | + ] | ||
39 | + ); | ||
40 | + Pjax::end(); | ||
41 | + ?> | ||
22 | 42 | ||
23 | - <div class="col-md-3 col-sm-4"> | ||
24 | - <div class="product"> | ||
25 | - <div class="image"> | ||
26 | - <a href="shop-detail.html"> | ||
27 | - <img src="img/product1.jpg" alt="" class="img-responsive image1"> | ||
28 | - </a> | ||
29 | - </div> | ||
30 | - <!-- /.image --> | ||
31 | - <div class="text"> | ||
32 | - <h3><a href="shop-detail.html">Fur coat with very but very very long name</a></h3> | ||
33 | - <p class="price">143.00</p> | ||
34 | - <p class="buttons"> | ||
35 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
36 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
37 | - </p> | ||
38 | - </div> | ||
39 | - <!-- /.text --> | ||
40 | - </div> | ||
41 | - <!-- /.product --> | ||
42 | - </div> | ||
43 | - | ||
44 | - <div class="col-md-3 col-sm-4"> | ||
45 | - <div class="product"> | ||
46 | - <div class="image"> | ||
47 | - <a href="shop-detail.html"> | ||
48 | - <img src="img/product2.jpg" alt="" class="img-responsive image1"> | ||
49 | - </a> | ||
50 | - </div> | ||
51 | - <!-- /.image --> | ||
52 | - <div class="text"> | ||
53 | - <h3><a href="shop-detail.html">White Blouse Armani</a></h3> | ||
54 | - <p class="price"> | ||
55 | - <del>280</del> | ||
56 | - 143.00 | ||
57 | - </p> | ||
58 | - <p class="buttons"> | ||
59 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
60 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
61 | - </p> | ||
62 | - </div> | ||
63 | - <!-- /.text --> | ||
64 | - | ||
65 | - <div class="ribbon sale"> | ||
66 | - <div class="theribbon">SALE</div> | ||
67 | - <div class="ribbon-background"></div> | ||
68 | - </div> | ||
69 | - <!-- /.ribbon --> | ||
70 | - | ||
71 | - <div class="ribbon new"> | ||
72 | - <div class="theribbon">NEW</div> | ||
73 | - <div class="ribbon-background"></div> | ||
74 | - </div> | ||
75 | - <!-- /.ribbon --> | ||
76 | - </div> | ||
77 | - <!-- /.product --> | ||
78 | - </div> | ||
79 | - | ||
80 | - <div class="col-md-3 col-sm-4"> | ||
81 | - <div class="product"> | ||
82 | - <div class="image"> | ||
83 | - <a href="shop-detail.html"> | ||
84 | - <img src="img/product3.jpg" alt="" class="img-responsive image1"> | ||
85 | - </a> | ||
86 | - </div> | ||
87 | - <!-- /.image --> | ||
88 | - <div class="text"> | ||
89 | - <h3><a href="shop-detail.html">Black Blouse Versace</a></h3> | ||
90 | - <p class="price">143.00</p> | ||
91 | - <p class="buttons"> | ||
92 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
93 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
94 | - </p> | ||
95 | - | ||
96 | - </div> | ||
97 | - <!-- /.text --> | ||
98 | - </div> | ||
99 | - <!-- /.product --> | ||
100 | - </div> | ||
101 | - | ||
102 | - <div class="col-md-3 col-sm-4"> | ||
103 | - <div class="product"> | ||
104 | - <div class="image"> | ||
105 | - <a href="shop-detail.html"> | ||
106 | - <img src="img/product4.jpg" alt="" class="img-responsive image1"> | ||
107 | - </a> | ||
108 | - </div> | ||
109 | - <!-- /.image --> | ||
110 | - <div class="text"> | ||
111 | - <h3><a href="shop-detail.html">Black Blouse Versace</a></h3> | ||
112 | - <p class="price">143.00</p> | ||
113 | - <p class="buttons"> | ||
114 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
115 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
116 | - </p> | ||
117 | - | ||
118 | - </div> | ||
119 | - <!-- /.text --> | ||
120 | - </div> | ||
121 | - <!-- /.product --> | ||
122 | - </div> | ||
123 | - | ||
124 | - <div class="col-md-3 col-sm-4"> | ||
125 | - <div class="product"> | ||
126 | - <div class="image"> | ||
127 | - <a href="shop-detail.html"> | ||
128 | - <img src="img/product3.jpg" alt="" class="img-responsive image1"> | ||
129 | - </a> | ||
130 | - </div> | ||
131 | - <!-- /.image --> | ||
132 | - <div class="text"> | ||
133 | - <h3><a href="shop-detail.html">White Blouse Armani</a></h3> | ||
134 | - <p class="price"> | ||
135 | - <del>280</del> | ||
136 | - 143.00 | ||
137 | - </p> | ||
138 | - <p class="buttons"> | ||
139 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
140 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
141 | - </p> | ||
142 | - </div> | ||
143 | - <!-- /.text --> | ||
144 | - | ||
145 | - <div class="ribbon sale"> | ||
146 | - <div class="theribbon">SALE</div> | ||
147 | - <div class="ribbon-background"></div> | ||
148 | - </div> | ||
149 | - <!-- /.ribbon --> | ||
150 | - | ||
151 | - <div class="ribbon new"> | ||
152 | - <div class="theribbon">NEW</div> | ||
153 | - <div class="ribbon-background"></div> | ||
154 | - </div> | ||
155 | - <!-- /.ribbon --> | ||
156 | - </div> | ||
157 | - <!-- /.product --> | ||
158 | - </div> | ||
159 | - | ||
160 | - <div class="col-md-3 col-sm-4"> | ||
161 | - <div class="product"> | ||
162 | - <div class="image"> | ||
163 | - <a href="shop-detail.html"> | ||
164 | - <img src="img/product4.jpg" alt="" class="img-responsive image1"> | ||
165 | - </a> | ||
166 | - </div> | ||
167 | - <!-- /.image --> | ||
168 | - <div class="text"> | ||
169 | - <h3><a href="shop-detail.html">White Blouse Versace</a></h3> | ||
170 | - <p class="price">143.00</p> | ||
171 | - <p class="buttons"> | ||
172 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
173 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
174 | - </p> | ||
175 | - | ||
176 | - </div> | ||
177 | - <!-- /.text --> | ||
178 | - | ||
179 | - <div class="ribbon new"> | ||
180 | - <div class="theribbon">NEW</div> | ||
181 | - <div class="ribbon-background"></div> | ||
182 | - </div> | ||
183 | - <!-- /.ribbon --> | ||
184 | - </div> | ||
185 | - <!-- /.product --> | ||
186 | - </div> | ||
187 | - | ||
188 | - <div class="col-md-3 col-sm-4"> | ||
189 | - <div class="product"> | ||
190 | - <div class="image"> | ||
191 | - <a href="shop-detail.html"> | ||
192 | - <img src="img/product2.jpg" alt="" class="img-responsive image1"> | ||
193 | - </a> | ||
194 | - </div> | ||
195 | - <!-- /.image --> | ||
196 | - <div class="text"> | ||
197 | - <h3><a href="shop-detail.html">White Blouse Versace</a></h3> | ||
198 | - <p class="price">143.00</p> | ||
199 | - <p class="buttons"> | ||
200 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
201 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
202 | - </p> | ||
203 | - | ||
204 | - </div> | ||
205 | - <!-- /.text --> | ||
206 | - | ||
207 | - <div class="ribbon new"> | ||
208 | - <div class="theribbon">NEW</div> | ||
209 | - <div class="ribbon-background"></div> | ||
210 | - </div> | ||
211 | - <!-- /.ribbon --> | ||
212 | - </div> | ||
213 | - <!-- /.product --> | ||
214 | - </div> | ||
215 | 43 | ||
216 | - <div class="col-md-3 col-sm-4"> | ||
217 | - <div class="product"> | ||
218 | - <div class="image"> | ||
219 | - <a href="shop-detail.html"> | ||
220 | - <img src="img/product1.jpg" alt="" class="img-responsive image1"> | ||
221 | - </a> | ||
222 | - </div> | ||
223 | - <!-- /.image --> | ||
224 | - <div class="text"> | ||
225 | - <h3><a href="shop-detail.html">Fur coat</a></h3> | ||
226 | - <p class="price">143.00</p> | ||
227 | - <p class="buttons"> | ||
228 | - <a href="shop-detail.html" class="btn btn-default">ะะพะดัะพะฑะฝะตะต</a> | ||
229 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>ะ ะบะพัะทะธะฝั</a> | ||
230 | - </p> | ||
231 | - | ||
232 | - </div> | ||
233 | - <!-- /.text --> | ||
234 | - </div> | ||
235 | - <!-- /.product --> | ||
236 | - </div> | ||
237 | <!-- /.col-md-4 --> | 44 | <!-- /.col-md-4 --> |
238 | </div> | 45 | </div> |
239 | <!-- /.products --> | 46 | <!-- /.products --> |
frontend/views/product/view.php
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | use yii\bootstrap\ActiveForm; | 8 | use yii\bootstrap\ActiveForm; |
9 | use yii\bootstrap\Html; | 9 | use yii\bootstrap\Html; |
10 | use yii\helpers\ArrayHelper; | 10 | use yii\helpers\ArrayHelper; |
11 | + use yii\helpers\Url; | ||
11 | use yii\web\View; | 12 | use yii\web\View; |
12 | 13 | ||
13 | /** | 14 | /** |
@@ -201,12 +202,51 @@ | @@ -201,12 +202,51 @@ | ||
201 | } | 202 | } |
202 | ?> | 203 | ?> |
203 | <?php | 204 | <?php |
204 | - /* | ||
205 | - ?> | ||
206 | - <button class="btn btn-default pull-right" data-toggle="tooltip" data-placement="top" title="ะะพะฑะฐะฒะธัั ะฒ ะธะทะฑัะฐะฝะฝะพะต"> | ||
207 | - <i class="fa fa-heart-o"></i> | ||
208 | - </button> | ||
209 | - */ | 205 | + if (\Yii::$app->user->isGuest) { |
206 | + echo Html::button( | ||
207 | + Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]), | ||
208 | + [ | ||
209 | + 'title' => 'ะะพะฑะฐะฒะธัั ะฒ ะธะทะฑัะฐะฝะฝะพะต', | ||
210 | + 'data' => [ | ||
211 | + 'toggle' => 'tooltip', | ||
212 | + 'placement' => 'top', | ||
213 | + ], | ||
214 | + 'class' => 'btn btn-default pull-right disabled', | ||
215 | + ] | ||
216 | + ); | ||
217 | + } elseif (in_array($variant->id, \Yii::$app->user->identity->wishlist)) { | ||
218 | + echo Html::button( | ||
219 | + Html::tag('i', '', [ 'class' => 'fa fa-heart' ]), | ||
220 | + [ | ||
221 | + 'title' => 'ะฃะฑัะฐัั ะธะท ะธะทะฑัะฐะฝะฝะพะณะพ', | ||
222 | + 'data' => [ | ||
223 | + 'toggle' => 'tooltip', | ||
224 | + 'placement' => 'top', | ||
225 | + 'product' => $model->id, | ||
226 | + 'variant' => $variant->id, | ||
227 | + 'user' => \Yii::$app->user->identity->getId(), | ||
228 | + 'url' => Url::to([ 'product/wishlist-rm' ]), | ||
229 | + ], | ||
230 | + 'class' => 'wishlist-rm btn btn-success pull-right', | ||
231 | + ] | ||
232 | + ); | ||
233 | + } else { | ||
234 | + echo Html::button( | ||
235 | + Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]), | ||
236 | + [ | ||
237 | + 'title' => 'ะะพะฑะฐะฒะธัั ะฒ ะธะทะฑัะฐะฝะฝะพะต', | ||
238 | + 'data' => [ | ||
239 | + 'toggle' => 'tooltip', | ||
240 | + 'placement' => 'top', | ||
241 | + 'product' => $model->id, | ||
242 | + 'variant' => $variant->id, | ||
243 | + 'user' => \Yii::$app->user->identity->getId(), | ||
244 | + 'url' => Url::to([ 'product/wishlist-add' ]), | ||
245 | + ], | ||
246 | + 'class' => 'wishlist-add btn btn-success pull-right', | ||
247 | + ] | ||
248 | + ); | ||
249 | + } | ||
210 | ?> | 250 | ?> |
211 | </p> | 251 | </p> |
212 | <hr> | 252 | <hr> |
frontend/web/js/script.js
@@ -171,6 +171,68 @@ $(function() { | @@ -171,6 +171,68 @@ $(function() { | ||
171 | } | 171 | } |
172 | }.bind(this)); | 172 | }.bind(this)); |
173 | 173 | ||
174 | + $(document) | ||
175 | + .on( | ||
176 | + 'click', '.wishlist-rm, .wishlist-add', function() { | ||
177 | + var button = $(this); | ||
178 | + $.ajax( | ||
179 | + { | ||
180 | + url: button.data('url'), | ||
181 | + type: "POST", | ||
182 | + data: { | ||
183 | + 'variant': button.data('variant'), | ||
184 | + 'product': button.data('product'), | ||
185 | + 'user': button.data('user') | ||
186 | + }, | ||
187 | + success: function(data) { | ||
188 | + button.replaceWith(data.button); | ||
189 | + new PNotify( | ||
190 | + { | ||
191 | + title: 'Info', | ||
192 | + text: data.message, | ||
193 | + type: 'info', | ||
194 | + styling: 'fontawesome' | ||
195 | + } | ||
196 | + ); | ||
197 | + | ||
198 | + } | ||
199 | + } | ||
200 | + ) | ||
201 | + } | ||
202 | + ); | ||
203 | + | ||
204 | + $(document) | ||
205 | + .on( | ||
206 | + 'click', '.wishlist-delete', function(e) { | ||
207 | + e.preventDefault(); | ||
208 | + var button = $(this); | ||
209 | + $.ajax( | ||
210 | + { | ||
211 | + url: button.data('url'), | ||
212 | + type: "POST", | ||
213 | + data: { | ||
214 | + 'product': button.data('product'), | ||
215 | + 'variant': button.data('variant'), | ||
216 | + 'user': button.data('user') | ||
217 | + }, | ||
218 | + success: function(data) { | ||
219 | + if (data.success) { | ||
220 | + $.pjax.reload({container: '#wishlist-products'}); | ||
221 | + new PNotify( | ||
222 | + { | ||
223 | + title: 'Info', | ||
224 | + text: data.message, | ||
225 | + type: 'info', | ||
226 | + styling: 'fontawesome' | ||
227 | + } | ||
228 | + ); | ||
229 | + } | ||
230 | + } | ||
231 | + } | ||
232 | + ); | ||
233 | + } | ||
234 | + ); | ||
235 | + | ||
174 | }); | 236 | }); |
175 | function showLoader(container) { | 237 | function showLoader(container) { |
176 | $(container) | 238 | $(container) |