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

[Cart Operations] Update Cart Items validation messages #530

Closed
atwixfirster opened this issue Mar 25, 2019 · 2 comments
Closed

[Cart Operations] Update Cart Items validation messages #530

atwixfirster opened this issue Mar 25, 2019 · 2 comments

Comments

@atwixfirster
Copy link
Contributor

atwixfirster commented Mar 25, 2019

Issue is reproduce-able in GraphQl - https://github.com/magento/graphql-ce

Preconditions (*)

  1. Create a simple product with SKU my-simple-product
  2. Advanced Inventory > Qty: 100
  3. Advanced Inventory > Minimum Qty Allowed in Shopping Cart: 1
  4. Advanced Inventory > Qty Uses Decimals: No

Steps to reproduce (*)

  1. Create an empty cart through
mutation {
  createEmptyCart
}
  1. Try to add 0.5 x my-simple-product into shopping cart
mutation {
  addSimpleProductsToCart(
    input: {
      cart_id: "d4viG4wIYOorhYCOxGsxd3GTjn8DnBqc"
      cartItems: {
        data: {
          qty: 0.5
          sku: "my-simple-product"
        }
      }
    }
  ) {
    cart {
      items {
        id
        qty
      }
    }
  }
}
  1. You will get Could not add the product with SKU my-simple-product to the shopping cart: The fewest you may purchase is 1. error. This is the expected result.

  2. Now, please add 1 x my-simple-product into shopping cart

mutation {
  addSimpleProductsToCart(
    input: {
      cart_id: "d4viG4wIYOorhYCOxGsxd3GTjn8DnBqc"
      cartItems: {
        data: {
          qty: 1
          sku: "my-simple-product"
        }
      }
    }
  ) {
    cart {
      items {
        id
        qty
      }
    }
  }
}
  1. You will get
{
  "data": {
    "addSimpleProductsToCart": {
      "cart": {
        "items": [
          {
            "id": "131",
            "qty": 1
          }
        ]
      }
    }
  }
}
  1. Let's update my-simple-product quantity through updateCartItems mutation query
mutation {
  updateCartItems(input: {
    cart_id: "d4viG4wIYOorhYCOxGsxd3GTjn8DnBqc"
    cart_items: [
      {
        cart_item_id: 131
        quantity: 0.5
      }
    ]
  }) {
    cart {
      items {
        id
        qty
      }
    }
  }
}

Expected result (*)

updateCartItemsshould return The fewest you may purchase is 1. error:

01

Actual result (*)

updateCartItems returns Invalid value of "0" provided for the qty field.:

02

@TomashKhamlai , could you please review this issue and let me know if the expected result is correct?

Thank you!!

CC: @galaoleksandr

@atwixfirster
Copy link
Contributor Author

PR: #531

Thank you!

@naydav
Copy link
Contributor

naydav commented Apr 29, 2019

#531

@naydav naydav closed this as completed Apr 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants