view.php
22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
186
187
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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
<?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;
use frontend\models\Order;
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Html;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\web\View;
use yii\jui\JuiAsset;
/**
* @var View $this
* @var Product $model
* @var Variant $variant
* @var SeoComponent $seo
* @var array $groups
* @var Product[] $similar
*/
$seo = \Yii::$app->get('seo');
if (!empty($model->category)) {
// if (!empty($model->category->parent)) {
// $this->params[ 'breadcrumbs' ][] = [
// 'label' => $model->category->parent->lang->title,
// 'url' => [
// '/category/view',
// 'category' => $model->category->parent->lang->alias->value,
// ],
// ];
// }
$this->params[ 'breadcrumbs' ][] = [
'label' => $model->category->lang->title,
'url' => [
'/category/view',
'category' => $model->category->lang->alias->value,
],
];
}
$this->params[ 'breadcrumbs' ][] = $seo->title;
$images = $model->images;
if (empty($model->images))
{
$images = [];
}
if (!empty($model->image)) {
array_unshift($images, $model->image);
}
$js = <<< JS
$(document).ready(function() {
$("#t_buy_credit").on("click", function(e) {
console.log("credit");
$('.Oziris_dialog').attr('ProductCode','KS-POTREB');
Oziris_open();
return false;
});
$("#t_buy_installment").on("click", function(e) {
console.log("installment");
$('.Oziris_dialog').attr('ProductCode','ECREDIT');
Oziris_open();
return false;
});
})
JS;
$this->registerJs($js, View::POS_READY);
?>
<!--<script>(function(d, s, id) {-->
<!-- var js, fjs = d.getElementsByTagName(s)[ 0 ];-->
<!-- if (d.getElementById(id)) {-->
<!-- return;-->
<!-- }-->
<!-- js = d.createElement(s);-->
<!-- js.id = id;-->
<!-- js.src = "//xkasa.com.ua/Scripts/Oziris-0.5.1.a.promo.js";-->
<!-- fjs.parentNode.insertBefore(js, fjs);-->
<!-- }(document, 'script', 'xkasa-jssdk'));-->
<!--</script>-->
<div id="content">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row" id="productMain">
<div class="col-xs-12 col-sm-3 col-md-4">
<div id="mainImage" class="image-zoom">
<?php
if (!empty($images)) {
echo ImageHelper::set($images[ 0 ]->getPath())
->fillResize(555, 555)
->quality(85)
->renderImage(
[
'class' => 'img-responsive',
'alt' => $model->lang->title,
'title' => $model->lang->title,
]
);
} else {
echo ImageHelper::set('@frontend/web/img/no-image.png')
->fillResize(555, 555)
->quality(85)
->renderImage(
[
'class' => 'img-responsive',
'alt' => $model->lang->title,
'title' => $model->lang->title,
]
);
}
?>
</div>
<?php
if($model->is('new') || $model->is('akcia') || $model->is('top')){
?>
<div class="status_wrapp">
<?php
if ($model->is('akcia')) {
?>
<div class="ribbon sale">
<div class="theribbon">АКЦІЯ</div>
<div class="ribbon-background"></div>
</div>
<!-- /.ribbon -->
<?php
}
if ($model->is('new')) {
?>
<div class="ribbon new">
<div class="theribbon">НОВЕ</div>
<div class="ribbon-background"></div>
</div>
<!-- /.ribbon -->
<?php
}
if ($model->is('top')) {
?>
<div class="ribbon top">
<div class="theribbon">ТОП</div>
<div class="ribbon-background"></div>
</div>
<!-- /.ribbon -->
<?php
}
?>
</div>
<?php } ?>
<?php if(count($images) > 1) { ?>
<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)
->quality(85)
->renderImage(
[
'class' => 'img-responsive',
'alt' => $model->lang->title,
'title' => $model->lang->title,
]
),
ImageHelper::set($image->getPath())
->fillResize(555, 555)
->quality(85)
->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)
->quality(85)
->renderImage(
[
'class' => 'img-responsive',
'alt' => $model->lang->title,
'title' => $model->lang->title,
]
),
ImageHelper::set('@frontend/web/img/no-image.png')
->fillResize(555, 555)
->quality(85)
->render(),
[
'class' => 'thumb',
]
),
[
'class' => 'col-xs-2',
]
);
}
?>
</div>
<?php } ?>
<?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-xs-12 col-sm-9 col-md-8">
<div class="box">
<h1><?php echo $model->lang->title; ?></h1>
<p class="no-margin"><?php echo $variant->sku; ?><span class="product-id">Код: <?= $model->id ?></span>
</p>
<p class="price">
<span class="price-title">Ціна:</span><?php echo $variant->price ? : 0; ?> грн 
<?php
if ($variant->canBuy()) {
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
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',
]
);
}
?>
</p>
<div class="line-card"></div>
<div class="row">
<?php
if ($variant->canBuy()) {
echo '<div class="col-xs-12 col-sm-4 card-buttons-wr">';
echo Html::a(
Html::icon(
'phone',
[
'prefix' => 'fa fa-',
]
) . \Yii::t('app', 'Купити в один клік'),
'#',
[
'data' => [
'toggle' => 'modal',
'target' => '#oneclick-modal',
],
'class' => 'btn btn-template-main',
]
);
echo '</div>';
echo '<div class="col-xs-12 col-sm-4 card-buttons-wr">';
echo Html::button(
Html::icon(
'tags',
[
'prefix' => 'fa fa-',
]
) . \Yii::t('app', 'Купити в кредит'),
[
'class' => 'btn btn-template-main',
'id' => 't_buy_credit',
]
);
echo '</div>';
echo '<div class="col-xs-12 col-sm-4 card-buttons-wr">';
echo Html::button(
Html::icon(
'tags',
[
'prefix' => 'fa fa-',
]
) . \Yii::t('app', 'Купити у розстрочку'),
[
'class' => 'btn btn-template-main',
'id' => 't_buy_installment',
]
);
echo '</div>';
}
?>
</div>
</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>
<?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'
)
)
)
);
}
}
?>
</tbody>
</table>
<?php
} else {
echo \Yii::t('app', 'Немає характеристик');
}
?>
</div>
</div>
</div>
<?php
if (!empty($similar)) {
?>
<div class="heading text-center">
<h2><?php echo \Yii::t('app', 'Схожі товари'); ?></h2>
</div>
<div class="product-carousel">
<div class="homepage owl-carousel">
<?php
$newItemsArrays = array_chunk($similar, 4);
foreach ($newItemsArrays as $newItemsArray) {
?>
<div class="products sliders_">
<?php
foreach ($newItemsArray as $product) {
echo $this->render(
'@frontend/views/site/_slider_product',
[
'product' => $product,
]
);
}
?>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
<!-- /.col-md-9 -->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</div>
<!-- /#content -->
<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">×</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,
'returnUrl' => \Yii::$app->request->absoluteUrl,
]
);
$form = ActiveForm::begin(
[
'action' => [ 'checkout/fast' ],
'id' => 'fast-buy-form',
]
);
echo $form->field($order, 'variantId')
->label(false)
->hiddenInput();
echo $form->field($order, 'returnUrl')
->label(false)
->hiddenInput();
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>
<div
class="Oziris_dialog"
ProductCode="KS-POTREB"
Line0Code="<?php echo $variant->sku; ?>"
Line0Title="<?php echo urlencode($model->lang->title); ?>"
Line0Price=<?php echo $variant->price ? : 0; ?>
></div>