How can I update an Item and add Modifier?

I’m developing a website and I’m having issues trying to modify the order.

Deleting modifiers it’s fine just adding the UID to the fieldsToClear.

but adding modifiers to a existing items doesn’t seems to be working, for instance, lets take this object from lineItems

It has an Item with 2 modifiers, but the customer wants to add another modifier to that order.
Test Item

  • Add-on Modifier 1
  • Add on Modifier 2
{
            "uid": "2WMc7OpHLgAG7C39XpNLHC",
            "name": "Test Item",
            "quantity": "1",
            "catalogObjectId": "L2O3GMJS6D2S6HP4YB7XGHK4",
            "catalogVersion": "1680288876214",
            "variationName": "Regular",
            "itemType": "ITEM",
            "modifiers": [
                {
                    "uid": "N2apMYYxKbt3QPQPyiAbND",
                    "catalogObjectId": "2UZIFRUSLLRVCXHQLK2E3OI7",
                    "catalogVersion": "1680288876214",
                    "name": "Add-on Modifier 1",
                    "quantity": "1",
                    "basePriceMoney": {
                        "amount": "30",
                        "currency": "USD"
                    },
                    "totalPriceMoney": {
                        "amount": "30",
                        "currency": "USD"
                    }
                },
                {
                    "uid": "ltuaRp46ykMYYgTY9utOq",
                    "catalogObjectId": "N6GTLMDHERB6YVAKY2VN7SDW",
                    "catalogVersion": "1680288876214",
                    "name": "Add-on Modifier 2",
                    "quantity": "1",
                    "basePriceMoney": {
                        "amount": "40",
                        "currency": "USD"
                    },
                    "totalPriceMoney": {
                        "amount": "40",
                        "currency": "USD"
                    }
                }
            ],
            "appliedTaxes": [
                {
                    "uid": "dc3a4593-2dea-4568-b62d-e7e3e779a3c1",
                    "taxUid": "2a719a92-c99b-4264-848d-ef7a6790d58d",
                    "appliedMoney": {
                        "amount": "23",
                        "currency": "USD"
                    }
                }
            ],
            "basePriceMoney": {
                "amount": "274",
                "currency": "USD"
            },
            "variationTotalPriceMoney": {
                "amount": "274",
                "currency": "USD"
            },
            "grossSalesMoney": {
                "amount": "384",
                "currency": "USD"
            },
            "totalTaxMoney": {
                "amount": "23",
                "currency": "USD"
            },
            "totalDiscountMoney": {
                "amount": "0",
                "currency": "USD"
            },
            "totalMoney": {
                "amount": "407",
                "currency": "USD"
            },
            "totalServiceChargeMoney": {
                "amount": "0",
                "currency": "USD"
            }
        }

What I’m trying to do is just adding the new modifier to the modifiers array like this:

Test Item

  • Add-on Modifier 1
  • Add on Modifier 2
    - Add on Modifier 3
{
            "uid": "2WMc7OpHLgAG7C39XpNLHC",
            "name": "Test Item",
            "quantity": "1",
            "catalogObjectId": "L2O3GMJS6D2S6HP4YB7XGHK4",
            "catalogVersion": "1680288876214",
            "variationName": "Regular",
            "itemType": "ITEM",
            "modifiers": [
                {
                    "uid": "N2apMYYxKbt3QPQPyiAbND",
                    "catalogObjectId": "2UZIFRUSLLRVCXHQLK2E3OI7",
                    "catalogVersion": "1680288876214",
                    "name": "Add-on Modifier 1",
                    "quantity": "1",
                    "basePriceMoney": {
                        "amount": "30",
                        "currency": "USD"
                    },
                    "totalPriceMoney": {
                        "amount": "30",
                        "currency": "USD"
                    }
                },
                {
                    "uid": "ltuaRp46ykMYYgTY9utOq",
                    "catalogObjectId": "N6GTLMDHERB6YVAKY2VN7SDW",
                    "catalogVersion": "1680288876214",
                    "name": "Add-on Modifier 2",
                    "quantity": "1",
                    "basePriceMoney": {
                        "amount": "40",
                        "currency": "USD"
                    },
                    "totalPriceMoney": {
                        "amount": "40",
                        "currency": "USD"
                    }
                },
                {
                    "catalogObjectId": "Z33Y2Y3KMTNFPHV2H57PJFVZ",
                    "name": "Add-on Modifier 3",
                    "quantity": "1"
                }
            ],
            "appliedTaxes": [
                {
                    "uid": "dc3a4593-2dea-4568-b62d-e7e3e779a3c1",
                    "taxUid": "2a719a92-c99b-4264-848d-ef7a6790d58d",
                    "appliedMoney": {
                        "amount": "23",
                        "currency": "USD"
                    }
                }
            ],
            "basePriceMoney": {
                "amount": "274",
                "currency": "USD"
            },
            "variationTotalPriceMoney": {
                "amount": "274",
                "currency": "USD"
            },
            "grossSalesMoney": {
                "amount": "384",
                "currency": "USD"
            },
            "totalTaxMoney": {
                "amount": "23",
                "currency": "USD"
            },
            "totalDiscountMoney": {
                "amount": "0",
                "currency": "USD"
            },
            "totalMoney": {
                "amount": "407",
                "currency": "USD"
            },
            "totalServiceChargeMoney": {
                "amount": "0",
                "currency": "USD"
            }
        }

But it’s not working, any ideas?

In this case you won’t be adding a new modifier directly to the item. You’ll need to create a new modifier in the modifier list. Any item that’s associated to the list then will automatically show the newly created modifier. :slightly_smiling_face:

Hi Bryan, let me add more context to my question, so all the modifiers exists in the catalog already, this is trying to add a modifier to the existing item (in the order)

This flow is for food ordering:

The customer adds a
Step 1:

Caesar Salad

  • Add Chicken
  • Add Ranch

Step 2:
Add the item with modifiers to the order.

Step 3:
Edits the item and adds a Celery in the modifiers.

The step 3 is the one in the code above

Okay, you can get that to work by calling UpdateOrder with:

{
    "idempotency_key": "{{$guid}}",
    "order": {
      "location_id": "{{location_id}}",
      "line_items": [
        {
          "uid": "OCRrpPPfNSYPnejia5TrQB",
          "catalog_object_id": "{{catalog_item_variation_id}}",
          "quantity": "1",
          "modifiers": [
            {
              "catalog_object_id": "{{catalog_modifier_object_id}}"
            }
          ]
        }
      ],
      "version": 2
    }
  }

:slightly_smiling_face: