A developer is attempting to retrieve a custom metafield (custom.sync_varients) in Shopify using custom Liquid code without modifying the theme directly. The code works inconsistently—functioning on first click but failing when navigating to other products.
Key Issues Identified:
Missing .value property when accessing the metafield (should be product.metafields.custom.sync_varients.value)
The all_products object has a 20-use limit per page, which may cause intermittent failures
List-type metafields require loops or array access methods
Recommended Solutions:
Use a product reference metafield type instead, which returns a product object directly and eliminates the need for all_products
Verify all products have values entered in the metafield
Inspect the rendered output using browser developer tools to troubleshoot what’s actually being generated
The discussion remains open with troubleshooting suggestions provided but no confirmed resolution from the original poster.
Summarized with AI on November 7.
AI used: claude-sonnet-4-5-20250929.
if your metafield contains product handle, then you need to use all_products; but nowadays a better approach would be to have a product reference type metafield which will return a product object so there is no need for all_products.