Skip to content

GraphQL cannot add product with customizable option to cart #37599

Closed
@github-jira-sync-bot

Description

@github-jira-sync-bot

Steps to reproduce

  1. Go to admin panel > Catalog > Products
  2. Create a simple product (Joust Duffle bag)
  3. Create a custom option for Joust Duffle Bag
  4. Use next graphql queries
  5.  Create a empty cart
mutation {  createEmptyCart} 

Get product options information

{
  products(filter: {sku: {eq: "24-MB01"}}) {
    items {
      uid
      name
      sku
      __typename
      ... on CustomizableProductInterface {
        options {
          title
          required
          sort_order
          uid
          ... on CustomizableFieldOption {
            textField: value {
              sku
              price
            }
          }
          ... on CustomizableDropDownOption {
            dropDown: value {
              sku
              price
            } 
          }
        }
      }
    }
  }
}

Add product to cart using custom option

mutation {
  addProductsToCart(
    cartId: "`cart_id`"
    cartItems: <
      {
        quantity: 1
        sku: "24-MB01"
        entered_options: [{
          uid: "Y3VzdG9tLW9wdGlvbi8x"
          value: "some content here!"
        }]
      }
    ]
  ) {
    cart {
      items {
        product {
          name
          sku
        }
        ... on SimpleCartItem {
          customizable_options {
            customizable*option*uid
            label
            values {
              customizable*option_value*uid
              value
            }
          }
        }
        quantity
      }
    }
    user_errors {
      code
      message
    }
  }
} 

Get the response returned

Actual results

currently, customizable_options are empty

{
  "data": {
    "addProductsToCart": {
      "cart": {
        "items": [
          {
            "product": {
              "name": "Joust Duffle Bag",
              "sku": "24-MB01"
            },
            "customizable_options": [],
            "quantity": 1
          }
        ]
      },
      "user_errors": []
    }
  }
}

 

Expected results

{
  "data": {
    "addProductsToCart": {
      "cart": {
        "items": [
          {
            "product": {
              "name": "Joust Duffle Bag",
              "sku": "24-MB01"
            },
            "customizable_options": [
              {
                "customizable*option*uid": "Y3VzdG9tLW9wdGlvbi8x",
                "label": "option test1",
                "values": [
                  {
                    "customizable*option_value*uid": "Y3VzdG9tLW9wdGlvbi8x",
                    "value": "some content here!"
                  }
                ]
              }
            ],
            "quantity": 1
          }
        ]
      },
      "user_errors": [>
    }
  }
}

Metadata

Metadata

Assignees

Labels

EvaluatedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S1Affects critical data or functionality and forces users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions