custom product fields woocommerce code example
Example: 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);