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

magento/graphql-ce#438: Adjust adding configurable products to the shopping cart #799

Merged
merged 1 commit into from
Aug 2, 2019

Conversation

lenaorobei
Copy link
Contributor

#438

Description (*)

Fixed Issues (if relevant)

  1. magento/magento2#<issue_number>: Issue title

Manual testing scenarios (*)

  1. ...
  2. ...

Questions or comments

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 are green)

@lenaorobei lenaorobei force-pushed the Configurable-add-to-cart branch 3 times, most recently from fb11b86 to 8481770 Compare August 1, 2019 16:01
@lenaorobei lenaorobei marked this pull request as ready for review August 1, 2019 16:07
@TomashKhamlai
Copy link
Contributor

A configurable product with variants configured around 2 attributes: first is visual swatch with 5 options, second is text swatch with 3 options, also has required customizable option.
A simple product associated with 2 selected options that I want to add to the cart also has a tier price for qty 5. I added 2 exactly the same configurable variants in quantity of 5 each with different customizable options.
My request for the second item (exactly the same except customizable option value)

mutation {
  addConfigurableProductsToCart(
    input: {
      cart_id: "pTJWGSAzx9mGs8Q3WT7HgE81O2MCO02e"
      cart_items: {
        data: {
          quantity: 5
          sku: "configurable-product-1-white-wholesale@us-mobiles.cn"
        }
        parent_sku: "configurable-product-1"
        customizable_options: {
          id: 1
          value_string: "blah-blah"
        }
      }
    }
  ) {
    cart {
      email
      items {
        id
        quantity
      }
    }
  }
}

Response

{
  "data": {
    "addConfigurableProductsToCart": {
      "cart": {
        "email": "John.Doe@example.com",
        "items": [
          {
            "id": "23",
            "quantity": 5
          },
          {
            "id": "25",
            "quantity": 5
          }
        ]
      }
    }
  }
}

When I try to update the quantity for any of the items I have the following situation:

Request

mutation {
  updateCartItems(
    input: {
      cart_id: "pTJWGSAzx9mGs8Q3WT7HgE81O2MCO02e"
      cart_items: {
        cart_item_id: 23
        quantity: 1
      }
    }
  ) {
    cart {
      items {
        id
        quantity
      }
    }
  }
}

Response

{
  "data": {
    "updateCartItems": {
      "cart": {
        "items": [
          {
            "id": "23",
            "quantity": 1
          },
          {
            "id": "25",
            "quantity": 5
          }
        ]
      }
    }
  }
}

Request

mutation {
  updateCartItems(
    input: {
      cart_id: "pTJWGSAzx9mGs8Q3WT7HgE81O2MCO02e"
      cart_items: {
        cart_item_id: 25
        quantity: 1
      }
    }
  ) {
    cart {
      items {
        id
        quantity
      }
    }
  }
}

Response

{
  "data": {
    "updateCartItems": {
      "cart": {
        "items": [
          {
            "id": "23",
            "quantity": 5
          },
          {
            "id": "25",
            "quantity": 1
          }
        ]
      }
    }
  }
}

Expected result

I can update both items

Actual result

I cannot update them
The response fools me

@TomashKhamlai
Copy link
Contributor

Notice: Undefined index: option_value in /shared/httpd/graphql-ce/graphql-ce/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/ConfigurableCartItemOptions.php on line 61 for the query

query viewCart(
  $cart_id: String!
) {
  cart(
    cart_id: $cart_id
  ) {
    applied_coupon {
      code
    }
    email
    items {
      id
      ... on ConfigurableCartItem {
        configurable_options {
          id
          value_label
          option_label
          value_id
        }
      }
    }
    prices {
      grand_total {
        value
        currency
      }
    }
    selected_payment_method {
      code
      purchase_order_number
      title
    }
    shipping_addresses {
      postcode
    }
    billing_address {
      postcode
    }
  }
}

@magento-engcom-team magento-engcom-team merged commit aeb7cc5 into 2.3-develop Aug 2, 2019
@ghost
Copy link

ghost commented Aug 2, 2019

Hi @lenaorobei, 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.

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.

3 participants