Sorting delivery methods doesn't work for Local Delivery #196
Replies: 14 comments 4 replies
-
Beta Was this translation helpful? Give feedback.
-
Looks like the sorting is done on some shipping rates prefetch which might have only subset of delivery options. |
Beta Was this translation helpful? Give feedback.
-
Any solution for this? |
Beta Was this translation helpful? Give feedback.
-
It worked on my tests. Would like to better understand the issue here but seems I miss some context about your setup @SaeedYasin. @rameshr-shopify do you have any idea for this, why could it happen this way for local delivery? Context for delivery customizations API doc. |
Beta Was this translation helpful? Give feedback.
-
We used to have some specific sorting logic for local delivery and instore pickup before, but it shouldn't be overriding function outputs. @SaeedYasin , are you able to share the checkout token (the url) of a checkout when you encountered this issue? We'd be able to get a better understanding of what's happening if we have that info. |
Beta Was this translation helpful? Give feedback.
-
The simplest way I am able to reproduce the issue is to just refresh the checkout shipping page a couple of times, then it will happen. Please note that this issue does happen in normal checkout flow as well, although only occasionally, so it's intermittent. When it does happen, then Local Delivery appears after a delay as compared to other shipping methods, as I described before. Here is the checkout URL, please note only one function was active on this store when I did this testing, Here is a video of the checkout, I refresh the checkout page a few times and in the last refresh it shows Local Delivery at the end, although the function is set to ensure Local Delivery always appears at the top. Here is function's execution results, first I show all the function executions which happened during the capture of the video above, then I show the last function result which clearly shows that Local Delivery was set to appear at the top by the function output, but that clearly didn't happen at the checkout. |
Beta Was this translation helpful? Give feedback.
-
To test it even further, I added this sorting function on a new dev store which doesn't really have anything else in it and I see different behaviour which is even stranger, it completely removed the Local Delivery option altogether from the checkout sometimes. Here is the checkout URL, only one function (same function) was active which ensures Local Delivery is at the top, Here is a video of the checkout, Here you can see even the first time when I land on the checkout shipping page, it has already removed the Local Delivery option, which is wrong. I refresh the checkout page a few times and in the last one it removes the Local Delivery option again. Here is function's execution results, first I show all the function executions which happened during the capture of the video above, then I show them one by one. We can see sometimes the function input is not receiving Local Delivery as input and in the next run it does receive it. I am not sure what is causing these weird behaviours, as far as I can check I made sure settings for both stores for shipping and Local Delivery etc are identical. |
Beta Was this translation helpful? Give feedback.
-
@RaVbaker @rameshr-shopify any news on this? please do let me know if you need anything else from me, thanks. |
Beta Was this translation helpful? Give feedback.
-
I took a deeper look at this and I'm not able to reproduce this issue on my store. On the store https://sylab-dev.myshopify.com/, refreshing the page during the shipping step on checkout doesn't seem to result in a valid network request which seems weird to me. On a few different stores I tested on, refreshing the page on checkout always results in a network request and getting the latest shipping information (including local delivery). @RaVbaker would you happen to know someone who'd be able to better help this issue? It doesn't seem to be anything local delivery specific which is causing this issue. |
Beta Was this translation helpful? Give feedback.
-
I’m running into this issue as well, and I can confirm it is unrelated to local delivery. The issue as I see it is:
While the user is on the shipping step of checkout, if any process changes the visible shipping methods, new shipping methods will often be added to the end of the list rather than placed in a proper sort order (i.e. as dictated by My pressing use-case is this (because discount codes are likely to be added while the user is selecting shipping options): https://discord.com/channels/842813079926603828/1096090045351469156/1096098022976405534, but an easier-to-test edge case that also could affect us is customer VIP free shipping tags: We have a delivery_customization function that hides standard shipping and shows free shipping if a customer is tagged with Again, this edge case (customer tagging that occurs while the customer is in checkout), is really unlikely and not a problem for our business, but it illustrates a bigger issue I’m trying to solve and appears to be a bug with checkout rendering that we can’t control. My guess is that it’s a race condition, or (if y’all are using React), it reminds me of the index-as-key list sorting issue: https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key Let me know if a simplified function for issue reproduction would be useful! |
Beta Was this translation helpful? Give feedback.
-
@rameshr-shopify @RaVbaker any idea when y'all might have a chance to look into this? We are otherwise ready to move off of our old shipping script and onto shopify functions, but we will have to hold on rolling this out until this sorting issue is resolved |
Beta Was this translation helpful? Give feedback.
-
This sorting issue exists even if the store does not have a delivery customization function installed. Here are the reproduction steps using a newly-created dev store using Shopify-provided test data and no apps/customizations: https://gist.github.com/alxwstn/0ea8358375b64aaaafe73f0b42190ee9 I'll be surfacing this at office hours tomorrow for more visibility as well! Hoping to get some acknowledgement of this bug. |
Beta Was this translation helpful? Give feedback.
-
@alxwstn I had a look your reproduce steps above and am unable to reproduce at this point. Can you check if you can still reproduce? |
Beta Was this translation helpful? Give feedback.
-
I read in the dev docs that Delivery customization doesn't support local delivery and local pickup options (https://shopify.dev/docs/api/functions/reference/delivery-customization). It's confusing whether it's worth supporting local pickup and local delivery or not. |
Beta Was this translation helpful? Give feedback.
-
Here function output is defining the sorting of the shipping methods, but that is NOT what happens on the checkout. Local delivery seems to have a mind of it's own and sometimes appears randomly as the last shipping method, which is not what the sorting function specified. Is this known behaviour or issue?
Function Stdin:
Function Stdout:
Checkout:
Store name:
https://sylab-store.myshopify.com/
Beta Was this translation helpful? Give feedback.
All reactions