Skip to content

Commit f7f4436

Browse files
committed
LYNX-358: Added shopping_cart_display_tax_gift_wrapping and cart_summary_display_total to GraphQl
1 parent a50e724 commit f7f4436

File tree

7 files changed

+114
-3
lines changed

7 files changed

+114
-3
lines changed

app/code/Magento/QuoteGraphQl/etc/graphql/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
<item name="is_guest_checkout_enabled" xsi:type="string">checkout/options/guest_checkout</item>
6767
<item name="is_one_page_checkout_enabled" xsi:type="string">checkout/options/onepage_checkout_enabled</item>
6868
<item name="max_items_in_order_summary" xsi:type="string">checkout/options/max_items_display_count</item>
69+
<item name="cart_summary_display_quantity" xsi:type="string">checkout/cart_link/use_qty</item>
70+
<item name="minicart_display" xsi:type="string">checkout/sidebar/display</item>
71+
<item name="minicart_max_items" xsi:type="string">checkout/sidebar/max_items_display_count</item>
72+
<item name="cart_expires_in_days" xsi:type="string">checkout/cart/delete_quote_after</item>
6973
</argument>
7074
</arguments>
7175
</type>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ type StoreConfig {
511511
is_guest_checkout_enabled: Boolean @doc(description: "Extended Config Data - checkout/options/guest_checkout")
512512
is_one_page_checkout_enabled: Boolean @doc(description: "Extended Config Data - checkout/options/onepage_checkout_enabled")
513513
max_items_in_order_summary: Int @doc(description: "Extended Config Data - checkout/options/max_items_display_count")
514+
cart_summary_display_quantity: Int @doc(description: "Extended Config Data - checkout/cart_link/use_qty")
515+
minicart_display: Boolean @doc(description: "Extended Config Data - checkout/sidebar/display")
516+
minicart_max_items: Int @doc(description: "Extended Config Data - checkout/sidebar/count")
517+
cart_expires_in_days: Int @doc(description: "Extended Config Data - checkout/cart/delete_quote_after")
514518
}
515519

