orderClient.php
3.74 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
<?php
/**
* @var \frontend\models\Order $order
*/
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\DetailView;
$sum = 0;
foreach ($order->orderProducts as $orderProduct) {
$sum += $orderProduct->count * $orderProduct->price;
}
if (!empty($order->delivery)) {
$sum += $order->delivery->value;
}
?>
<h3>
<?php echo \Yii::t(
'app',
'Your order {orderId} successfully created!',
[
'orderId' => $order->id,
]
); ?>
</h3>
<p><?php echo \Yii::t('app', 'Order info:'); ?></p>
<?php
echo DetailView::widget(
[
'model' => $order,
'attributes' => [
'id',
'name',
'phone',
'email',
'city',
'address',
'comment',
[
'attribute' => 'label_id',
'value' => function ($model) {
/**
* @var \frontend\models\Order $model
*/
return $model->label->lang->title;
},
],
[
'attribute' => 'delivery_id',
'value' => function ($model) {
/**
* @var \frontend\models\Order $model
*/
return $model->delivery->lang->title;
},
],
[
'attribute' => 'payment_id',
'value' => function ($model) {
/**
* @var \frontend\models\Order $model
*/
return $model->payment->lang->title;
},
],
[
'attribute' => 'created_at',
'format' => 'datetime',
],
],
]
);
?>
<table>
<tr>
<th><?php echo \Yii::t('app', 'Product'); ?></th>
<th><?php echo \Yii::t('app', 'Article'); ?></th>
<th><?php echo \Yii::t('app', 'Price'); ?></th>
<th><?php echo \Yii::t('app', 'Count'); ?></th>
<th><?php echo \Yii::t('app', 'Sum'); ?></th>
</tr>
<?php
foreach ($order->orderProducts as $orderProduct) {
?>
<tr>
<td>
<?php echo Html::a(
$orderProduct->variant->product->lang->title,
Url::to(
[
'product/view',
'id' => $orderProduct->variant->product->id,
'alias' => $orderProduct->variant->product->lang->alias,
],
true
)
); ?>
</td>
<td>
<?php
echo $orderProduct->sku;
?>
</td>
<td>
<?php
echo $orderProduct->price . ' грн.';
?>
</td>
<td>
<?php
echo $orderProduct->count;
?>
</td>
<td>
<?php
echo ( $orderProduct->price * $orderProduct->count ) . ' грн.';
?>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4"><?php echo \Yii::t('app', 'Delivery'); ?></td>
<td><?php echo $order->delivery->value . ' грн.'; ?></td>
</tr>
<tr>
<td colspan="4"><?php echo \Yii::t('app', 'Sum'); ?></td>
<td><?php echo $sum . ' грн.'; ?></td>
</tr>
</table>