Commit 94a1dbd29313d96289d45e4b6fdaff085376674f
1 parent
9c88815c
Checkout top
Showing
2 changed files
with
52 additions
and
255 deletions
Show diff stats
frontend/controllers/CheckoutController.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace frontend\controllers; |
| 4 | - | |
| 4 | + | |
| 5 | + use artbox\catalog\models\Product; | |
| 5 | 6 | use artbox\order\models\Delivery; |
| 6 | 7 | use artbox\order\models\OrderProduct; |
| 7 | 8 | use artbox\order\models\Payment; |
| 8 | 9 | use frontend\models\Order; |
| 9 | 10 | use yii\web\Controller; |
| 10 | - | |
| 11 | + | |
| 11 | 12 | /** |
| 12 | 13 | * Class CheckoutController |
| 13 | 14 | * |
| ... | ... | @@ -26,15 +27,21 @@ |
| 26 | 27 | if (!empty($data)) { |
| 27 | 28 | $variants = $basket->findModels(array_keys($data)); |
| 28 | 29 | } |
| 30 | + $topItems = Product::find() | |
| 31 | + ->with('lang', 'image', 'variants') | |
| 32 | + ->is('mask', 1) | |
| 33 | + ->limit(20) | |
| 34 | + ->all(); | |
| 29 | 35 | return $this->render( |
| 30 | 36 | 'index', |
| 31 | 37 | [ |
| 32 | 38 | 'basket' => $basket, |
| 33 | 39 | 'variants' => $variants, |
| 40 | + 'topItems' => $topItems, | |
| 34 | 41 | ] |
| 35 | 42 | ); |
| 36 | 43 | } |
| 37 | - | |
| 44 | + | |
| 38 | 45 | public function actionInfo() |
| 39 | 46 | { |
| 40 | 47 | $model = new Order( |
| ... | ... | @@ -65,7 +72,7 @@ |
| 65 | 72 | ] |
| 66 | 73 | ); |
| 67 | 74 | } |
| 68 | - | |
| 75 | + | |
| 69 | 76 | public function actionDelivery() |
| 70 | 77 | { |
| 71 | 78 | $model = new Order( |
| ... | ... | @@ -84,10 +91,10 @@ |
| 84 | 91 | return $this->redirect([ 'info' ]); |
| 85 | 92 | } |
| 86 | 93 | $deliveries = Delivery::find() |
| 87 | - ->with('lang') | |
| 88 | - ->where([ 'status' => true ]) | |
| 89 | - ->orderBy([ 'sort' => SORT_ASC ]) | |
| 90 | - ->all(); | |
| 94 | + ->with('lang') | |
| 95 | + ->where([ 'status' => true ]) | |
| 96 | + ->orderBy([ 'sort' => SORT_ASC ]) | |
| 97 | + ->all(); | |
| 91 | 98 | return $this->render( |
| 92 | 99 | 'delivery', |
| 93 | 100 | [ |
| ... | ... | @@ -96,7 +103,7 @@ |
| 96 | 103 | ] |
| 97 | 104 | ); |
| 98 | 105 | } |
| 99 | - | |
| 106 | + | |
| 100 | 107 | public function actionPayment() |
| 101 | 108 | { |
| 102 | 109 | $model = new Order( |
| ... | ... | @@ -116,10 +123,10 @@ |
| 116 | 123 | return $this->redirect('confirm'); |
| 117 | 124 | } else { |
| 118 | 125 | $payments = Payment::find() |
| 119 | - ->with('lang') | |
| 120 | - ->where([ 'status' => true ]) | |
| 121 | - ->orderBy([ 'sort' => SORT_ASC ]) | |
| 122 | - ->all(); | |
| 126 | + ->with('lang') | |
| 127 | + ->where([ 'status' => true ]) | |
| 128 | + ->orderBy([ 'sort' => SORT_ASC ]) | |
| 129 | + ->all(); | |
| 123 | 130 | return $this->render( |
| 124 | 131 | 'payment', |
| 125 | 132 | [ |
| ... | ... | @@ -135,7 +142,7 @@ |
| 135 | 142 | 'delivery' |
| 136 | 143 | ); |
| 137 | 144 | } |
| 138 | - | |
| 145 | + | |
| 139 | 146 | public function actionConfirm() |
| 140 | 147 | { |
| 141 | 148 | $model = new Order(); |
| ... | ... | @@ -208,7 +215,7 @@ |
| 208 | 215 | } |
| 209 | 216 | return $model->getErrors(); |
| 210 | 217 | } |
| 211 | - | |
| 218 | + | |
| 212 | 219 | public function beforeAction($action) |
| 213 | 220 | { |
| 214 | 221 | /** | ... | ... |
frontend/views/checkout/index.php
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | * @var \yii\web\View $this |
| 4 | 4 | * @var \artbox\order\models\Basket $basket |
| 5 | 5 | * @var \artbox\catalog\models\Variant[] $variants |
| 6 | + * @var \artbox\catalog\models\Product[] $topItems | |
| 6 | 7 | */ |
| 7 | 8 | use artbox\core\helpers\ImageHelper; |
| 8 | 9 | use yii\bootstrap\Html; |
| ... | ... | @@ -208,249 +209,38 @@ |
| 208 | 209 | } |
| 209 | 210 | ?> |
| 210 | 211 | </div> |
| 211 | - <div class="col-md-12"> | |
| 212 | - <div class="heading text-center"> | |
| 213 | - <h2>Смотрите также</h2> | |
| 214 | - </div> | |
| 215 | - | |
| 216 | - <div class="product-carousel"> | |
| 217 | - <div class="homepage owl-carousel"> | |
| 218 | - <div class="products"> | |
| 219 | - <div class="col-md-3 col-sm-6"> | |
| 220 | - <div class="product"> | |
| 221 | - <div class="image"> | |
| 222 | - <a href="shop-detail.html"> | |
| 223 | - <img src="/img/product1.jpg" alt="" class="img-responsive image1"> | |
| 224 | - </a> | |
| 225 | - </div> | |
| 226 | - <!-- /.image --> | |
| 227 | - <div class="text"> | |
| 228 | - <h3><a href="shop-detail.html">Fur coat with very but very very long name</a></h3> | |
| 229 | - <p class="price">143.00</p> | |
| 230 | - <p class="buttons"> | |
| 231 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 232 | - </p> | |
| 233 | - </div> | |
| 234 | - <!-- /.text --> | |
| 235 | - | |
| 236 | - <div class="ribbon new"> | |
| 237 | - <div class="theribbon">Новое</div> | |
| 238 | - <div class="ribbon-background"></div> | |
| 239 | - </div> | |
| 240 | - <!-- /.ribbon --> | |
| 241 | - </div> | |
| 242 | - <!-- /.product --> | |
| 243 | - </div> | |
| 244 | - | |
| 245 | - <div class="col-md-3 col-sm-6"> | |
| 246 | - <div class="product"> | |
| 247 | - <div class="image"> | |
| 248 | - <a href="shop-detail.html"> | |
| 249 | - <img src="/img/product2.jpg" alt="" class="img-responsive image1"> | |
| 250 | - </a> | |
| 251 | - </div> | |
| 252 | - <!-- /.image --> | |
| 253 | - <div class="text"> | |
| 254 | - <h3><a href="shop-detail.html">White Blouse Armani</a></h3> | |
| 255 | - <p class="price"> | |
| 256 | - <del>280</del> | |
| 257 | - 143.00 | |
| 258 | - </p> | |
| 259 | - <p class="buttons"> | |
| 260 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 261 | - </p> | |
| 262 | - </div> | |
| 263 | - <!-- /.text --> | |
| 264 | - | |
| 265 | - <div class="ribbon sale"> | |
| 266 | - <div class="theribbon">Акция</div> | |
| 267 | - <div class="ribbon-background"></div> | |
| 268 | - </div> | |
| 269 | - <!-- /.ribbon --> | |
| 270 | - | |
| 271 | - <div class="ribbon new"> | |
| 272 | - <div class="theribbon">Новое</div> | |
| 273 | - <div class="ribbon-background"></div> | |
| 274 | - </div> | |
| 275 | - <!-- /.ribbon --> | |
| 276 | - </div> | |
| 277 | - <!-- /.product --> | |
| 278 | - </div> | |
| 279 | - | |
| 280 | - <div class="col-md-3 col-sm-6"> | |
| 281 | - <div class="product"> | |
| 282 | - <div class="image"> | |
| 283 | - <a href="shop-detail.html"> | |
| 284 | - <img src="/img/product3.jpg" alt="" class="img-responsive image1"> | |
| 285 | - </a> | |
| 286 | - </div> | |
| 287 | - <!-- /.image --> | |
| 288 | - <div class="text"> | |
| 289 | - <h3><a href="shop-detail.html">Black Blouse Versace</a></h3> | |
| 290 | - <p class="price">143.00</p> | |
| 291 | - <p class="buttons"> | |
| 292 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 293 | - </p> | |
| 294 | - | |
| 295 | - </div> | |
| 296 | - <!-- /.text --> | |
| 297 | - | |
| 298 | - <div class="ribbon new"> | |
| 299 | - <div class="theribbon">Новое</div> | |
| 300 | - <div class="ribbon-background"></div> | |
| 301 | - </div> | |
| 302 | - <!-- /.ribbon --> | |
| 303 | - </div> | |
| 304 | - <!-- /.product --> | |
| 305 | - </div> | |
| 306 | - | |
| 307 | - <div class="col-md-3 col-sm-6"> | |
| 308 | - <div class="product"> | |
| 309 | - <div class="image"> | |
| 310 | - <a href="shop-detail.html"> | |
| 311 | - <img src="/img/product3.jpg" alt="" class="img-responsive image1"> | |
| 312 | - </a> | |
| 313 | - </div> | |
| 314 | - <!-- /.image --> | |
| 315 | - <div class="text"> | |
| 316 | - <h3><a href="shop-detail.html">Black Blouse Versace</a></h3> | |
| 317 | - <p class="price">143.00</p> | |
| 318 | - <p class="buttons"> | |
| 319 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 320 | - </p> | |
| 321 | - | |
| 322 | - </div> | |
| 323 | - <!-- /.text --> | |
| 324 | - | |
| 325 | - <div class="ribbon new"> | |
| 326 | - <div class="theribbon">Новое</div> | |
| 327 | - <div class="ribbon-background"></div> | |
| 328 | - </div> | |
| 329 | - <!-- /.ribbon --> | |
| 330 | - </div> | |
| 331 | - <!-- /.product --> | |
| 332 | - </div> | |
| 333 | - </div> | |
| 334 | - | |
| 335 | - <div class="products"> | |
| 336 | - <div class="col-md-3 col-sm-6"> | |
| 337 | - <div class="product"> | |
| 338 | - <div class="image"> | |
| 339 | - <a href="shop-detail.html"> | |
| 340 | - <img src="/img/product1.jpg" alt="" class="img-responsive image1"> | |
| 341 | - </a> | |
| 342 | - </div> | |
| 343 | - <!-- /.image --> | |
| 344 | - <div class="text"> | |
| 345 | - <h3><a href="shop-detail.html">Fur coat with very but very very long name</a></h3> | |
| 346 | - <p class="price">143.00</p> | |
| 347 | - <p class="buttons"> | |
| 348 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 349 | - </p> | |
| 350 | - </div> | |
| 351 | - <!-- /.text --> | |
| 352 | - | |
| 353 | - <div class="ribbon new"> | |
| 354 | - <div class="theribbon">Новое</div> | |
| 355 | - <div class="ribbon-background"></div> | |
| 356 | - </div> | |
| 357 | - <!-- /.ribbon --> | |
| 358 | - </div> | |
| 359 | - <!-- /.product --> | |
| 360 | - </div> | |
| 361 | - | |
| 362 | - <div class="col-md-3 col-sm-6"> | |
| 363 | - <div class="product"> | |
| 364 | - <div class="image"> | |
| 365 | - <a href="shop-detail.html"> | |
| 366 | - <img src="/img/product2.jpg" alt="" class="img-responsive image1"> | |
| 367 | - </a> | |
| 368 | - </div> | |
| 369 | - <!-- /.image --> | |
| 370 | - <div class="text"> | |
| 371 | - <h3><a href="shop-detail.html">White Blouse Armani</a></h3> | |
| 372 | - <p class="price"> | |
| 373 | - <del>280</del> | |
| 374 | - 143.00 | |
| 375 | - </p> | |
| 376 | - <p class="buttons"> | |
| 377 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 378 | - </p> | |
| 379 | - </div> | |
| 380 | - <!-- /.text --> | |
| 381 | - | |
| 382 | - <div class="ribbon sale"> | |
| 383 | - <div class="theribbon">Акция</div> | |
| 384 | - <div class="ribbon-background"></div> | |
| 385 | - </div> | |
| 386 | - <!-- /.ribbon --> | |
| 387 | - | |
| 388 | - <div class="ribbon new"> | |
| 389 | - <div class="theribbon">Новое</div> | |
| 390 | - <div class="ribbon-background"></div> | |
| 391 | - </div> | |
| 392 | - <!-- /.ribbon --> | |
| 393 | - </div> | |
| 394 | - <!-- /.product --> | |
| 395 | - </div> | |
| 396 | - | |
| 397 | - <div class="col-md-3 col-sm-6"> | |
| 398 | - <div class="product"> | |
| 399 | - <div class="image"> | |
| 400 | - <a href="shop-detail.html"> | |
| 401 | - <img src="/img/product3.jpg" alt="" class="img-responsive image1"> | |
| 402 | - </a> | |
| 403 | - </div> | |
| 404 | - <!-- /.image --> | |
| 405 | - <div class="text"> | |
| 406 | - <h3><a href="shop-detail.html">Black Blouse Versace</a></h3> | |
| 407 | - <p class="price">143.00</p> | |
| 408 | - <p class="buttons"> | |
| 409 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 410 | - </p> | |
| 411 | - | |
| 412 | - </div> | |
| 413 | - <!-- /.text --> | |
| 414 | - | |
| 415 | - <div class="ribbon new"> | |
| 416 | - <div class="theribbon">Новое</div> | |
| 417 | - <div class="ribbon-background"></div> | |
| 418 | - </div> | |
| 419 | - <!-- /.ribbon --> | |
| 420 | - </div> | |
| 421 | - <!-- /.product --> | |
| 212 | + <?php | |
| 213 | + if (!empty($topItems)) { | |
| 214 | + ?> | |
| 215 | + <div class="heading text-center"> | |
| 216 | + <h2><?php echo \Yii::t('app', 'Смотрите также'); ?></h2> | |
| 422 | 217 | </div> |
| 423 | - | |
| 424 | - <div class="col-md-3 col-sm-6"> | |
| 425 | - <div class="product"> | |
| 426 | - <div class="image"> | |
| 427 | - <a href="shop-detail.html"> | |
| 428 | - <img src="/img/product3.jpg" alt="" class="img-responsive image1"> | |
| 429 | - </a> | |
| 430 | - </div> | |
| 431 | - <!-- /.image --> | |
| 432 | - <div class="text"> | |
| 433 | - <h3><a href="shop-detail.html">Black Blouse Versace</a></h3> | |
| 434 | - <p class="price">143.00</p> | |
| 435 | - <p class="buttons"> | |
| 436 | - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a> | |
| 437 | - </p> | |
| 438 | - | |
| 439 | - </div> | |
| 440 | - <!-- /.text --> | |
| 441 | - | |
| 442 | - <div class="ribbon new"> | |
| 443 | - <div class="theribbon">Новое</div> | |
| 444 | - <div class="ribbon-background"></div> | |
| 445 | - </div> | |
| 446 | - <!-- /.ribbon --> | |
| 218 | + <div class="product-carousel"> | |
| 219 | + <div class="homepage owl-carousel"> | |
| 220 | + <?php | |
| 221 | + $newItemsArrays = array_chunk($topItems, 4); | |
| 222 | + foreach ($newItemsArrays as $newItemsArray) { | |
| 223 | + ?> | |
| 224 | + <div class="products"> | |
| 225 | + <?php | |
| 226 | + foreach ($newItemsArray as $product) { | |
| 227 | + echo $this->render( | |
| 228 | + '@frontend/views/site/_slider_product', | |
| 229 | + [ | |
| 230 | + 'product' => $product, | |
| 231 | + ] | |
| 232 | + ); | |
| 233 | + } | |
| 234 | + ?> | |
| 235 | + </div> | |
| 236 | + <?php | |
| 237 | + } | |
| 238 | + ?> | |
| 447 | 239 | </div> |
| 448 | - <!-- /.product --> | |
| 449 | 240 | </div> |
| 450 | - </div> | |
| 451 | - </div> | |
| 452 | - </div> | |
| 453 | - </div> | |
| 241 | + <?php | |
| 242 | + } | |
| 243 | + ?> | |
| 454 | 244 | </div> |
| 455 | 245 | </div> |
| 456 | 246 | </div> |
| 457 | 247 | \ No newline at end of file | ... | ... |