Shopify / function-examples

MIT License
185 stars 53 forks source link

Null fields in purchase.pickup-point-delivery-option-generator.fetch #520

Open victorvilarocket opened 4 months ago

victorvilarocket commented 4 months ago

Describe the bug

We are using the new Pickup Points Delivery Option Generator API in our checkout and we are getting some null values when entering the address.

Screenshot 2024-06-18 at 13 44 30

Screenshot 2024-06-18 at 13 46 03

Screenshot 2024-06-18 at 13 47 23

Here's my fetch.graphql:

query FetchInput { deliveryAddress{ address1 address2 company provinceCode zip phone city countryCode longitude latitude } }

https://shopify.dev/docs/api/functions/reference/pickup-point-delivery-option-generator/graphql/input

Expected behavior

Address1, address2 and city should have values in the input purchase.pickup-point-delivery-option-generator.fetch.

Environment

MacOS Shopify CLI version 3.60

victorvilarocket commented 2 months ago

@mathiusj @davejcameron @FriedRiceNoodles @adampetro can you help me here please?

VictorNiharra commented 2 months ago

cc @joshua-arts can you take a look pls?

joshua-arts commented 2 months ago

Hey @victorvilarocket!

The address here comes from the address that the buyer enters into the pickup points search field at checkout, which is not required to be a full address.

As an example, you can search for "Ontario, Canada" to find pickup points generally within the province, which doesn't have a city or a postal code attached. In this case, you'd see just a lat/long (which is general to ON), zone and country data.

We do our best to try and infer the postal code and city, but this is based on the buyer location and that does not always match up to the search result (and we won't send it through if it doesn't match the search country / zone).


Totally get the the typing here isn't super clear, and I think we can make improvements to the field and documentation to make it clear that you cannot rely on some fields being present all the time. At the bare minimum, you should always get a lat/long and a country.