Why are custom metafields on customers showing stale data?

Hello! We have a problem regarding custom metafields and we need your two cents on the issue.

We have some custom metafields for customers, let’s say billing.first_name and billing.last_name. The problem is that sometimes when we try to access the custom metafields, for example in checkout layout using the following, we get old/stale data (previous values).


Note 1: If we populate the custom fields using Matrixify import then there is no problem, but when we change the custom metafields manually from the back-office then most of the time the data are wrong.

Note 2: The issue arises also in Incognito Mode

If you’re experiencing stale or old data when accessing custom metafields for customers, there are a few potential causes and solutions you can consider:

  1. Caching: It’s possible that the stale data is being cached by the browser or by Shopify’s servers. To rule out caching as the cause, try clearing your browser cache or using a private browsing mode (like Incognito mode) to see if the issue persists. If the stale data is still being displayed, caching may not be the primary cause.

  2. Metafield synchronization: When you update customer metafields manually from the Shopify admin, there might be a delay in the synchronization of the updated values. Shopify’s metafields API has eventual consistency, which means changes to metafields may take some time to propagate fully. If you’re immediately accessing the updated metafield values after making the changes, you may encounter the stale data. To mitigate this, you can add a small delay (e.g., a few seconds) before accessing the metafield values to allow time for synchronization.

  3. Theme code caching: If you’ve made changes to your theme code, such as adding the script to access custom metafields, it’s possible that the theme code itself is being cached. In this case, you can try clearing the theme code cache by editing your theme settings and saving the changes. This can force a recompilation of the theme code and ensure that the latest version is being used.

  4. App conflicts: If you have any installed apps that interact with customer metafields or modify customer data, there could be conflicts or interference causing the stale data. Consider reviewing the apps you have installed and their impact on customer metafields. Temporarily disabling or removing apps one by one can help identify if a specific app is causing the issue.