Skip to content

Commit ec175b1

Browse files
authored
LYNX-451: Deliver Order Grand_Total Without Tax in CartPrices
1 parent 4e53b87 commit ec175b1

File tree

3 files changed

+476
-9
lines changed

3 files changed

+476
-9
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,25 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
6565
$cartTotals = $this->totalsCollector->collectQuoteTotals($quote);
6666
$currency = $quote->getQuoteCurrencyCode();
6767

68+
$appliedTaxes = $this->getAppliedTaxes($cartTotals, $currency);
69+
$grandTotal = $cartTotals->getGrandTotal();
70+
71+
$totalAppliedTaxes = 0;
72+
foreach ($appliedTaxes as $appliedTax) {
73+
$totalAppliedTaxes += $appliedTax['amount']['value'];
74+
}
75+
$grandTotalExclTax = $grandTotal - $totalAppliedTaxes;
76+
6877
return [
69-
'grand_total' => ['value' => $cartTotals->getGrandTotal(), 'currency' => $currency],
78+
'grand_total' => ['value' => $grandTotal, 'currency' => $currency],
79+
'grand_total_excluding_tax' => ['value' => $grandTotalExclTax, 'currency' => $currency],
7080
'subtotal_including_tax' => ['value' => $cartTotals->getSubtotalInclTax(), 'currency' => $currency],
7181
'subtotal_excluding_tax' => ['value' => $cartTotals->getSubtotal(), 'currency' => $currency],
7282
'subtotal_with_discount_excluding_tax' => [
7383
'value' => $this->getSubtotalWithDiscountExcludingTax($cartTotals),
7484
'currency' => $currency
7585
],
76-
'applied_taxes' => $this->getAppliedTaxes($cartTotals, $currency),
86+
'applied_taxes' => $appliedTaxes,
7787
'discount' => $this->getDiscount($cartTotals, $currency),
7888
'model' => $quote
7989
];

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,18 @@ input SetGuestEmailOnCartInput @doc(description: "Defines the guest email and ca
214214
email: String! @doc(description: "The email address of the guest.")
215215
}
216216

217-
type CartPrices @doc(description: "Contains details about the final price of items in the cart, including discount and tax information.") {
218-
grand_total: Money @doc(description: "The total, including discounts, taxes, shipping, and other fees.")
219-
subtotal_including_tax: Money @doc(description: "The subtotal including any applied taxes.")
220-
subtotal_excluding_tax: Money @doc(description: "The subtotal without any applied taxes.")
217+
type CartPrices @doc(description: "Contains details about the final price of items in the cart, including discount and tax information.") {
218+
grand_total: Money @doc(description: "The total, including discounts, taxes, shipping, and other fees.")
219+
grand_total_excluding_tax: Money @doc(description: "The total of the cart, including discounts, shipping, and other fees without tax.")
220+
subtotal_including_tax: Money @doc(description: "The subtotal including any applied taxes.")
221+
subtotal_excluding_tax: Money @doc(description: "The subtotal without any applied taxes.")
221222
discount: CartDiscount @deprecated(reason: "Use discounts instead.")
222-
subtotal_with_discount_excluding_tax: Money @doc(description: "The subtotal with any discounts applied, but not taxes.")
223-
applied_taxes: [CartTaxItem] @doc(description: "An array containing the names and amounts of taxes applied to each item in the cart.")
223+
subtotal_with_discount_excluding_tax: Money @doc(description: "The subtotal with any discounts applied, but not taxes.")
224+
applied_taxes: [CartTaxItem] @doc(description: "An array containing the names and amounts of taxes applied to each item in the cart.")
224225
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")
225226
}
226227

227-
type CartTaxItem @doc(description: "Contains tax information about an item in the cart.") {
228+
type CartTaxItem @doc(description: "Contains tax information about an item in the cart.") {
228229
amount: Money! @doc(description: "The amount of tax applied to the item.")
229230
label: String! @doc(description: "The description of the tax.")
230231
}

0 commit comments

Comments
 (0)