missing CPF localization extension

Solved
luanbrito7
Tourist
4 0 0

Hi, I'm building a Shopify App using ShopifyAPI gem and I'm trying to get a specific country field (CPF) from a order

I think the only way that is possible now (2021-01) is through GraphQL api, but since I don't have much experience in graphql I just reproduced the last piece of code exemplified: https://shopify.dev/tutorials/manage-country-fields-using-localization-extensions

I've created an order through my development store with a random CPF number in additional information field, and manually made this request, but the response comes with empty edges

Body of my request:

{
  order(id: "gid://shopify/Order/order_id_value") {
    id
    localizationExtensions(first: 5) {
      edges {
        node {
          countryCode
          purpose
          title
          value
       }
     }
    }
  }
}

 

Api response:

{
"data": {
"order": {
"id": "gid://shopify/Order/order_id_value",
"localizationExtensions": {
"edges": []
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 8,
"actualQueryCost": 3,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 997,
"restoreRate": 50
}
}
}
}

 

am I missing something?

0 Likes
Michal_Morek
Shopify Partner
821 73 139

Hi @luanbrito7 

Hope you're having a great day!

It is clearly the order does not contain the data you are trying to retrieve.

For testing, you should update your existing order before your queries. Help below:

e8137c23-22d5-4ace-af67-452ce29e016a.png

 

Response:

a156ee6e-9b4b-4216-919f-09779dde1616.png

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
luanbrito7
Tourist
4 0 0

hi @Michal_Morek, thanks for the quick response, hope you're having a great day too

just to make sure I understand: I just need to do this process of adding myself this field for development/testing, but when a real brazilian customer order a product in a real store this field will be already there, right?

0 Likes
Michal_Morek
Shopify Partner
821 73 139

Hi @luanbrito7 

but when a real brazilian customer order a product in a real store this field will be already there, right?

Since Brazilian merchants are required to collect a tax ID for government invoicing, CPF/CNPJ localization extension field will be displayed in the Additional Information section during checkout on their store. So if you are not in a country where tax ID for government invoicing is required, you have to change the address of your development store before you can test this.

 

Localization extensions allow partners and app developers to access the tax id that is collected during checkout. So if the tax id was not collected during checkout for your orders, you can't get it using Localization extensions as you did below:

Body of my request:

{
  order(id: "gid://shopify/Order/order_id_value") {
    id
    localizationExtensions(first: 5) {
      edges {
        node {
          countryCode
          purpose
          title
          value
       }
     }
    }
  }
}

That's why localization extensions were [] in your API response.

API response:

{
"data": {
"order": {
"id": "gid://shopify/Order/order_id_value",
"localizationExtensions": {
"edges": []
}
}
},

Only orders made through checkout in countries that require a tax id for customs clearance or government invoicing will have this information available through the GraphQL API. So to test this feature, you needed an order containing a localization extension field that was collected during checkout. That's why I gave you my example. 

You should first update an old order with the localization extensions' data for the test before you can run your query. Or you can directly collect the country field on a custom checkout following this tutorial.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes
luanbrito7
Tourist
4 0 0

Hi, @Michal_Morek 

the strange thing is that my development store already has the address in Brazil, and when creating an order from the admin page I added the CPF in additional information field, and it does not appear on the order preview page in the store or in the query

this is because I created the order from development store admin page?

Screenshot from 2021-06-10 10-51-04.png

0 Likes
luanbrito7
Tourist
4 0 0

Hi, @Michal_Morek 

hope everything is fine with you

I'm using graphql to insert localization Extensions to a order for testing purpose just like you shown and it's working well, thanks!

but I would like to understand why this field has not been set through my store's admin page when I create a new order and add my CPF value to additional information (my development store's address is in Brazil)

This is supposed to happen? Can I assume the field will be there when a real brazilian customer request a fulfillment?

 

 

0 Likes
Michal_Morek
Shopify Partner
821 73 139

This is an accepted solution.

Hi @luanbrito7 

Hope you're having a great day!

You're welcome.

This is supposed to happen?

Yes. Default behavior. It works only by completing a checkout from your storefront, not from the store's admin.

Can I assume the field will be there when a real brazilian customer request a fulfillment?

To be sure, you can check it out as a customer from another browser (storefront) or private navigation tab.

Please, mark the answer that helped you as an accepted solution and hit Like. This would help others in the future who have the same problem and come across this thread. Thanks

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
Michal_Morek
Shopify Partner
821 73 139

Hi @luanbrito7 

You're welcome. I'm happy to help.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes