I too am experiencing this.
I have enabled the Gutenberg editor for WooCommerce products using the below code.
function wplook_activate_gutenberg_products($can_edit, $post_type)
{
if ($post_type == 'product') {
$can_edit = true;
}
return $can_edit;
}
add_filter('use_block_editor_for_post_type', 'wplook_activate_gutenberg_products', 10, 2);I am now unable to remove these blocks.
This update has also broken my custom content-single-product.php
I also have the below code to add WooCommerce categories to the body class, which is now throwing an error.
add_filter('body_class', 'wc_cat_names');
function wc_cat_names($classes)
{
if (is_product()) {
global $post;
$terms = get_the_terms($post->ID, 'product_cat');
foreach ($terms as $term) {
$classes[] = $term->slug;
}
}
return $classes;
}Warning: Invalid argument supplied for foreach() in /Users/EXAMPLE/Development/local/wp-content/themes/EXAMPLE/inc/woocommerce.php on line 287
Hello, thanks for reporting this. We added a template to the “product” post type, which might be interfering with your customization. The template can be removed using a filter like this:
add_filter('woocommerce_register_post_type_product', function( $args ) {
unset( $args['template'] );
return $args;
});Note however that this template also exists in WooCommerce 7.6.1, so if things worked fine in that version there might be another root cause for the behavior you’re seeing.
Hello
You can find a solution here :
(see Cameron answer)
function reset_product_template( $post_type_args ) {
if ( array_key_exists( 'template', $post_type_args ) ) {
unset( $post_type_args['template'] );
}
return $post_type_args;
}
add_filter( 'woocommerce_register_post_type_product', 'reset_product_template' );I hope this solution will be stable, the next updates are freaking me out a bit.
Question: is it Woocommerce’s will to prevent us from using Gutunberg which has become a WordPress standard? Incomprehensible not being able to activate Gutunberg properly in 2023 in Woocommerce!
If we have to pay for an option to activate Gutunberg let us know.
I don’t dare activate it for my next clients (fortunately I’m testing it on my own site). At some point the old editor just isn’t enough. My clients also take paid Woocommerce options… I need to trust the solution I’m selling.
- This reply was modified 1 hour, 7 minutes ago by Kuroweb.
Thanks for update, my website is on https://batoaneproteice.ro/
everything works perfectly
