Skip to content

Commit 29bacd0

Browse files
committed
ACP2E-910: display all price promotions, discounts, adjusments
1 parent cd826aa commit 29bacd0

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ private function getDiscountValues(Quote $quote)
4141
{
4242
$discountValues=[];
4343
$address = $quote->getShippingAddress();
44-
$totalDiscounts = $address->getExtensionAttributes()->getDiscounts();
45-
if ($totalDiscounts && is_array($totalDiscounts)) {
46-
foreach ($totalDiscounts as $value) {
47-
$discount = [];
48-
$amount = [];
49-
$discount['label'] = $value->getRuleLabel() ?: __('Discount');
50-
/* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discountData */
51-
$discountData = $value->getDiscountData();
52-
$amount['value'] = $discountData->getAmount();
53-
$amount['currency'] = $quote->getQuoteCurrencyCode();
54-
$discount['amount'] = $amount;
55-
$discountValues[] = $discount;
44+
$totals = $address->getTotals();
45+
if ($totals && is_array($totals)){
46+
foreach ($totals as $total) {
47+
if (stripos($total->getCode(), 'total') === false && $total->getValue() < 0.00) {
48+
$discount = [];
49+
$amount = [];
50+
$discount['label'] = $total->getTitle() ?: __('Discount');
51+
$amount['value'] = $total->getValue();
52+
$amount['currency'] = $quote->getQuoteCurrencyCode();
53+
$discount['amount'] = $amount;
54+
$discountValues[] = $discount;
55+
}
5656
}
5757
return $discountValues;
5858
}

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ type CartPrices @doc(description: "Contains details about the final price of it
167167
discount: CartDiscount @deprecated(reason: "Use discounts instead.")
168168
subtotal_with_discount_excluding_tax: Money @doc(description: "The subtotal with any discounts applied, but not taxes.")
169169
applied_taxes: [CartTaxItem] @doc(description: "An array containing the names and amounts of taxes applied to each item in the cart.")
170-
discounts: [Discount] @doc(description:"An array containing all discounts applied to the cart.") @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Discounts")
170+
discounts: [Discount] @doc(description:"An array containing cart rule discounts, store credit and gift cards applied to the cart.") @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Discounts")
171171
}
172172

173173
type CartTaxItem @doc(description: "Contains tax information about an item in the cart.") {

0 commit comments

Comments
 (0)