Skip to content

Commit faacfe0

Browse files
committed
GraphQL-37: [Cart Operations] Manage Cart Items
-- Refactoring
1 parent 19cc640 commit faacfe0

File tree

6 files changed

+15
-72
lines changed

6 files changed

+15
-72
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItems.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function __construct(
5050
*/
5151
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
5252
{
53-
if (!isset($args['input']['cart_id'])) {
53+
if (!isset($args['input']['cart_id']) || empty($args['input']['cart_id'])) {
5454
throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
5555
}
5656
$maskedCartId = $args['input']['cart_id'];
5757

58-
if (!isset($args['input']['coupon_code'])) {
58+
if (!isset($args['input']['coupon_code']) || empty($args['input']['coupon_code'])) {
5959
throw new GraphQlInputException(__('Required parameter "coupon_code" is missing'));
6060
}
6161
$couponCode = $args['input']['coupon_code'];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
*/
3838
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
3939
{
40-
if (!isset($args['cart_id'])) {
40+
if (!isset($args['cart_id']) || empty($args['cart_id'])) {
4141
throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
4242
}
4343
$maskedCartId = $args['cart_id'];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(
5050
*/
5151
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
5252
{
53-
if (!isset($args['input']['cart_id'])) {
53+
if (!isset($args['input']['cart_id']) || empty($args['input']['cart_id'])) {
5454
throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
5555
}
5656
$maskedCartId = $args['input']['cart_id'];

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,38 @@
2323
class RemoveItemFromCart implements ResolverInterface
2424
{
2525
/**
26-
* @var GuestCartItemRepositoryInterface
26+
* @var GetCartForUser
2727
*/
28-
private $guestCartItemRepository;
28+
private $getCartForUser;
2929

3030
/**
31-
* @var GetCartForUser
31+
* @var GuestCartItemRepositoryInterface
3232
*/
33-
private $getCartForUser;
33+
private $guestCartItemRepository;
3434

3535
/**
36-
* @param GuestCartItemRepositoryInterface $guestCartItemRepository
3736
* @param GetCartForUser $getCartForUser
37+
* @param GuestCartItemRepositoryInterface $guestCartItemRepository
3838
*/
3939
public function __construct(
40-
GuestCartItemRepositoryInterface $guestCartItemRepository,
41-
GetCartForUser $getCartForUser
40+
GetCartForUser $getCartForUser,
41+
GuestCartItemRepositoryInterface $guestCartItemRepository
4242
) {
43-
$this->guestCartItemRepository = $guestCartItemRepository;
4443
$this->getCartForUser = $getCartForUser;
44+
$this->guestCartItemRepository = $guestCartItemRepository;
4545
}
4646

4747
/**
4848
* @inheritdoc
4949
*/
5050
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
5151
{
52-
if (!isset($args['input']['cart_id'])) {
52+
if (!isset($args['input']['cart_id']) || empty($args['input']['cart_id'])) {
5353
throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
5454
}
5555
$maskedCartId = $args['input']['cart_id'];
5656

57-
if (!isset($args['input']['cart_item_id'])) {
57+
if (!isset($args['input']['cart_item_id']) || empty($args['input']['cart_item_id'])) {
5858
throw new GraphQlInputException(__('Required parameter "cart_item_id" is missing'));
5959
}
6060
$itemId = $args['input']['cart_item_id'];

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Mutation {
1111
addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
1212
applyCouponToCart(input: ApplyCouponToCartInput): ApplyCouponToCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ApplyCouponToCart")
1313
removeCouponFromCart(input: RemoveCouponFromCartInput): RemoveCouponFromCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\RemoveCouponFromCart")
14+
updateCartItems(input: UpdateCartItemsInput): UpdateCartItemsOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\UpdateCartItems")
1415
removeItemFromCart(input: RemoveItemFromCartInput): RemoveItemFromCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\RemoveItemFromCart")
1516
setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput): SetShippingAddressesOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetShippingAddressesOnCart")
1617
setBillingAddressOnCart(input: SetBillingAddressOnCartInput): SetBillingAddressOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetBillingAddressOnCart")

0 commit comments

Comments
 (0)