I am facing a weird error after working on woocommerce templates. Issue is that I am seeing same reviews (reviews belonging to one particular product) across all the products, what ever the product page I open the reviews are same that of one particular product.I tried trashing that one product but the pattern has not changed and reviews are caught up from another product.
What I changed:
Initially my aim was to load the woocommerce templates from the custom plugin I am working based on woocommerce, I have copied the woocommerce templates into my plugin folder and used below code to call each template file separately.
function intercept_wc_template_meta($template, $template_name, $template_path) {
if ($template_name == 'single-product/meta.php') {
$template = um_product_path.'woocommerce/single-product/meta.php';
}
return $template;
}
add_filter('woocommerce_locate_template', 'intercept_wc_template_meta', 20, 3);
What came up:
After doing this for all the files I tried testing with var_dump($template)
and all the files are loading from my plugin successfully.
Finally there is an error in reviews part of product page.
For example if I have products A, B, C, D and there are 4 reviews for product A which are shown properly on product A page, the same 4 reviews of A are being displayed/overwritten for B, C, D also instead of their own reviews.
Have anyone faced this problem earlier? I am no sure what caused this error.
Consider to find out on which hook
meta.php
template part is added to page, unhook that and try to attach this template part on the same hook with late binding that is using priority > 10.woocommerce_locate_template
does not work for every thing.