show_microdata.php – Adding shipping/returns to Offer JSON-LD (ChatGPT recommend

  • Posts: 391
  • Thank you received: 14
  • Hikashop Business
12 hours 28 minutes ago #370534

Hi Nicolas,

I’m working in product structured data.
This is generated via this template override:

`/templates/cassiopeia/html/com_hikashop/product/show_microdata.php`

When I validate a product page with Google’s Rich Results Test, the page is valid, but I consistently get **non-critical Merchant listings warnings under `offers`**:

* Missing field `hasMerchantReturnPolicy` (optional)
* Missing field `shippingDetails` (optional)

A practical approach was suggested to me by ChatGPT to “polish” shipping and returns for Google Merchant listings: implement these fields **server-side** in the Offer JSON-LD that HikaShop outputs (instead of injecting them with JavaScript after load, which doesn’t seem to be reliably picked up by Google’s test).

**Goal**
Add `hasMerchantReturnPolicy` (and later `shippingDetails`) inside each `Offer` object that HikaShop generates (variants) in `show_microdata.php`, so Google can read it reliably and these warnings disappear.

**Return policy requirements / constraints**

* Public return policy page: ` www.hermanosgaliano.es/devoluciones `
* General return window: **15 days**
* For **personalized products**, returns are **not permitted** (except manufacturing defects; details are on the policy page)
* We can detect personalized products by URL/alias containing the substring `personaliz` (plus one specific exception slug)

**Proposed implementation (high level)**
In `show_microdata.php`, where `$variant_offer` is built (Offer JSON-LD), add something like:

* `hasMerchantReturnPolicy`:

* `@type: MerchantReturnPolicy`
* `applicableCountry: ES`
* `merchantReturnLink: www.hermanosgaliano.es/devoluciones `
* `returnPolicyCategory`:

* `MerchantReturnNotPermitted` for personalized products
* `MerchantReturnFiniteReturnWindow` + `merchantReturnDays: 15` for non-personalized products

Then attach it to the offer:
`$variant_offer->hasMerchantReturnPolicy = $rp;`

**Questions**

1. Is editing/augmenting `show_microdata.php` (override) the recommended/supported way to extend the Offer JSON-LD in HikaShop, or is there a built-in config/hook/plugin mechanism you’d recommend instead?
2. Does the use of `MerchantReturnPolicy` inside `Offer` align with HikaShop’s schema output and Google’s Merchant listings expectations, in your experience?
3. For `shippingDetails`, is there a preferred best-practice approach in HikaShop (global shipping policy vs per-offer `shippingDetails`) that you recommend?

If you want, I can paste the exact excerpt from `show_microdata.php` where `$variant_offer` is created, so you can advise the cleanest placement.

Thanks a lot,
José Ángel

Please Log in or Create an account to join the conversation.

  • Posts: 85116
  • Thank you received: 13885
  • MODERATOR
8 hours 45 minutes ago #370536

Hi,

1. Overriding show_microdata.php is indeed the way to go.

2. You can indeed do it like that. However, as you can read at developers.google.com/search/docs/appear...d-data/return-policy supporting all the cases for us in an interface is complex. A simpler approach is to just configure the return policy in the settings of your merchant account:
support.google.com/merchants/answer/1401...8037-3481869007&rd=1
By configuring it in your merchant account, you don't have to create an override of this view file. So, it will be easier to maintain in the long term. This possibility is why we didn't bother with implementing something for this in HikaShop.

3. For shipping details, you can configure the "Shipping" setting of the HikaShop Google Products plugin:
www.hikashop.com/support/documentation/8...google-products.html

The shipping rules for your product. Rules must be separated by a comma. Each rule has four variables separated by a colon. For example, if you want two shipping methods for France, a standard one at 5 euros and an express one at 10 euros you should write: FR::Standard:5.00 EUR,FR::Express:10.00 EUR . If you enter here the column name of a custom product field, it will use the value of the custom field for each product allowing you to have different shipping rules for each product.

With it, you can provide shipping fees globally or per product and this will be provided to Google via your product feed generated by the Google Products plugin. However, this won't be added to the JSON-LD output by show_microdata.php as this is not supported for now.
However, similarly to the return policy, it's also possible to configure your shipping fees directly in your merchant account:
support.google.com/merchants/answer/1257...1815-1460720483&rd=1
So that's the approach I would normally recommend.

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum