Archived topic
Overwrite WC List loop item with custom Block element
4 replies · Started by Patrick on January 30, 2022
Hi Support,
First of all thank you for GeneratePress - you are doing a great job! I just started with it and already know I will migrate nearly all my websites to GP.
Now my question. My customers need a unique WooCommerce List Item design (with Dokan Multivendor fields included etc.) and I thought perhaps I can create it with your Block Element? But I am struggling to find the right way to overwrite the WC template.
I copied the woocommerce/templates/product-content.php template to my child-theme/woocommerce/ folder and placed a custom hook "myawesomehook_wc_list_item" inside the template, and removed all the WC hooks. But I can't find my custom hook. Then I checked your code and realized you are registering available hooks via "get_available_hooks()" in "gp-premium/elements/class-elements-helper.php", and there is no filter.
Do you have any idea how I could achieve a custom WC List Item design with GP? Or what would you recommend?
Thank you!
Hi Patrick,
Thank you for the kind words!
Once you’ve added your custom hook in the specific template, you may simply utilize that hook through Hook name “Custom Hook”.
You may refer to this screenshot for reference: https://share.getcloudapp.com/X6u8RpK2
But if you really this custom hook to appear in the drop down, you may try adding this custom snippet:
<?php
add_filter( 'generate_hooks_list', function($hooks){
$hooks['woocommerce-global']['hooks'][] = 'myawesomehook_wc_list_item';
return $hooks;
}, 99,1 );
?>
See this for reference: https://share.getcloudapp.com/BludG9m0
Either of the two should work. Hope this helps! :)
Hi Fernando,
I am sorry, I was just blind and didn't see the "custom hook" option even I read about it in your documentation.
Thanks for sharing this and the filter to add custom hooks to your selection! That's really helpful for the future.
I appreciate your fast and awesome support!
Thanks!
Patrick
Solved
You're welcome! Glad to have helped. Feel free to reach out if you'll need assistance with anything else! :)