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

[Cart Operations] Update Cart Items validation messages #530

@atwixfirster

Description

@atwixfirster

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions