I am trying to get my custom Shipping and Return Metafields to be recognized by Google for Rich Results/Google Shopping, but the structured data is failing the validation test.
I need the correct Liquid snippet to successfully map my metafields to the necessary Google Schema properties.
Details of the Issue
Goal: Add Shipping Details and Return Policy to my product’s JSON-LD Schema, and functions for all my product.
Code Location: I understand the code needs to be placed in the right block, but need to know if it should be put in main-product.liquid file? And the exact position is?
Failure: When I try to add the code myself, it fails Google’s Rich Results Test instantly, confirming the structure is incorrect.
Request for Code Could an experienced developer please provide the correct Liquid code snippet required to map the metafields to the JSON-LD?
Google doesn’t read metafields directly, it only reads the final JSON-LD. So you need to inject your metafields inside the existing Product schema, not in a separate script.
Where to put it:
Go to Online Store → Themes → … → Edit code
Search for: type="application/ld+json" and "@type": "Product"
In most themes this is in a snippet (e.g. snippets/product-schema.liquid) or at the bottom of main-product.liquid.
You want to edit that existing Product JSON-LD block and add shipping/returns inside the "offers" object.
Key points:
Replace custom.shipping_details / custom.return_policy_url with your actual metafield namespace + key.
Keep everything dynamic wrapped in | json to avoid invalid JSON.
Don’t create a separate partial schema with only shippingDetails, keep it inside the main Product schema.
After saving, run the page through Google’s Rich Results Test again; if it still fails, it’s almost always a missing/extra comma or a wrong metafield handle.
So you should be able to add your info like below.
Of course, the actual code for OfferShippingDetails you need to construct yourself.
Here it is referenced, but you can obviously inline it too.
Also, you can use “Custom liquid” section added to the product template, no need to edit theme code for this.