Home › Forums › WoodMart support forum › Product Layout Hooks
Product Layout Hooks
- This topic has 3 replies, 2 voices, and was last updated 9 months ago by
Hung Pham.
-
AuthorPosts
-
May 31, 2024 at 12:13 pm #569700
MikeParticipantHi,
i have construct a custom plugin to hide add to cart button and prices conditionally and everything is working fine. But my code is stop working if i enable a custom layout for product page.
Can you tell me what action should i use so my code will function with custom product layout?Here is a part of my code that is working when custom product layout is disabled.
/** Modify product page when non-purchasable or hide price & cart are enabled: hide price and/or add to cart button */ add_action('woocommerce_before_single_product', 'gb_npwp_modify_product_display'); function gb_npwp_modify_product_display() { global $product; $not_buyable = get_post_meta($product->get_id(), '_not_buyable', true); $hide_price = get_post_meta($product->get_id(), '_hide_price', true); if ($not_buyable === 'yes' || $hide_price === 'yes') { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30); if ($hide_price === 'yes') { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10); } } }
June 1, 2024 at 8:10 am #569893
Hung PhamKeymasterHi Mike,
Unfortunately, customization is out of basic support.
Thanks for understanding our limitations.
Regards,
June 1, 2024 at 9:44 am #569910
MikeParticipantWell if the customization is out of basic support, then you must listen to and implement major features request that needed and a considered e-commerce oriented theme should have. But anyway.
i don’t asked you to customize something for me. I just asked you what are the hooks that woodmart use to override the default woocommerce product template, because i need to use that action on my code. Is this clear to you?
June 3, 2024 at 6:37 pm #570299
Hung PhamKeymasterHi Mike,
First of all, I’m really sorry have taken long time to reply you due to the weekend.
In order for the custom code to work, you need to add 2 Hook elements to the single product layout, select
woocommerce_before_single_product
in one andwoocommerce_single_product_summary
in the other. Also, in the configuration of these elements, you need to turn off theClean actions
option, and not use theAdd to cart
element, since it will be displayed using a hook.Please refer to our documentation and let me know how it goes https://xtemos.com/docs-topic/custom-hooks-and-plugins-compatibility/
Regards,
-
AuthorPosts
- You must be logged in to create new topics. Login / Register