Answers for "how to add wc() function in my custom page"

PHP
0

how to add wc() function in my custom page

/**
 * Get custom single product page template for a category
 */

function my_custom_product_template($template, $slug, $name) {
    if ($name === 'single-product' && $slug === 'content') {
        global $product_cat;
        $temp = locate_template(array("{$slug}-{$name}-{$product_cat}.php", WC()->template_path() . "{$slug}-{$name}-{$product_cat}.php"));
        if($temp) {
           $template = $temp;
        }
    }
    return $template;
}

add_filter('wc_get_template_part', 'my_custom_product_template', 10, 3);
Posted by: Guest on October-17-2020

Code answers related to "how to add wc() function in my custom page"

Browse Popular Code Answers by Language