Blame view

frontend/views/product/view.php 18.5 KB
e9f8a5ec   Yarik   Detail page
1
2
3
4
5
6
  <?php
      use artbox\catalog\models\OptionGroup;
      use artbox\catalog\models\Product;
      use artbox\catalog\models\Variant;
      use artbox\core\components\SeoComponent;
      use artbox\core\helpers\ImageHelper;
6c8e3423   Yarik   Fast buy
7
8
      use frontend\models\Order;
      use yii\bootstrap\ActiveForm;
e9f8a5ec   Yarik   Detail page
9
10
      use yii\bootstrap\Html;
      use yii\helpers\ArrayHelper;
ac6e2c67   Alexey Boroda   -Cabinet ready
11
      use yii\helpers\Url;
e9f8a5ec   Yarik   Detail page
12
13
14
15
16
17
18
19
20
21
22
      use yii\web\View;
      
      /**
       * @var View         $this
       * @var Product      $model
       * @var Variant      $variant
       * @var SeoComponent $seo
       * @var array        $groups
       * @var Product[]    $similar
       */
      $seo = \Yii::$app->get('seo');
ce64afcb   Yarik   Image fixes
23
24
      if (!empty($model->category)) {
          if (!empty($model->category->parent)) {
e9f8a5ec   Yarik   Detail page
25
26
27
28
              $this->params[ 'breadcrumbs' ][] = [
                  'label' => $model->category->parent->lang->title,
                  'url'   => [
                      '/category/view',
71c16737   Yarik   Url manager fix
29
                      'category' => $model->category->parent->lang->alias->value,
e9f8a5ec   Yarik   Detail page
30
31
32
33
34
35
36
                  ],
              ];
          }
          $this->params[ 'breadcrumbs' ][] = [
              'label' => $model->category->lang->title,
              'url'   => [
                  '/category/view',
71c16737   Yarik   Url manager fix
37
                  'category' => $model->category->lang->alias->value,
e9f8a5ec   Yarik   Detail page
38
39
40
41
              ],
          ];
      }
      $this->params[ 'breadcrumbs' ][] = $seo->title;
ce64afcb   Yarik   Image fixes
42
      $images = $model->images;
4b0990fd   Yarik   Image fixes
43
      if (!empty($model->image)) {
ce64afcb   Yarik   Image fixes
44
          array_unshift($images, $model->image);
4b0990fd   Yarik   Image fixes
45
      }
e9f8a5ec   Yarik   Detail page
46
47
  ?>
  <div id="content">
ce64afcb   Yarik   Image fixes
48
49
50
51
52
53
54
55
56
57
58
59
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          
          <div class="row" id="productMain">
            <div class="col-sm-6">
              <div id="mainImage">
                  <?php
                      if (!empty($images)) {
                          echo ImageHelper::set($images[ 0 ]->getPath())
                                          ->fillResize(555, 555)
                                          ->renderImage(
e9f8a5ec   Yarik   Detail page
60
                                              [
ce64afcb   Yarik   Image fixes
61
62
63
                                                  'class' => 'img-responsive',
                                                  'alt'   => $model->lang->title,
                                                  'title' => $model->lang->title,
e9f8a5ec   Yarik   Detail page
64
65
                                              ]
                                          );
ce64afcb   Yarik   Image fixes
66
67
68
69
                      } else {
                          echo ImageHelper::set('@frontend/web/img/no-image.png')
                                          ->fillResize(555, 555)
                                          ->renderImage(
e9f8a5ec   Yarik   Detail page
70
                                              [
ce64afcb   Yarik   Image fixes
71
72
73
                                                  'class' => 'img-responsive',
                                                  'alt'   => $model->lang->title,
                                                  'title' => $model->lang->title,
e9f8a5ec   Yarik   Detail page
74
                                              ]
ce64afcb   Yarik   Image fixes
75
76
77
78
79
80
                                          );
                      }
                  ?>
              </div>
                
                <?php
8cd678be   Yarik   Special pages
81
                    if ($model->is('akcia')) {
ce64afcb   Yarik   Image fixes
82
83
                        ?>
                      <div class="ribbon sale">
46c5cef5   Eugeny Galkovskiy   Переводы
84
                        <div class="theribbon">АКЦИЯ</div>
ce64afcb   Yarik   Image fixes
85
                        <div class="ribbon-background"></div>
e9f8a5ec   Yarik   Detail page
86
                      </div>
ce64afcb   Yarik   Image fixes
87
88
89
                      <!-- /.ribbon -->
                        <?php
                    }
8cd678be   Yarik   Special pages
90
                    if ($model->is('new')) {
ce64afcb   Yarik   Image fixes
91
92
                        ?>
                      <div class="ribbon new">
46c5cef5   Eugeny Galkovskiy   Переводы
93
                        <div class="theribbon">НОВОЕ</div>
ce64afcb   Yarik   Image fixes
94
                        <div class="ribbon-background"></div>
e9f8a5ec   Yarik   Detail page
95
                      </div>
ce64afcb   Yarik   Image fixes
96
97
98
                      <!-- /.ribbon -->
                        <?php
                    }
88fcbfaf   Eugeny Galkovskiy   Модалка "вход", п...
99
100
                    if ($model->is('top')) {
                        ?>
35b13e82   Yarik   Fixes
101
                      <div class="ribbon top">
9f827b4d   Yarik   Merge remote-trac...
102
                        <div class="theribbon">ТОП</div>
35b13e82   Yarik   Fixes
103
104
105
                        <div class="ribbon-background"></div>
                      </div>
                      <!-- /.ribbon -->
88fcbfaf   Eugeny Galkovskiy   Модалка "вход", п...
106
107
                        <?php
                    }
ce64afcb   Yarik   Image fixes
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
                ?>
              
              <div class="row" id="thumbs">
                  <?php
                      if (!empty($images)) {
                          foreach ($images as $image) {
                              echo Html::tag(
                                  'div',
                                  Html::a(
                                      ImageHelper::set($image->getPath())
                                                 ->fillResize(70, 60)
                                                 ->renderImage(
                                                     [
                                                         'class' => 'img-responsive',
                                                         'alt'   => $model->lang->title,
                                                         'title' => $model->lang->title,
                                                     ]
                                                 ),
                                      ImageHelper::set($image->getPath())
                                                 ->fillResize(555, 555)
                                                 ->render(),
                                      [
                                          'class' => 'thumb',
                                      ]
                                  ),
                                  [
                                      'class' => 'col-xs-2',
                                  ]
                              );
                          }
                      } else {
                          echo Html::tag(
                              'div',
                              Html::a(
                                  ImageHelper::set('@frontend/web/img/no-image.png')
                                             ->fillResize(70, 60)
                                             ->renderImage(
                                                 [
                                                     'class' => 'img-responsive',
                                                     'alt'   => $model->lang->title,
                                                     'title' => $model->lang->title,
                                                 ]
                                             ),
                                  ImageHelper::set('@frontend/web/img/no-image.png')
                                             ->fillResize(555, 555)
                                             ->render(),
                                  [
                                      'class' => 'thumb',
                                  ]
                              ),
                              [
                                  'class' => 'col-xs-2',
                              ]
                          );
                      }
                  ?>
              </div>
                <?php
                    if (!empty($model->video)) {
                        ?>
                      <div class="product-video">
                        <div class="h3">
                            <?php echo \Yii::t('app', 'Видеообзор продукта'); ?>
                        </div>
                        <div class="video-box">
                            <?php echo $model->video; ?>
                        </div>
                      </div>
                        <?php
                    }
                ?>
            </div>
            <div class="col-sm-6">
              <div class="box">
                <h1><?php echo $model->lang->title; ?></h1>
                <p class="no-margin"><?php echo $variant->sku; ?></p>
                <p class="price">
                  <span class="price-title">Цена:</span><?php echo $variant->price ? : 0; ?> грн&ensp;
4bf9edb7   Yarik   Order
186
                    <?php
8e13c18c   Yarik   Search
187
                        if ($variant->canBuy()) {
4bf9edb7   Yarik   Order
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
                            echo Html::a(
                                Html::tag(
                                    'i',
                                    '',
                                    [
                                        'class' => 'fa fa-shopping-cart',
                                    ]
                                ) . \Yii::t('app', 'Добавить в корзину'),
                                '#',
                                [
                                    'class'   => 'btn btn-success add-to-basket',
                                    'data-id' => $variant->id,
                                ]
                            );
                        } else {
                            echo Html::a(
                                \Yii::t('app', 'Нет в наличии'),
                                '#',
                                [
                                    'class'   => 'btn btn-info disabled',
                                    'data-id' => $variant->id,
                                ]
                            );
                        }
                    ?>
                    <?php