516520
input EstimateTotalsInput {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\TaxGraphQl\Model\Resolver;
18+
19+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
20+
use Magento\Framework\GraphQl\Config\Element\Field;
21+
use Magento\Framework\GraphQl\Query\EnumLookup;
22+
use Magento\Framework\GraphQl\Query\ResolverInterface;
23+
24+
/**
25+
* @inheritdoc
26+
*/
27+
class DisplayGiftWrapping implements ResolverInterface
28+
{
29+
/**
30+
* @param EnumLookup $enumLookup
31+
*/
32+
public function __construct(private readonly EnumLookup $enumLookup) {
33+
}
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
public function resolve(
39+
Field $field,
40+
$context,
41+
ResolveInfo $info,
42+
array $value = null,
43+
array $args = null
44+
) {
45+
if (isset($value['shopping_cart_display_tax_gift_wrapping'])) {
46+
return $this->enumLookup->getEnumValueFromField(
47+
'TaxGiftWrappingEnum',
48+
$value['shopping_cart_display_tax_gift_wrapping']
49+
);
50+
}
51+
return null;
52+
}
53+
}

app/code/Magento/TaxGraphQl/etc/graphql/di.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* ************************************************************************
1717
*/
1818
-->
19-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
2021
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
2122
<arguments>
2223
<argument name="extendedConfigData" xsi:type="array">
@@ -26,7 +27,21 @@
2627
<item name="shopping_cart_display_grand_total" xsi:type="string">tax/cart_display/grandtotal</item>
2728
<item name="shopping_cart_display_full_summary" xsi:type="string">tax/cart_display/full_summary</item>
2829
<item name="shopping_cart_display_zero_tax" xsi:type="string">tax/cart_display/zero_tax</item>
30+
<item name="shopping_cart_display_tax_gift_wrapping" xsi:type="string">tax/cart_display/gift_wrapping</item>
31+
</argument>
32+
</arguments>
33+
</type>
34+
<type name="Magento\Framework\GraphQl\Schema\Type\Enum\DefaultDataMapper">
35+
<arguments>
36+
<argument name="map" xsi:type="array">
37+
<item name="TaxGiftWrappingEnum" xsi:type="array">
38+
<item name="display_excluding_tax" xsi:type="string">1</item>
39+
<item name="display_including_tax" xsi:type="string">2</item>
40+
<item name="display_type_both" xsi:type="string">3</item>
41+
</item>
2942
</argument>
3043
</arguments>
3144
</type>
3245
</config>
46+
47+

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ type StoreConfig {
1212
shopping_cart_display_grand_total: Boolean @doc(description: "Extended Config Data - tax/cart_display/grandtotal")
1313
shopping_cart_display_full_summary: Boolean @doc(description: "Extended Config Data - tax/cart_display/full_summary")
1414
shopping_cart_display_zero_tax: Boolean @doc(description: "Extended Config Data - tax/cart_display/zero_tax")
15+
shopping_cart_display_tax_gift_wrapping: TaxGiftWrappingEnum @doc(description: "Extended Config Data - tax/cart_display/gift_wrapping") @resolver(class: "Magento\\TaxGraphQl\\Model\\Resolver\\DisplayGiftWrapping")
16+
}
17+
18+
enum TaxGiftWrappingEnum {
19+
DISPLAY_EXCLUDING_TAX
20+
DISPLAY_INCLUDING_TAX
21+
DISPLAY_TYPE_BOTH
1522
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/StoreConfigResolverTest.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,28 @@
1818
class StoreConfigResolverTest extends GraphQlAbstract
1919
{
2020
private const MAX_ITEMS_TO_DISPLAY = 5;
21+
private const CART_SUMMARY_DISPLAY_TOTAL = 1;
22+
private const MINICART_MAX_ITEMS = 10;
23+
private const CART_EXPIRES_IN_DAYS = 5;
2124

2225
#[
2326
ConfigFixture(Data::XML_PATH_GUEST_CHECKOUT, true, ScopeInterface::SCOPE_STORE, 'default'),
2427
ConfigFixture('checkout/options/onepage_checkout_enabled', true, ScopeInterface::SCOPE_STORE, 'default'),
25-
ConfigFixture('checkout/options/max_items_display_count', self::MAX_ITEMS_TO_DISPLAY)
28+
ConfigFixture('checkout/options/max_items_display_count', self::MAX_ITEMS_TO_DISPLAY),
29+
ConfigFixture('checkout/cart_link/use_qty', 1, ScopeInterface::SCOPE_STORE, 'default'),
30+
ConfigFixture('checkout/sidebar/display', true, ScopeInterface::SCOPE_STORE, 'default'),
31+
ConfigFixture(
32+
'checkout/sidebar/max_items_display_count',
33+
self::MINICART_MAX_ITEMS,
34+
ScopeInterface::SCOPE_STORE,
35+
'default'
36+
),
37+
ConfigFixture(
38+
'checkout/cart/delete_quote_after',
39+
self::CART_EXPIRES_IN_DAYS,
40+
ScopeInterface::SCOPE_STORE,
41+
'default'
42+
),
2643
]
2744
public function testGetStoreConfig(): void
2845
{
@@ -32,7 +49,11 @@ public function testGetStoreConfig(): void
3249
storeConfig {
3350
is_guest_checkout_enabled,
3451
is_one_page_checkout_enabled,
35-
max_items_in_order_summary
52+
max_items_in_order_summary,
53+
cart_summary_display_quantity,
54+
minicart_display,
55+
minicart_max_items,
56+
cart_expires_in_days
3657
}
3758
}
3859
QUERY;
@@ -52,5 +73,9 @@ private function validateStoreConfig(
5273
$this->assertTrue($responseConfig['is_guest_checkout_enabled']);
5374
$this->assertTrue($responseConfig['is_one_page_checkout_enabled']);
5475
$this->assertEquals(self::MAX_ITEMS_TO_DISPLAY, $responseConfig['max_items_in_order_summary']);
76+
$this->assertEquals(self::CART_SUMMARY_DISPLAY_TOTAL, $responseConfig['cart_summary_display_quantity']);
77+
$this->assertTrue($responseConfig['minicart_display']);
78+
$this->assertEquals(self::MINICART_MAX_ITEMS, $responseConfig['minicart_max_items']);
79+
$this->assertEquals(self::CART_EXPIRES_IN_DAYS, $responseConfig['cart_expires_in_days']);
5580
}
5681
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Tax/StoreConfigResolverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class StoreConfigResolverTest extends GraphQlAbstract
2525
ConfigFixture(Config::XML_PATH_DISPLAY_CART_GRANDTOTAL, 1, ScopeInterface::SCOPE_STORE, 'default'),
2626
ConfigFixture(Config::XML_PATH_DISPLAY_CART_FULL_SUMMARY, 1, ScopeInterface::SCOPE_STORE, 'default'),
2727
ConfigFixture(Config::XML_PATH_DISPLAY_CART_ZERO_TAX, 1, ScopeInterface::SCOPE_STORE, 'default'),
28+
ConfigFixture('tax/cart_display/gift_wrapping', 3, ScopeInterface::SCOPE_STORE, 'default'),
2829
]
2930
public function testGetStoreConfig(): void
3031
{
@@ -38,6 +39,7 @@ public function testGetStoreConfig(): void
3839
shopping_cart_display_grand_total,
3940
shopping_cart_display_full_summary,
4041
shopping_cart_display_zero_tax,
42+
shopping_cart_display_tax_gift_wrapping,
4143
}
4244
}
4345
QUERY;
@@ -60,5 +62,6 @@ private function validateStoreConfig(
6062
$this->assertEquals(1, $responseConfig['shopping_cart_display_grand_total']);
6163
$this->assertEquals(1, $responseConfig['shopping_cart_display_full_summary']);
6264
$this->assertEquals(1, $responseConfig['shopping_cart_display_zero_tax']);
65+
$this->assertEquals('DISPLAY_TYPE_BOTH', $responseConfig['shopping_cart_display_tax_gift_wrapping']);
6366
}
6467
}

0 commit comments

Comments
 (0)