ISSUE: Brizy Beta 2.0.7 - Woocommerce Product Archive/Product page content duplicating with base theme
So I have made a Woocommerce Shop page named "My Store" and "store" as the page slug.
Then I assigned it in Woocommerce settings
I am also using the Brizy Starter Theme as the base theme,
Now I added a new Brizy page called My Store, then added the woocommerce products element to it.
Next, I made a Brizy template for my single product pages
Now the problem happens when using Brizy conditional templates with the Brizy Starter Theme.
The issue is that the product single adds Brizy content and Woocommerce content, and the Brizy HTML section gets added in the Description Tab of the product page. Strange.
So to fix the product page, without having to modified WC template files, I add woocommerce.php to my Brizy Starter Template theme folder. And added the following:
/*woocommerce.php*/
if ( ! class_exists( 'WooCommerce' ) ){
return;
}
get_header();
woocommerce_content();
get_footer();
/*functions.php*/
function brizy_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'brizy_add_woocommerce_support' );
However the Archive page is now broken :/
/* Add Woocommerce support */
function brizy_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
/*Get the last segment of the url*/
function getLastPathSegment($url) {
$path = parse_url($url, PHP_URL_PATH); // to get the path from a whole URL
$pathTrimmed = trim($path, '/'); // normalise with no leading or trailing slash
$pathTokens = explode('/', $pathTrimmed); // get segments delimited by a slash
if (substr($path, -1) !== '/') {
array_pop($pathTokens);
}
return "/".count($pathTokens) ."/". $pathTokens[0] ."/". $pathTokens[1] . "/" . end($pathTokens); // get the last segment
}
$segment = explode('/', getLastPathSegment($_SERVER['REQUEST_URI']));
$ctsegment = $segment[1];
$firstsegment = $segment[2];
$secondsegment = $segment[3];
$lastsegment = $segment[4];
/*get the page slug of the shop page*/
$shop_id = get_option( 'woocommerce_shop_page_id' );
$shop_slug = get_post_field( 'post_name', $shop_id );
// echo "ToT=". $ctsegment;
// echo " First=".$firstsegment;
// echo " Second=".$secondsegment;
// echo " Last=" . $lastsegment;
/*If the page is whatever you set it to be in WC settings */
if($firstsegment == $shop_slug):
if(!is_numeric($lastsegment)):
if($lastsegment != $shop_slug):
//echo "<br> TRUE1";
add_action( 'after_setup_theme', 'brizy_add_woocommerce_support' );
endif;
endif;
if($firstsegment != $shop_slug && !is_numeric($lastsegment)):
//echo "<br> TRUE2";
add_action( 'after_setup_theme', 'brizy_add_woocommerce_support' );
endif;
if($firstsegment == $shop_slug && is_numeric($lastsegment)):
if($ctsegment > 3):
//echo "<br> TRUE3";
add_action( 'after_setup_theme', 'brizy_add_woocommerce_support' );
endif;
endif;
endif;
Now all is working!
The above code check to see if the Current archive page is your shop page, and enable and disable the woocommerce support accordingly.
Now this is also assumed that you have your permalink structure as mine:
yourdomain/yourshopname/
yourdomain/yourshopname/productname
yourdomain/yourshopname/category/category-name
yourdomain/yourshopname/tag/tag-name
this is a dirty fix. Have you guys at brizy came across this problem?
-
Hi,
Thank you for going deeper into the problem. I forwarded this to the devs and they will look into it. If they have any comments we will get back to you with a message.
0 -
Any updates on this?
0 -
Unfortunately, I have no news in this regard. The internal issue created on this topic is still under the "open" label.
0
Please sign in to leave a comment.
Comments
3 comments