CS-Cart JSON-LD schema modifications

Hello everyone,
I have noticed that the schema.org JSON-LD structured data is being added in the products page by using the SEO add-on. It’s really good that it’s already adding the most basic data to make the products visible in Google.
However, I was not able to find anywhere to add more fields or modify this data. I have tried to find a way to do this with My Changes add-on but it seems more complicated than this.
Basically, what I want to do is to add the shipping weight attribute to this structured data. Is there an easy way to do this. Or is there an add-on which allows me to modify or add more data to this json.

Any help or idea is appreciated…

You can use the My changes module and hook in the following file

design/themes/responsive/templates/addons/seo/hooks/products/view_main_info.pre.tpl

Hello ecomlabs,
Thank you very much for replying to this topic. Would you be able to give me an example code on how to add a hook and obtain the product weight? Or do you guys have an add-on which allows me achieve the thing that I am trying to do?
Thanks in advance

I’d like to clarify the template you may want to check:
design/themes/responsive/templates/addons/seo/hooks/index/meta.post.tpl

And also the hook that you can use to extend the existing json-ld paramaters:

    /**
     * Executes when getting product Schema.org markup items, right before returning result,
     * allows you to modify the created markup items.
     *
     * @param array  $product_data Product data to get markup items from
     * @param bool   $show_price   Whether product price must be shown
     * @param string $currency     Currency to get product price in
     * @param array  $markup_items Schema.org markup items
     */
    fn_set_hook('seo_get_schema_org_markup_items_post', $product_data, $show_price, $currency, $markup_items);

Here is the article on how to use hooks:
https://docs.cs-cart.com/latest/developer_guide/addons/hooking/php_hooks.html#how-to-use-a-php-hook

Hello cs cart team and ecomlabs,

Seems like “design/themes/responsive/templates/addons/seo/hooks/products/view_main_info.pre.tpl” is using the old itemprops microdata pattern and as of 4.11.4 is now deprecated. However I have tried adding itemprop only to my products in my website and I have tried it with Google’s https://search.google.com/test/rich-results test page but sadly those are not recognized. So it seems like my only option is to somehow modify or extend the JSON+LD data which is a the bottom of the page.

I am not an official add-on developer and have only tiny knowledge with php. So far I have only used my changes add-on to add some custom features to my website and to my products. So I have never used php hooks, only worked with tpl hooks.

Can I use this hook “seo_get_schema_org_markup_items_post” with my my changes add-on? Do you have a relevant documentation regarding that? Would you be able to help me getting and adding the “shipping_weight” for my products inside JSON+LD schema?

Thanks in advance

Yes, it is possible with php hooks. Please find details here

https://docs.cs-cart.com/latest/developer_guide/addons/hooking/php_hooks.html#how-to-use-a-php-hook

1 Like

Sadly, I have no experience of php and I have no time to invest in this. If there is a modifiable solution or a ready add-on I would be willing to purchase. Thanks for the help anyway.

I am afraid, there is no ready-to-use solution to show shipping weight in the snippets.

We can make it on the paid basis. Feel free to contact us

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.