Home Forums WoodMart support forum Woodmart Theme hooks

Woodmart Theme hooks

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #541357

    leejay123
    Participant

    I want to display a button below the “visitor counter” on a product page.
    5d6e62588af8f66263ac098f99af9361

    I 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?

    #541428

    Hello,

    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.

    #541706

    leejay123
    Participant

    Ive created an html block
    [html_block id="11331"]
    https://vinylmasters-ltd.uk/?cms_block=contact-to-place-order-button-for-products

    I need to display this button to display below “15 People watching this product now!”
    The visitor counter. https://gyazo.com/378c931219a31fdce65d87bc16a5e592

    I also want this button to display within the quickview

    #541733

    leejay123
    Participant

    I’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 );

    #541750

    leejay123
    Participant

    I’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.
    // ==============================================================================

    #541753

    leejay123
    Participant

    I’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);

    #541808

    Hello,

    Such modification requires complicated code customization which is not covered by our support, sorry. Hope you can understand our limitations.

    Best Regards

Viewing 7 posts - 1 through 7 (of 7 total)