ac6e2c67   Alexey Boroda   -Cabinet ready
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
                        if (\Yii::$app->user->isGuest) {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]),
                                [
                                    'title' => 'Добавить в избранное',
                                    'data'  => [
                                        'toggle'    => 'tooltip',
                                        'placement' => 'top',
                                    ],
                                    'class' => 'btn btn-default pull-right disabled',
                                ]
                            );
                        } elseif (in_array($variant->id, \Yii::$app->user->identity->wishlist)) {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart' ]),
                                [
                                    'title' => 'Убрать из избранного',
                                    'data'  => [
                                        'toggle'    => 'tooltip',
                                        'placement' => 'top',
                                        'product'   => $model->id,
                                        'variant'   => $variant->id,
                                        'user'      => \Yii::$app->user->identity->getId(),
                                        'url'       => Url::to([ 'product/wishlist-rm' ]),
                                    ],
                                    'class' => 'wishlist-rm btn btn-success pull-right',
                                ]
                            );
                        } else {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]),
                                [
                                    'title' => 'Добавить в избранное',
                                    'data'  => [
                                        'toggle'    => 'tooltip',
                                        'placement' => 'top',
                                        'product'   => $model->id,
                                        'variant'   => $variant->id,
                                        'user'      => \Yii::$app->user->identity->getId(),
                                        'url'       => Url::to([ 'product/wishlist-add' ]),
                                    ],
                                    'class' => 'wishlist-add btn btn-success pull-right',
                                ]
                            );
                        }
4bf9edb7   Yarik   Order
259
                    ?>
ce64afcb   Yarik   Image fixes
260
261
                </p>
                <hr>
4bf9edb7   Yarik   Order
262
                  <?php
8e13c18c   Yarik   Search
263
264
265
266
267
268
269
270
271
                      if ($variant->canBuy()) {
                          echo Html::a(
                              Html::icon(
                                  'phone',
                                  [
                                      'prefix' => 'fa fa-',
                                  ]
                              ) . \Yii::t('app', 'Купить в один клик'),
                              '#',
6c8e3423   Yarik   Fast buy
272
                              [
8e13c18c   Yarik   Search
273
274
275
276
277
                                  'data'  => [
                                      'toggle' => 'modal',
                                      'target' => '#oneclick-modal',
                                  ],
                                  'class' => 'btn btn-template-main',
6c8e3423   Yarik   Fast buy
278
                              ]
8e13c18c   Yarik   Search
279
280
                          );
                      }
6c8e3423   Yarik   Fast buy
281
                  ?>
582ee9ba   Eugeny Galkovskiy   мелкие правки вёр...
282
283
                  <button type="submit" class="btn btn-template-main"><i class="fa fa-tags"></i> Купить в кредит</button>
                  <button type="submit" class="btn btn-template-main"><i class="fa fa-tags"></i> Купить в рассрочку</button>
ce64afcb   Yarik   Image fixes
284
285
286
287
288
289
290
291
              </div>
              <div class="box" id="details">
                <h2><?php echo \Yii::t('app', 'Описание товара'); ?></h2>
                  <?php echo $model->lang->description ? : \Yii::t('app', 'Нет описания'); ?>
              </div>
              
              <div class="box" id="details">
                <h2><?php echo \Yii::t('app', 'Характеристики'); ?></h2>
9a840185   Yarik   Language Link
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
                  <?php
                      if (!empty($groups)) {
                          ?>
                        <table class="table">
                          <tbody>
                              <?php
                                  foreach ($groups as $group) {
                                      foreach ($group as $optionGroup) {
                                          /**
                                           * @var OptionGroup $optionGroup
                                           */
                                          echo Html::tag(
                                              'tr',
                                              Html::tag(
                                                  'td',
                                                  $optionGroup->lang->title,
                                                  [ 'class' => 'td-title' ]
                                              ) . Html::tag(
                                                  'td',
                                                  implode(
                                                      ', ',
                                                      ArrayHelper::getColumn(
                                                          $optionGroup->currentOptions,
                                                          'lang.value'
                                                      )
                                                  )
ce64afcb   Yarik   Image fixes
318
                                              )
9a840185   Yarik   Language Link
319
320
321
322
323
324
325
326
327
328
329
                                          );
                                      }
                                  }
                              ?>
                          </tbody>
                        </table>
                          <?php
                      } else {
                          echo \Yii::t('app', 'Нет характеристик');
                      }
                  ?>
