Open bobbingwide opened 3 years ago
Is this simply because these themes add_theme_support( 'woocommerce' )?
In a nutshell, Yes. The WC_Template_Loader
class has different logic for when the current_theme_supports( 'woocommerce' )
and when it does not.
It turns out that the solution developed for https://github.com/woocommerce/woocommerce/pull/30013 appeared to hinder my ( current ) implementation when I tried adding the theme support.
So, rather than implementing that logic, I'm continuing as before, with workarounds to reintroduce the support for Reviews.
Adding the following into functions.php
seems to do the job.
Logic in wizzie_after_setup_theme()
/**
* Because we haven't added 'woocommerce' theme support we have to reimplement some of the logic that WooCommerce
* would have used. See the logic in WC_Template_Loader.
* For Reviews we reapply the Review tab logic.
* which means we need to implement the `comments_template` filter that replaces
* the normal comment form by WooCommerce's Reviews plus the 'Add a review' comment form.
*/
add_filter( 'woocommerce_product_tabs', 'wizzie_unsupported_theme_reapply_review_tab', 11 );
add_filter( 'comments_template', array( 'WC_Template_Loader','comments_template_loader' ) );
}
New filter function. Note this isn't internationalized.
function wizzie_unsupported_theme_reapply_review_tab( $tabs ) {
$tabs['reviews'] = [ 'title' => "Reviews", 'priority' => 30, 'callback'=> 'comments_template'];
return $tabs;
}
When I attempted to use the logic in PR 30013, the single-product template just displayed post_content
.
I needed most of the logic in unsupported_theme_product_page_init()
especially
unsupported_theme_product_content_filter()
which invokes the [product_page]
shortcode for the current post.
This is what it now looks like on https://woocommerce.wp-a2z.org/product/my-favourite-block-annotated/#reviews
When viewing a single product it should be possible to view customer reviews and add your own reviews. For the My Favourite Block - Annotated product there's a link to the #reviews tab, but there is no tab.
https://woocommerce.wp-a2z.org/product/my-favourite-block-annotated/#reviews
The Reviews tab does appear when using the Genesis-a2z or Storefront theme. Is this simply because these themes
add_theme_support( 'woocommerce' )
?