Archived topic
Diversify the way I can show a product in WooCommerce
5 replies · Started by Lars on June 15, 2022
Hi!
I would like to learn how to diversify the way I can design a product page i Generatepress. I am currently trying to learn how to implement a product picture in the Header Element, how can I do that?
And if I would like to rearrange, add and remove things in the product page, how can I do that without messing with the theme files but still be able to go beyond the customizable options that are offered in the Customizer?
Thanks
Lars
Hi Lars,
I am currently trying to learn how to implement a product picture in the Header Element, how can I do that?
This can be done with a block element page hero:
https://docs.generatepress.com/article/block-element-page-hero/
You can add a container block from GenerateBlocks:
https://docs.generateblocks.com/article/container-overview/
Then use the background image option and make it dynamic with featured images:
https://docs.generateblocks.com/article/container-overview/#backgrounds
https://docs.generatepress.com/article/dynamic-data/#dynamic-background
The steps are essentially the step of creating a block element page hero for single posts:
https://docs.generatepress.com/article/block-element-page-hero/#examples
And if I would like to rearrange, add and remove things in the product page, how can I do that without messing with the theme files but still be able to go beyond the customizable options that are offered in the Customizer?
This actually wouldn't be the theme file as WooCommerce plugin is responsible for the single product template. I would recommend Googling "modifying WooCommerce single product template".
Oh wow! This is a revolution.
Do you know how to retrieve the category hierarchy as a dynamic data. If I am selling a "Red Apple" and this is categorized inside of "Apples" and beyond that "Fruits", then the hierarchy i "Fruits / Apples / Red Apple". This string, is it available as a dynamic data?
Thank you.
Hi Lars,
It is possible, but there’s no in-built functionality in our products to retrieve category hierarchy in such a way. SEO plugins usually offer this functionality in form of Breadcrumbs. Here’s an article you may refer to for assistance: https://docs.generatepress.com/article/adding-breadcrumbs/
Hope this clarifies!
It does very much give me solution to my problem. Thank you!
Questions keep on coming. I am now aware that I can use WooCommerce hooks to implement data wherever I want to. Next question is how I retrieve a WooCommerce product description and put it as a dynamic data wherever I want. I can't seem to find that data in particular, should I be searching for something like "content" or similar?
Hi there,
if you're using GP Block Elements, then you can use a GP Dynamic Content block. It has a few options:
1. The Post Content - will return the product description
2. The Excerpt - will return the Short Description IF it is completed, otherwise it grab an excerpt of #1
Aside from that you can get the Post Title and Featured Image and some term data using the other blocks. But thats about it for now.
For greater detail and options to modify the single product:
1. Woo has a lot of Hooks and a lot of function callbacks - which you can see here:
https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
Note that the description is called inside one of the woo tabs by default. More info on tabs here:
https://woocommerce.com/document/editing-product-data-tabs/
2. For getting specific data outside a function then this guide explains:
https://www.businessbloomer.com/woocommerce-easily-get-product-info-title-sku-desc-product-object/
3. And if you really must then use a child theme to create your own single template: