Skip to content

Commit 6aae805

Browse files
author
Mariana Lashch
committed
Merge branch 'MAGETWO-97314' into port-1001
2 parents d7ac52b + 682312b commit 6aae805

File tree

1 file changed

+35
-0
lines changed
  • app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar

1 file changed

+35
-0
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
79

10+
use Magento\Catalog\Model\Product;
11+
use Magento\Catalog\Pricing\Price\FinalPrice;
12+
813
/**
914
* Adminhtml sales order create sidebar cart block
1015
*
@@ -58,6 +63,17 @@ public function getItemCollection()
5863
return $collection;
5964
}
6065

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+
6177
/**
6278
* Retrieve display item qty availability
6379
*
@@ -111,4 +127,23 @@ protected function _prepareLayout()
111127

112128
return parent::_prepareLayout();
113129
}
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+
}
114149
}

0 commit comments

Comments
 (0)