• Resolved dyrgutt

    (@dyrgutt)


    Hi all,

    Just starting my WooCommerce Store journey (and WP for that matter) and can’t figure out why the shop’s header [store nav area] isn’t showing?

    The entire store functions as expected, but when I attempt to override single-product.php – and I mean a copy without any modifications made to it, yet – the product page shows (with some small styling issues) but the header, sidebar, footer sections do not appear?

    The caveat is – I’m trying to do it from a custom plugin with:

        function load_custom_product_template($template) {
            global $post;
        
            $product = wc_get_product($post->ID);
            if ($product && $product->get_type() === 'extended') {
                $custom_template = plugin_dir_path(__FILE__) . 'woocommerce/single-product.php';
        
                if (file_exists($custom_template)) {
                    return $custom_template;
                }
            }
        
            return $template;
        }
        add_filter('template_include', 'load_custom_product_template');

    So, other than the single-product.php – do I have to copy a ‘header.php’ & ‘footer.php’ from somewhere – I can’t find anything header/footer related in woocommerce and after searching the forum, people have mentioned it’s controlled by the theme anyways; which does appear to be correct, as Query Monitor lists these under templates used:

    \wordpress\wp-includes\theme-compat\header.php | footer.php

    -but even when attempting to override the template via my theme (with the plugin disabled), i.e.:

    …themes\twentytwentyfour\woocommerce\single-product.php OR …themes\twentytwentyfour\woocommerce\single-product\single-product.php [tried both]

    It still doesn’t have any effect.…so how does WooCommerce do it then? Many thanks for any help or advice in advance, Cheers Dyr

    Versions: WP: 6.5.3? |? Woocommerce 8.8.3? |? Theme: twentytwentyfour

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @dyrgutt

    For reference, this particular forum is meant for general support with the core functionality of WooCommerce itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.

    Thread Starter dyrgutt

    (@dyrgutt)

    Thank you so much @shameemreza – I will definitely check those links/support sources out ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Override ‘single-product.php’ Successfully?’ is closed to new replies.