MDVA-39521: Unable to set shipping address on carts via GraphQL

Last update: 2023-07-27
  • Created for:
  • Admin

The MDVA-39521 patch solves the issue where the user is unable to set shipping address on carts with an empty phone number via GraphQL. This patch is available when the Quality Patches Tool (QPT) 1.1.2 is installed. The patch ID is MDVA-39521. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.4.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.2-p1

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.0 - 2.4.3
NOTE

The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

The user is not able to set shipping address on the carts with an empty telephone number via GraphQL despite the fact that the Show Telephone is configured as optional.

Steps to reproduce:

  1. Create a simple product.

  2. Go to Stores > Configuration > Customers > Customer Configuration > Name and Address Options and set the Show Telephone as Optional.

  3. Create an empty cart via GraphQL request.

    mutation {
    createEmptyCart
    }
    
  4. Add product to cart.

    mutation {
    addSimpleProductsToCart(
    input: {
      cart_id: "{ CART_ID }"
      cart_items: [
        {
          data: {
            quantity: 1
            sku: "24-MG04"
          }
        }
      ]
    }
    ) {
    cart {
      items {
        id
        product {
          sku
          stock_status
        }
        quantity
      }
    }
    }
    }
    
  5. Add address: GRAPHQL VARIABLES.

    {
      "cartId": "6Efw00UbjPoP5cvTFhsswDTjpxs0Xupt"
    }
    
    mutation ($cartId: String!) {
      setShippingAddressesOnCart(input: {cart_id: $cartId, shipping_addresses:
      {address: {firstname: "John", lastname: "Doe", company: "Company Name",
      street: ["820 Burrard Street"], city: "Vancouver", region: "BC", postcode: "V6Z 2J1",
      country_code: "CA", telephone: "123-456-0000", save_in_address_book: false}}}) {
        cart {
          shipping_addresses {
            firstname
            lastname
            company
            street
            city
            postcode
            telephone
            country {
              code
              label
            }
          }
        }
      }
    }
    

    Result:

      {
          "data": {
              "setShippingAddressesOnCart": {
                  "cart": {
                      "shipping_addresses": [
                          {
                              "firstname": "John",
                              "lastname": "Canada",
                              "company": "Company Name",
                              "street": [
                                  "820 Burrard Street"
                              ],
                              "city": "Vancouver",
                              "postcode": "V6Z 2J1",
                              "telephone": "123-456-0000",
                              "country": {
                                  "code": "CA",
                                  "label": "CA"
                              }
                          }
                      ]
                  }
              }
          }
      }
    
  6. Add address with empty phone number.

    mutation ($cartId: String!) {
      setShippingAddressesOnCart(input: {cart_id: $cartId, shipping_addresses: {address: {firstname:
        "John", lastname: "Canada", company: "Company Name", street: ["820 Burrard Street"], city:
        "Vancouver", region: "BC", postcode: "V6Z 2J1", country_code: "CA", telephone: "123-456-0000",
        save_in_address_book: false}}}) {
        cart {
          shipping_addresses {
            firstname
            lastname
            company
            street
            city
            postcode
            telephone
            country {
              code
              label
            }
          }
        }
      }
    }
    

Expected results:

 {
    "data": {
        "setShippingAddressesOnCart": {
            "cart": {
                "shipping_addresses": [
                    {
                        "firstname": "John",
                        "lastname": "Doe",
                        "company": "Company Name",
                        "street": [
                            "820 Burrard Street"
                        ],
                        "city": "Vancouver",
                        "postcode": "V6Z 2J1",
                        "telephone": "",
                        "country": {
                            "code": "CA",
                            "label": "CA"
                        }
                    }
                ]
            }
        }
    }
 }

Actual results:

{
    "data": {
        "setShippingAddressesOnCart": {
            "cart": {
                "shipping_addresses": []
            }
        }
    }
}

Apply the patch

To apply individual patches, use the following links depending on your deployment type:

To learn more about Quality Patches Tool, refer to:

For info about other patches available in QPT, refer to the Patches available in QPT section.

On this page