Shopify / checkout-sheet-kit-swift

Shopify’s Checkout Sheet Kit makes it simple to perform a checkout inside your Swift native app.
MIT License
37 stars 13 forks source link

Only one shipping address is being shown #134

Closed cka29 closed 6 months ago

cka29 commented 8 months ago

When creating a cart using the cartCreate mutation and providing multiple deliveryAddressPreferences for the CartBuyerIdentityInput I can only see one address in the checkout sheet. When I copy the carts' checkoutUrl and paste it in my browser I can see multiple (those I've sent with the mutation) addresses in the dropdown.

Thank you in advance!

EDIT: Same issue on android side, but I haven't opened an issue there yet. Let's check if this is really a bug first :)

kiftio commented 8 months ago

Hi @cka29, thanks for the report

Could you confirm that you're opening the checkout URL in a browser with no pre-existing cookies, (e.g. in incognito mode). And also whether you're submitting a customerAccessToken, as well as the deliveryAddressPreferences in the mutation's CartBuyerIdentityInput?

Thanks

cka29 commented 8 months ago

Hi @cka29, thanks for the report

Could you confirm that you're opening the checkout URL in a browser with no pre-existing cookies, (e.g. in incognito mode). And also whether you're submitting a customerAccessToken, as well as the deliveryAddressPreferences in the mutation's CartBuyerIdentityInput?

Thanks

Thanks for the quick response! Yes I can confirm all those. Better: When I create the cart by mentioned mutation, I even see the deliveryAddressPreferences in the mutations response. So I know that they're there, but they're just not shown in the mobile apps checkout sheet (only one of them is shown). On the other hand ALL deliveryAddressPreferences are visible in the desktop browser when calling the checkoutUrl from my mutations response. Do you need any other infos?

cka29 commented 7 months ago

Any news on this one?

kiftio commented 6 months ago

Hi @cka29 we're now displaying multiple shipping addresses based on delivery address preferences.

Let us know if you run into any issues.

cka29 commented 6 months ago

@kiftio thank you! So this will be included in the next release of CSK? Or was it fixed in Storefront API?

kiftio commented 6 months ago

It was Storefront API/checkout side, so no CSK update should be necessary

cka29 commented 6 months ago

@kiftio is this already included in the Storefront API v.unstable ? Because it's still not working for me :(

kiftio commented 6 months ago

It is in unstable now yes. This video is of the Android sample app on the main branch, pointing at a test store:

https://github.com/Shopify/checkout-sheet-kit-swift/assets/15106863/52364981-663a-42b4-bffa-184bce406e35

The deliveryAddressPreferences values are defined in DemoBuyerIdentity.kt. We don't have multiple addresses in the swift sample yet, but I just tried it out manually and it seemed to work OK there too.

Does the sample app match up with your setup?

N.B. There's also some address validation that happens, where invalid addresses may be discarded

cka29 commented 6 months ago

It is in unstable now yes. This video is of the Android sample app on the main branch, pointing at a test store:

multi-address.mp4 The deliveryAddressPreferences values are defined in DemoBuyerIdentity.kt. We don't have multiple addresses in the swift sample yet, but I just tried it out manually and it seemed to work OK there too.

Does the sample app match up with your setup?

N.B. There's also some address validation that happens, where invalid addresses may be discarded

Thanks for the quick response! I will look into it, but the hint regarding address validation could already solve this. Will check.

Thanks! 💯

cka29 commented 6 months ago

It is in unstable now yes. This video is of the Android sample app on the main branch, pointing at a test store:

multi-address.mp4 The deliveryAddressPreferences values are defined in DemoBuyerIdentity.kt. We don't have multiple addresses in the swift sample yet, but I just tried it out manually and it seemed to work OK there too.

Does the sample app match up with your setup?

N.B. There's also some address validation that happens, where invalid addresses may be discarded

I checked the code in main and everything seems to be setup similarly. However if I use createCart and the according deliveryAddressPreferences as input for buyerIdentity I always get an internal server error from Storefront API (version unstable). I use real addresses with country code DE for Germany. The store I'm testing against is located in Germany and delivers there too. However I saw that in the demo app you are using a list of MailingAddressInput instead of customerAddressId. I have also tried using customerAddressId, but this did not work either. EDIT: When I try to use both fields I get this error:

 GraphQLError(message: DeliveryAddressInput requires exactly one of delivery_address, customer_address_id, locations: [], path: [cartCreate], extensions: {code: INVALID_FIELD_ARGUMENTS})

Reference: https://shopify.dev/docs/api/storefront/2024-01/input-objects/DeliveryAddressInput

Does it help if I provide you the request-id?

error: GraphQLError(message: Internal error. Looks like something went wrong on our end.
Request ID: ff4df148-b0c9-4f6b-9f68-d0ca4d8d5c5a-1712768921 (include this in support requests)., locations: null, path: null, extensions: {code: INTERNAL_SERVER_ERROR, requestId: ff4df148-b0c9-4f6b-9f68-d0ca4d8d5c5a-1712768921})

Thank you for your patience @kiftio !

kiftio commented 6 months ago

Hi @cka29,

Thanks for the request ID, that did help track it down. I found that there's an open issue around this. The error appears when deliveryAddressPreferences is included in the graphQL response, when MailingAddresses are saved on the cart (as opposed to customerAddressIds).

We're not including deliveryAddressPreferences in the cartCreate response in the sample app, so we aren't running into it there.

Some additional notes:

N.B. this all assumes you're not passing in a customerAccessToken, which changes things a bit but I believe should also lead to multiple addresses being shown (taken from the customer account).

Last note, customer authentication is being worked on, which should be the better long term option. We'll let you know when it's ready.