File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Sales \Block \Adminhtml \Order \Create \Sidebar ;
7
9
10
+ use Magento \Catalog \Model \Product ;
11
+ use Magento \Catalog \Pricing \Price \FinalPrice ;
12
+
8
13
/**
9
14
* Adminhtml sales order create sidebar cart block
10
15
*
@@ -58,6 +63,17 @@ public function getItemCollection()
58
63
return $ collection ;
59
64
}
60
65
66
+ /**
67
+ * @inheritdoc
68
+ */
69
+ public function getItemPrice (Product $ product )
70
+ {
71
+ $ customPrice = $ this ->getCartItemCustomPrice ($ product );
72
+ $ price = $ customPrice ?? $ product ->getPriceInfo ()->getPrice (FinalPrice::PRICE_CODE )->getValue ();
73
+
74
+ return $ this ->convertPrice ($ price );
75
+ }
76
+
61
77
/**
62
78
* Retrieve display item qty availability
63
79
*
@@ -111,4 +127,23 @@ protected function _prepareLayout()
111
127
112
128
return parent ::_prepareLayout ();
113
129
}
130
+
131
+ /**
132
+ * Returns cart item custom price.
133
+ *
134
+ * @param Product $product
135
+ * @return float|null
136
+ */
137
+ private function getCartItemCustomPrice (Product $ product ): ?float
138
+ {
139
+ $ items = $ this ->getItemCollection ();
140
+ foreach ($ items as $ item ) {
141
+ $ productItemId = $ this ->getProduct ($ item )->getId ();
142
+ if ($ productItemId === $ product ->getId () && $ item ->getCustomPrice ()) {
143
+ return (float )$ item ->getCustomPrice ();
144
+ }
145
+ }
146
+
147
+ return null ;
148
+ }
114
149
}
You can’t perform that action at this time.
0 commit comments