Skip to content

Commit a9dcf13

Browse files
committed
MC-20244: Pricing :: FPT calculation
- add fpt display settings
1 parent 144b9ee commit a9dcf13

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

app/code/Magento/WeeeGraphQl/Model/Resolver/FptResolver.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,39 @@ public function resolve(
5151
if (!isset($value['model'])) {
5252
throw new LocalizedException(__('"model" value should be specified'));
5353
}
54+
5455
$fptArray = [];
5556
$product = $value['model'];
5657

5758
/** @var StoreInterface $store */
5859
$store = $context->getExtensionAttributes()->getStore();
5960

60-
$attributes = $this->weeeHelper->getProductWeeeAttributesForDisplay($product);
61-
foreach ($attributes as $attribute) {
62-
$displayInclTaxes = $this->taxHelper->getPriceDisplayType($store);
63-
$amount = $attribute->getData('amount');
64-
if ($displayInclTaxes === 1) {
65-
$amount = $attribute->getData('amount_excl_tax');
66-
} elseif ($displayInclTaxes === 2) {
67-
$amount = $attribute->getData('amount_excl_tax') + $attribute->getData('tax_amount');
68-
}
69-
$fptArray[] = [
70-
'amount' => [
71-
'value' => $amount,
72-
'currency' => $value['final_price']['currency'],
61+
62+
if (!$this->weeeHelper->isEnabled($store)) {
63+
return $fptArray;
64+
}
65+
66+
67+
if ($this->weeeHelper->isDisplayInclDesc($store) || $this->weeeHelper->isDisplayExclDescIncl($store)) {
68+
$attributes = $this->weeeHelper->getProductWeeeAttributesForDisplay($product);
69+
foreach ($attributes as $attribute) {
70+
$displayInclTaxes = $this->taxHelper->getPriceDisplayType($store);
71+
$amount = $attribute->getData('amount');
72+
//add display mode for WEE to not return WEE if excluded
73+
if ($displayInclTaxes === 1) {
74+
$amount = $attribute->getData('amount_excl_tax');
75+
} elseif ($displayInclTaxes === 2) {
76+
$amount = $attribute->getData('amount_excl_tax') + $attribute->getData('tax_amount');
77+
}
78+
$fptArray[] = [
79+
'amount' => [
80+
'value' => $amount,
81+
'currency' => $value['final_price']['currency'],
7382
],
7483
'label' => $attribute->getData('name')
75-
];
84+
];
85+
}
7686
}
77-
7887
return $fptArray;
7988
}
8089
}

0 commit comments

Comments
 (0)