ce64afcb   Yarik   Image fixes
330
331
332
333
334
335
336
337
338
339
              </div>
            </div>
          
          </div>
            
            <?php
                if (!empty($similar)) {
                    ?>
                  <div class="heading text-center">
                    <h2><?php echo \Yii::t('app', 'Похожие товары'); ?></h2>
e9f8a5ec   Yarik   Detail page
340
341
                  </div>
                  
ce64afcb   Yarik   Image fixes
342
343
344
345
346
347
348
                  <div class="product-carousel">
                    <div class="homepage owl-carousel">
                        <?php
                            $newItemsArrays = array_chunk($similar, 4);
                            foreach ($newItemsArrays as $newItemsArray) {
                                ?>
                              <div class="products">
e9f8a5ec   Yarik   Detail page
349
                                  <?php
ce64afcb   Yarik   Image fixes
350
351
352
353
354
355
356
                                      foreach ($newItemsArray as $product) {
                                          echo $this->render(
                                              '@frontend/views/site/_slider_product',
                                              [
                                                  'product' => $product,
                                              ]
                                          );
e9f8a5ec   Yarik   Detail page
357
358
359
                                      }
                                  ?>
                              </div>
ce64afcb   Yarik   Image fixes
360
361
362
363
364
365
366
367
368
369
                                <?php
                            }
                        ?>
                    </div>
                  </div>
                    <?php
                }
            ?>
        </div>
        <!-- /.col-md-9 -->
e9f8a5ec   Yarik   Detail page
370
      </div>
ce64afcb   Yarik   Image fixes
371
372
373
      <!-- /.row -->
    </div>
    <!-- /.container -->
e9f8a5ec   Yarik   Detail page
374
375
  </div>
  <!-- /#content -->
6c8e3423   Yarik   Fast buy
376
377
378
379
380
381
382
383
384
385
386
387
388
389
  <div class="modal fade" id="oneclick-modal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm">
      
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title callback"><?php echo \Yii::t('app', 'Купить в один клик'); ?></h4>
        </div>
        <div class="modal-body">
            <?php
                $order = new Order(
                    [
                        'scenario'  => Order::SCENARIO_FAST,
                        'variantId' => $variant->id,
35b13e82   Yarik   Fixes
390
                        'returnUrl' => \Yii::$app->request->absoluteUrl,
6c8e3423   Yarik   Fast buy
391
392
393
394
395
396
397
398
399
400
401
                    ]
                );
                $form = ActiveForm::begin(
                    [
                        'action' => [ 'checkout/fast' ],
                        'id'     => 'fast-buy-form',
                    ]
                );
                echo $form->field($order, 'variantId')
                          ->label(false)
                          ->hiddenInput();
35b13e82   Yarik   Fixes
402
403
404
                echo $form->field($order, 'returnUrl')
                          ->label(false)
                          ->hiddenInput();
6c8e3423   Yarik   Fast buy
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
                echo $form->field($order, 'name')
                          ->label(false)
                          ->textInput(
                              [
                                  'placeholder' => $order->getAttributeLabel('name'),
                              ]
                          );
                echo $form->field($order, 'phone')
                          ->label(false)
                          ->textInput(
                              [
                                  'placeholder' => $order->getAttributeLabel('phone'),
                              ]
                          );
                echo Html::tag(
                    'p',
                    Html::submitButton(
                        Html::icon(
                            'shopping-cart',
                            [
                                'prefix' => 'fa fa-',
                            ]
                        ) . \Yii::t('app', ' Отправить'),
                        [
                            'class' => 'btn btn-template-main',
                        ]
                    ),
                    [
                        'class' => 'text-center',
                    ]
                );
                $form::end();
            ?>
        </div>
      </div>
    </div>
  </div>