Home › Forums › WoodMart support forum › Woodmart Theme hooks
Woodmart Theme hooks
- This topic has 6 replies, 2 voices, and was last updated 1 year, 5 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
February 19, 2024 at 2:32 pm #541357
leejay123ParticipantI want to display a button below the “visitor counter” on a product page.
5d6e62588af8f66263ac098f99af9361I have this code: <?php echo do_shortcode(‘[html_block id="11331"]‘); ?>
Where can I place it?Also, How can I add the “visitor counter” to the quick view?
February 19, 2024 at 5:07 pm #541428
Aizaz Imtiaz AwanKeymasterHello,
Can you please share some screenshots where you want to add a button. And also tell us which type of button you want to add.
Best Regards.
February 20, 2024 at 12:08 pm #541706
leejay123ParticipantIve created an html block
[html_block id="11331"]
https://vinylmasters-ltd.uk/?cms_block=contact-to-place-order-button-for-productsI need to display this button to display below “15 People watching this product now!”
The visitor counter. https://gyazo.com/378c931219a31fdce65d87bc16a5e592I also want this button to display within the quickview
February 20, 2024 at 12:58 pm #541733
leejay123ParticipantI’ve added the following code to my child theme’s functions.php file to display the HTML block shortcode content above the product meta details but below the visitor counter and it works.
function custom_output_between_counter_and_meta() {
if ( is_product() ) {
echo do_shortcode(‘[html_block id="11331"]‘);
}
}// Assuming the visitor counter is indeed at 38, and meta starts at 40,
// placing this at 39 should theoretically work, but if it doesn’t,
// it means we might need to closely inspect the priorities or the execution order.
add_action( ‘woocommerce_single_product_summary’, ‘custom_output_between_counter_and_meta’, 39 );February 20, 2024 at 1:20 pm #541750
leejay123ParticipantI’ve incorporated a second snippet into my child theme’s functions.php file that specifically injects a shortcode into the Quick View modal while ensuring it does not appear on the single product pages.
// ==============================================================================
// Adds Shortcode Specifically for Quick View Modal, Excludes Single Product Page
// ==============================================================================
function custom_add_shortcode_to_quick_view() {
// Trigger only for AJAX requests to ensure execution in Quick View modals.
if ( wp_doing_ajax() ) {
// Output the shortcode. Adjust ‘[html_block id="11331"]‘ as needed.
echo do_shortcode(‘[html_block id="11331"]‘);
}
}// Hook into WooCommerce product summary at a strategic point.
// Priority 22 positions the shortcode right below the product attributes.
add_action(‘woocommerce_single_product_summary’, ‘custom_add_shortcode_to_quick_view’, 22);// ==============================================================================
// Note: Adjust the priority if necessary to align with your theme’s structure.
// Quick View modals must be loaded via AJAX for this to function correctly.
// ==============================================================================February 20, 2024 at 1:46 pm #541753
leejay123ParticipantI’ve incorporated a third snippet into my child theme’s functions.php file that specifically Displays Visitor Counter in Quick View Modal
// ==============================================================================
// Display Visitor Counter in Quick View Modal
// ==============================================================================
function add_visitor_counter_to_quick_view() {
// Check for Quick View context via AJAX request
// Adjust the condition to match your Quick View AJAX action identifier
if ( isset($_REQUEST[‘action’]) && ($_REQUEST[‘action’] == ‘woodmart_quick_view’) ) {
// Call the function to display the visitor counter
// Ensure this correctly references your counter display function
XTS\Modules\Visitor_Counter\Main::get_instance()->output_count_visitors();
}
}// Hook into the WooCommerce single product summary to add the visitor counter
// Adjust the priority as needed to position the counter within the Quick View
add_action(‘woocommerce_single_product_summary’, ‘add_visitor_counter_to_quick_view’, 38);February 20, 2024 at 3:53 pm #541808
Aizaz Imtiaz AwanKeymasterHello,
Such modification requires complicated code customization which is not covered by our support, sorry. Hope you can understand our limitations.
Best Regards
-
AuthorPosts
- You must be logged in to create new topics. Login / Register