• Resolved Krzysztof Planeta

    (@chrisplaneta)


    Hi

    I noticed that the “Related products” block outputs different HTML and can be styled differently than the rest of blocks. How can I add content to these blocks so that it is aware of the product it is in?

    I need it to output an inline script with product data, such as product name, sku, id, price, tax, shipping class, etc. \Data in every product needs to be different of course. Unfortunately I cannot find any actions or filters for modyfying their HTML. And inner blocks added inside the product blocks are unaware of the product they are in.

Viewing 1 replies (of 1 total)
  • Hi @chrisplaneta

    Thanks for reaching out!

    I noticed that the “Related products” block outputs different HTML and can be styled differently than the rest of blocks.

    Related Products is a section on some templates that pulls products from your store that share the same tags or categories as the current product.

    These products cannot be specified in the admin, but can be influenced by grouping similar products in the same category or by using the same tags.

    How can I add content to these blocks so that it is aware of the product it is in?

    I need it to output an inline script with product data, such as product name, sku, id, price, tax, shipping class, etc. \Data in every product needs to be different of course. Unfortunately I cannot find any actions or filters for modyfying their HTML. And inner blocks added inside the product blocks are unaware of the product they are in.

    Currently, WooCommerce doesn’t have a built-in feature to add custom content to these blocks. However, you can accomplish this using custom code.

    I did some research and found these articles could be a good starting point:

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘How to add dynamic content to products in the “Related products” block’ is closed to new replies.