What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Could not add custom attribute in order with cartTransformAPI using FLOW.

Could not add custom attribute in order with cartTransformAPI using FLOW.

Sayed_Safin
Shopify Partner
44 2 2

Can you please help me to fix and what is the issue in the given code?
Flow workflow code 

Problem Solved? ✔Accept and Like solutions to help future merchants.
Github: https://github.com/safin777
Buy me a coffee
Replies 4 (4)

PaulNewton
Shopify Partner
7516 662 1578

See orderUpdate,  or instead use tags, or metafields

https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/orderUpdate

💣customAttributes will nuke all other attributes if you don't get them first as part of the update.

 

The cartTransform api is part of shopify-functions that run in the checkout not an api to call at some arbitrary time before or after in the process.

https://shopify.dev/docs/api/functions/reference/cart-transform 

 

Avoid posting screenshots of code when there is a literal code button, do the effort to lower the effort and time others have to burn to aid you.

https://community.shopify.com/c/blog/how-to-get-support-from-the-community/ba-p/1399408

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


Kalen_Jordan
Shopify Partner
798 37 143

The json input is invalid. I see a missing colon after customAttributes. Try pasting that into a json validator or better yet use the graphiql app to test the mutation outside of flow.

Sayed_Safin
Shopify Partner
44 2 2

Hi @Kalen_Jordan I have tried after using the colon, but still showing the error. 
Can you please tell me what is the error here which is blocking me here? 

{% assign bundleSku = "bundleSku" %}
{% for lineItems_item in order.lineItems %}
  {% assign bundleSku = lineItems_item.lineItemGroup.variantSku %}
{% endfor %}

mutation orderUpdate($input: OrderInput!) {
  orderUpdate(input: $input) {
    order {
      id
      customAttributes {
       key
       value
      }
    }
    userErrors {
      message
      field
    }
  }
}


{
  "input":{
    "id" : "{{ order.id }}",
    "customAttributes" : 
    {
      "key" : "Bundle-Sku",
      "value": "{{ bundleSku }}"
    }
  }
}
Problem Solved? ✔Accept and Like solutions to help future merchants.
Github: https://github.com/safin777
Buy me a coffee
Kalen_Jordan
Shopify Partner
798 37 143

Not sure - I'd recommend running that query through the graphiql app. You'll get a detailed error that way. If you'd like some additional help from me on a paid basis, the link is in my signature.