Solved

Update Company name Shopify Flow

Ram_A
Explorer
59 3 18

Hi,


I'd really appreciate any help in my Shopify Flow

Main goal is: Upon customer account creation >>> update the customer default address company name based on the customer specific tag

1. Upon customer account creation.
2. Check if the he has a certain tags A,B,C, if so, then go to 3.

3. Then use that tag value to update the customer default address company name.
4. Quick twist: I don’t want the tag to include any additional tags that the customer has unless they match the first set of tags on (Step 2). E.g. if a customer has tags A and Apple, the condition will go through, but only tag A will be used to update the company name. Apple won’t be added as it doesn’t match the condition set in step#2.
Note: The customer will always has only one of those tags from Step 2 sit, so he won't have more than one. However, they might still have other tags not related to that sit.

Now, here's the hiccup, when I run the Shopify Flow, it seems the URL endpoint variable doesn't pick up the values of the customer ID and the address ID from the previous steps.


Thanks a bunch!
Cheers,

HTTP PUT Request:

 

https://XX.myshopify.com/admin/api/2024-01/customers/{{customer.id}}/addresses/{{customer.defaultAddress.id}}.json

 


Body:

 

 

 

{% assign numeric_customer_id = customer.id | remove: 'gid://shopify/Customer/' | split: '/' | last %}
{% assign numeric_customer_defaultAddress_id = customer.defaultAddress.id | remove: 'gid://shopify/MailingAddress/' | split: '/' | first %}

{% assign company_tag = '' %}
{% for tags_item in customer.tags %}
  {% assign company_tag = tags_item %}
{% endfor %}

{% for addresses_item in customer.addresses %}
  {% assign updated_company_value = company_tag %}
  {% capture updated_company_json %}{"address": {"company": "{{ updated_company_value }}"}}{% endcapture %}
  {{ updated_company_json }}
{% endfor %}

 

 


The error I got:

The request was unsuccessful
{"status":400,"response_body":"Bad Request","verb":"PUT","url":"https://XX.myshopify.com/admin/api/2024-01/customers/gid://shopify/Customer/6525273112612/addresses/gid://shopify/MailingAddress/7867024834596?model_name=CustomerAddress.json","request_body":"\n\n\n\n\n\n\n\n"}



Flow.png

Condition.pngHTTP PUT Request.png


Error.png

Accepted Solution (1)
paul_n
Shopify Staff
793 118 191

This is an accepted solution.

{{ customer.legacyResourceId }}

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 3 (3)

paul_n
Shopify Staff
793 118 191

ID is a GID like "gid://shopify/Customer/123". You want legacyResourceId, which would be "123"

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Ram_A
Explorer
59 3 18

 

Hey Paul, I'm a bit stuck on how to make the variable grab the legacyResourceId value. Here's where I'm at:

https://XX.myshopify.com/admin/api/2024-01/customers/{{customer.id}}/addresses/{{customer.defaultAddress.id}}.json



 

{% assign numeric_customer_id = customer.id | remove: 'gid://shopify/Customer/' | split: '/' | last %}
{% assign numeric_customer_defaultAddress_id = customer.defaultAddress.id | remove: 'gid://shopify/MailingAddress/' | split: '/' | first %}


{% assign company_tag = '' %}
{% for tags_item in customer.tags %}
  {% assign company_tag = tags_item %}
{% endfor %}

{% for addresses_item in customer.addresses %}
  {% assign updated_company_value = company_tag %}
  {% capture updated_company_json %}{"address": {"company": "{{ updated_company_value }}"}}{% endcapture %}
  {{ updated_company_json }}
{% endfor %}

 


Screenshot 2024-01-17 at 18.24.33.png

 

paul_n
Shopify Staff
793 118 191

This is an accepted solution.

{{ customer.legacyResourceId }}

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.