Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

[Cart Operations] Update Cart Items Mutation #377

Merged

Conversation

pmclain
Copy link
Contributor

@pmclain pmclain commented Feb 15, 2019

Description (*)

Mutation for updating cart items.

#37

Manual testing scenarios (*)

  1. Create empty cart
mutation {
  createEmptyCart
}
  1. Add product to cart
mutation AddToCart($cartId: String!) {
  addSimpleProductsToCart(input: {
    cart_id:$cartId
    cartItems:[
      {
        data: {
          sku:"product_dynamic_1",
          qty:2
        }
      }
      {
        data: {
          sku:"product_dynamic_2",
          qty:2
        }
      }
    ]
  }) {
    cart {
      cart_id
      items {
        id
        qty
        product {
          sku
        }
      }
    }
  }
}
  1. Update cart items
mutation updateCart($cartId:String!, $itemId:String!) {
  updateCartItems(input:{
    cart_id:$cartId
    cart_items:[
      {
        item_id:"$itemId"
        qty: 5
      }
    ]
  }) {
    cart {
      cart_id
      items {
        id
        qty
        product {
          sku
        }
      }
    }
  }
}
  1. Validate item quantity has been updated
  2. Remove cart item via zero qty update
mutation updateCart($cartId:String!, $itemId:String!) {
  updateCartItems(input:{
    cart_id:$cartId
    cart_items:[
      {
        item_id:"$itemId"
        qty: 0
      }
    ]
  }) {
    cart {
      cart_id
      items {
        id
        qty
        product {
          sku
        }
      }
    }
  }
}
  1. Validate cart item is removed

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@TomashKhamlai
Copy link
Contributor

Similar problem like in #357 can be seen here while updating with qty = -1
Validation message is expected

message: "Please enter a quantity greater than 0."

Do not think that it should be fixed here or now. Just linking issue to have use cases to check later
@naydav, can you approve that "zero qty update" is valid request?

@TomashKhamlai
Copy link
Contributor

Covered mc-8886

@pmclain pmclain force-pushed the feature/update-cart-items branch from d5cc236 to dd42a46 Compare February 24, 2019 17:39
@naydav
Copy link
Contributor

naydav commented Mar 6, 2019

Similar problem like in #357 can be seen here while updating with qty = -1
Validation message is expected

message: "Please enter a quantity greater than 0."

Do not think that it should be fixed here or now. Just linking issue to have use cases to check later
@naydav, can you approve that "zero qty update" is valid request?

Need to ask PO

@ghost
Copy link

ghost commented Mar 8, 2019

Hi @pmclain, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@keharper
Copy link
Contributor

Documented as part of magento/devdocs#4502

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants