I'm developing the research of the product in the shop page. I'm trying to create a drop down part containing some attribute filters. I'm using the blocks filters of Woocommerce without any plugin.
I think the only way to create a drop down page is coding, so I will create a div and put in that div all the filters that I need to show.
HERE IS THE PROBLEM: I don't know how to call these blocks in the php file.
I know that there is the possibility to use the function "do_blocks()", but it doesn't work. I wrote this in my archive-product.php file:
echo do_blocks('<!-- wp:woocommerce/attribute-filter {"attributeId":16,"headingLevel":4,"displayStyle":"dropdown","showFilterButton":true,"selectType":"single","heading":"Filtra per filter_name"} -->');
and I enquequed the script files which could be related to my attribute filter like this:
wp_enqueue_script( 'attribute-filter.js', 'wp-content\plugins\woocommerce\packages\woocommerce-blocks\build' );
wp_enqueue_script( 'attribute-filter-frontend.js', 'wp-content\plugins\woocommerce\packages\woocommerce-blocks\build' );
So the questions are:
- am I making a mistake in calling do_blocks() function?
- is there a function which enables me to call the filter by attribute in my php file?
- or maybe there is a simpler solution to create a drop down page containing all my filters?
Thank you!