Skip to content

Commit 2f9e816

Browse files
authored
GraphQL: Incl. Tax for Product Price on Order Item
Fix for issue #36946 (Jira ticket AC-8104): Include Tax for Product Price if `\Magento\Tax\Helper\Data::displaySalesPriceInclTax(...)` returns `true`
1 parent 4a41ec4 commit 2f9e816

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/code/Magento/SalesGraphQl/Model/OrderItem/DataProvider.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Sales\Api\Data\OrderItemInterface;
1515
use Magento\Sales\Api\OrderItemRepositoryInterface;
1616
use Magento\Sales\Api\OrderRepositoryInterface;
17+
use Magento\Tax\Helper\Data as TaxHelper;
1718

1819
/**
1920
* Data provider for order items
@@ -45,6 +46,11 @@ class DataProvider
4546
*/
4647
private $optionsProcessor;
4748

49+
/**
50+
* @var TaxHelper
51+
*/
52+
private $taxHelper;
53+
4854
/**
4955
* @var int[]
5056
*/
@@ -61,19 +67,22 @@ class DataProvider
6167
* @param OrderRepositoryInterface $orderRepository
6268
* @param SearchCriteriaBuilder $searchCriteriaBuilder
6369
* @param OptionsProcessor $optionsProcessor
70+
* @param TaxHelper $taxHelper
6471
*/
6572
public function __construct(
6673
OrderItemRepositoryInterface $orderItemRepository,
6774
ProductRepositoryInterface $productRepository,
6875
OrderRepositoryInterface $orderRepository,
6976
SearchCriteriaBuilder $searchCriteriaBuilder,
70-
OptionsProcessor $optionsProcessor
77+
OptionsProcessor $optionsProcessor,
78+
TaxHelper $taxHelper
7179
) {
7280
$this->orderItemRepository = $orderItemRepository;
7381
$this->productRepository = $productRepository;
7482
$this->orderRepository = $orderRepository;
7583
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
7684
$this->optionsProcessor = $optionsProcessor;
85+
$this->taxHelper = $taxHelper;
7786
}
7887

7988
/**
@@ -140,7 +149,9 @@ private function fetch()
140149
'status' => $orderItem->getStatus(),
141150
'discounts' => $this->getDiscountDetails($associatedOrder, $orderItem),
142151
'product_sale_price' => [
143-
'value' => $orderItem->getPrice(),
152+
'value' => $this->taxHelper->displaySalesPriceInclTax($associatedOrder->getStoreId())
153+
? $orderItem->getPriceInclTax()
154+
: $orderItem->getPrice(),
144155
'currency' => $associatedOrder->getOrderCurrencyCode()
145156
],
146157
'selected_options' => $itemOptions['selected_options'],

0 commit comments

Comments
 (0)