3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
- // phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
6
+ // phpcs:disable Magento2.Templates.ThisInTemplate
7
7
/** @var $block \Magento\Bundle\Block\Sales\Order\Items\Renderer */
8
+ /** @var $viewModel \Magento\Bundle\ViewModel\Sales\Order\Items\Renderer */
8
9
$ parentItem = $ block ->getItem ();
9
- $ items = array_merge ([$ parentItem ], $ parentItem ->getChildrenItems ());
10
+ $ viewModel = $ block ->getViewModel ();
11
+ $ items = $ viewModel ->getOrderItems ((int )$ parentItem ->getOrderId (), (int )$ parentItem ->getId ());
10
12
$ index = 0 ;
11
13
$ prevOptionId = '' ;
12
14
?>
13
15
14
- <?php foreach ($ items as $ item ) : ?>
16
+ <?php foreach ($ items as $ item ): ?>
15
17
16
18
<?php if ($ block ->getItemOptions ()
17
19
|| $ parentItem ->getDescription ()
18
20
|| $ this ->helper (Magento \GiftMessage \Helper \Message::class)->isMessagesAllowed ('order_item ' , $ parentItem )
19
- && $ parentItem ->getGiftMessageId ()) : ?>
21
+ && $ parentItem ->getGiftMessageId ()): ?>
20
22
<?php $ showLastRow = true ; ?>
21
- <?php else : ?>
23
+ <?php else : ?>
22
24
<?php $ showLastRow = false ; ?>
23
25
<?php endif ; ?>
24
26
25
- <?php if ($ item ->getParentItem ()) : ?>
27
+ <?php if ($ item ->getParentItem ()): ?>
26
28
<?php $ attributes = $ block ->getSelectionAttributes ($ item ) ?>
27
- <?php if ($ prevOptionId != $ attributes ['option_id ' ]) : ?>
29
+
30
+ <?php if (isset ($ attributes ['option_id ' ]) && $ prevOptionId != $ attributes ['option_id ' ]): ?>
28
31
<tr class="options-label">
29
32
<td class="col label" colspan="5"><?= $ block ->escapeHtml ($ attributes ['option_label ' ]); ?> </td>
30
33
</tr>
31
34
<?php $ prevOptionId = $ attributes ['option_id ' ] ?>
32
35
<?php endif ; ?>
33
36
<?php endif ; ?>
34
37
<tr id="order-item-row-<?= /* @noEscape */ $ item ->getId () ?> "
35
- class="<?php if ($ item ->getParentItem ()) : ?>
38
+ class="<?php if ($ item ->getParentItem ()): ?>
36
39
item-options-container
37
- <?php else : ?>
40
+ <?php else : ?>
38
41
item-parent
39
42
<?php endif ; ?> "
40
- <?php if ($ item ->getParentItem ()) : ?>
41
- data-th="<?= $ block ->escapeHtmlAttr ($ attributes ['option_label ' ]); ?> "
43
+ <?php if ($ item ->getParentItem ()): ?>
44
+ data-th="<?= $ block ->escapeHtmlAttr ($ attributes ['option_label ' ] ?? '' ); ?> "
42
45
<?php endif ; ?> >
43
- <?php if (!$ item ->getParentItem ()) : ?>
46
+ <?php if (!$ item ->getParentItem ()): ?>
44
47
<td class="col name" data-th="<?= $ block ->escapeHtmlAttr (__ ('Product Name ' )); ?> ">
45
48
<strong class="product name product-item-name"><?= $ block ->escapeHtml ($ item ->getName ()); ?> </strong>
46
49
</td>
47
- <?php else : ?>
50
+ <?php else : ?>
48
51
<td class="col value" data-th="<?= $ block ->escapeHtmlAttr (__ ('Product Name ' )); ?> ">
49
52
<?= $ block ->getValueHtml ($ item ); ?>
50
53
</td>
@@ -53,82 +56,82 @@ $prevOptionId = '';
53
56
<?= /* @noEscape */ $ block ->prepareSku ($ item ->getSku ()); ?>
54
57
</td>
55
58
<td class="col price" data-th="<?= $ block ->escapeHtmlAttr (__ ('Price ' )); ?> ">
56
- <?php if (!$ item ->getParentItem ()) : ?>
59
+ <?php if (!$ item ->getParentItem ()): ?>
57
60
<?= /* @noEscape */ $ block ->getItemPriceHtml (); ?>
58
- <?php else : ?>
61
+ <?php else : ?>
59
62
60
63
<?php endif ; ?>
61
64
</td>
62
65
<td class="col qty" data-th="<?= $ block ->escapeHtmlAttr (__ ('Quantity ' )); ?> ">
63
66
<?php if (($ item ->getParentItem () && $ block ->isChildCalculated ()) ||
64
67
(!$ item ->getParentItem () && !$ block ->isChildCalculated ()) ||
65
- ($ item ->getQtyShipped () > 0 && $ item ->getParentItem () && $ block ->isShipmentSeparately ())) : ?>
68
+ ($ item ->getQtyShipped () > 0 && $ item ->getParentItem () && $ block ->isShipmentSeparately ())): ?>
66
69
<ul class="items-qty">
67
70
<?php endif ; ?>
68
71
<?php if (($ item ->getParentItem () && $ block ->isChildCalculated ()) ||
69
- (!$ item ->getParentItem () && !$ block ->isChildCalculated ())) : ?>
70
- <?php if ($ item ->getQtyOrdered () > 0 ) : ?>
72
+ (!$ item ->getParentItem () && !$ block ->isChildCalculated ())): ?>
73
+ <?php if ($ item ->getQtyOrdered () > 0 ): ?>
71
74
<li class="item">
72
75
<span class="title"><?= $ block ->escapeHtml (__ ('Ordered ' )); ?> </span>
73
76
<span class="content"><?= /* @noEscape */ $ item ->getQtyOrdered () * 1 ; ?> </span>
74
77
</li>
75
78
<?php endif ; ?>
76
- <?php if ($ item ->getQtyShipped () > 0 && !$ block ->isShipmentSeparately ()) : ?>
79
+ <?php if ($ item ->getQtyShipped () > 0 && !$ block ->isShipmentSeparately ()): ?>
77
80
<li class="item">
78
81
<span class="title"><?= $ block ->escapeHtml (__ ('Shipped ' )); ?> </span>
79
82
<span class="content"><?= /* @noEscape */ $ item ->getQtyShipped () * 1 ; ?> </span>
80
83
</li>
81
84
<?php endif ; ?>
82
- <?php if ($ item ->getQtyCanceled () > 0 ) : ?>
85
+ <?php if ($ item ->getQtyCanceled () > 0 ): ?>
83
86
<li class="item">
84
87
<span class="title"><?= $ block ->escapeHtml (__ ('Canceled ' )); ?> </span>
85
88
<span class="content"><?= /* @noEscape */ $ item ->getQtyCanceled () * 1 ; ?> </span>
86
89
</li>
87
90
<?php endif ; ?>
88
- <?php if ($ item ->getQtyRefunded () > 0 ) : ?>
91
+ <?php if ($ item ->getQtyRefunded () > 0 ): ?>
89
92
<li class="item">
90
93
<span class="title"><?= $ block ->escapeHtml (__ ('Refunded ' )); ?> </span>
91
94
<span class="content"><?= /* @noEscape */ $ item ->getQtyRefunded () * 1 ; ?> </span>
92
95
</li>
93
96
<?php endif ; ?>
94
- <?php elseif ($ item ->getQtyShipped () > 0 && $ item ->getParentItem () && $ block ->isShipmentSeparately ()) : ?>
97
+ <?php elseif ($ item ->getQtyShipped () > 0 && $ item ->getParentItem () && $ block ->isShipmentSeparately ()): ?>
95
98
<li class="item">
96
99
<span class="title"><?= $ block ->escapeHtml (__ ('Shipped ' )); ?> </span>
97
100
<span class="content"><?= /* @noEscape */ $ item ->getQtyShipped () * 1 ; ?> </span>
98
101
</li>
99
- <?php else : ?>
102
+ <?php else : ?>
100
103
<span class="content"><?= /* @noEscape */ $ parentItem ->getQtyOrdered () * 1 ; ?> </span>
101
104
<?php endif ; ?>
102
105
<?php if (($ item ->getParentItem () && $ block ->isChildCalculated ()) ||
103
106
(!$ item ->getParentItem () && !$ block ->isChildCalculated ()) ||
104
- ($ item ->getQtyShipped () > 0 && $ item ->getParentItem () && $ block ->isShipmentSeparately ())) :?>
107
+ ($ item ->getQtyShipped () > 0 && $ item ->getParentItem () && $ block ->isShipmentSeparately ())):?>
105
108
</ul>
106
109
<?php endif ; ?>
107
110
</td>
108
111
<td class="col subtotal" data-th="<?= $ block ->escapeHtmlAttr (__ ('Subtotal ' )) ?> ">
109
- <?php if (!$ item ->getParentItem ()) : ?>
112
+ <?php if (!$ item ->getParentItem ()): ?>
110
113
<?= /* @noEscape */ $ block ->getItemRowTotalHtml (); ?>
111
- <?php else : ?>
114
+ <?php else : ?>
112
115
113
116
<?php endif ; ?>
114
117
</td>
115
118
</tr>
116
119
<?php endforeach ; ?>
117
120
118
- <?php if ($ showLastRow && (($ options = $ block ->getItemOptions ()) || $ block ->escapeHtml ($ item ->getDescription ()))) : ?>
121
+ <?php if ($ showLastRow && (($ options = $ block ->getItemOptions ()) || $ block ->escapeHtml ($ item ->getDescription ()))): ?>
119
122
<tr>
120
123
<td class="col options" colspan="5">
121
- <?php if ($ options = $ block ->getItemOptions ()) : ?>
124
+ <?php if ($ options = $ block ->getItemOptions ()): ?>
122
125
<dl class="item-options">
123
- <?php foreach ($ options as $ option ) : ?>
126
+ <?php foreach ($ options as $ option ): ?>
124
127
<dt><?= $ block ->escapeHtml ($ option ['label ' ]) ?> </dt>
125
- <?php if (!$ block ->getPrintStatus ()) : ?>
128
+ <?php if (!$ block ->getPrintStatus ()): ?>
126
129
<?php $ formattedOptionValue = $ block ->getFormatedOptionValue ($ option ) ?>
127
- <dd<?php if (isset ($ formattedOptionValue ['full_view ' ])) : ?>
130
+ <dd<?php if (isset ($ formattedOptionValue ['full_view ' ])): ?>
128
131
class="tooltip wrapper"
129
132
<?php endif ; ?> >
130
133
<?= /* @noEscape */ $ formattedOptionValue ['value ' ] ?>
131
- <?php if (isset ($ formattedOptionValue ['full_view ' ])) : ?>
134
+ <?php if (isset ($ formattedOptionValue ['full_view ' ])): ?>
132
135
<div class="tooltip content">
133
136
<dl class="item options">
134
137
<dt><?= $ block ->escapeHtml ($ option ['label ' ]); ?> </dt>
@@ -137,7 +140,7 @@ $prevOptionId = '';
137
140
</div>
138
141
<?php endif ; ?>
139
142
</dd>
140
- <?php else : ?>
143
+ <?php else : ?>
141
144
<dd><?= $ block ->escapeHtml ((isset ($ option ['print_value ' ]) ?
142
145
$ option ['print_value ' ] :
143
146
$ option ['value ' ])); ?>
0 commit comments