• Resolved plenet10

    (@plenet10)


    Hello,

    I used the following code to enable the Gutenberg

    // enable gutenberg for woocommerce
    function activate_gutenberg_product( $can_edit, $post_type ) {
    	if ( $post_type == 'product' ) {
    		   $can_edit = true;
    	   }
    	   return $can_edit;
       }
       add_filter( 'use_block_editor_for_post_type', 'activate_gutenberg_product', 10, 2 );
       
       // enable taxonomy fields for woocommerce with gutenberg on
       function enable_taxonomy_rest( $args ) {
    	   $args['show_in_rest'] = true;
    	   return $args;
       }
       add_filter( 'woocommerce_taxonomy_args_product_cat', 'enable_taxonomy_rest' );
       add_filter( 'woocommerce_taxonomy_args_product_tag', 'enable_taxonomy_rest' );

    Is it possible to add WooCommerce Blocks to the products, I tried it on a test website where it did not work, it could be a problem with the code above or with WooCommerce Blocks. (I would like to get the list of all products working)

    Thanks in advance,

    Auke Hendriks

Viewing 15 replies - 1 through 15 (of 21 total)
  • Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    The first snippet there should allow you to use the block editor with products. Most likely it will just output the blocks into the “description” section of the single product page.

    What did you have mind for the second bit of code with the category and tag filters?

    Thread Starter plenet10

    (@plenet10)

    The first is the expected behavior, on my end it did not work.

    The taxonomy fields should now be exposed to the rest api. I will try it without those filters although I don’t think I will change the unexpected behavior. Thanks for replying!

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Are you wanting to add blocks to the product category and tags? As far as I know, that’s not currently possible. The infrastructure doesn’t exist to support that just now.

    The first snippet did enable the block editor on my test site. It outputs in the description “tab” down below the main product content.

    When you use that first snippet, does the block editor not show up at all?

    Thread Starter plenet10

    (@plenet10)

    So it does add the Gutenberg editor and I can use normal blocks even blocks from other plugins, it only behaves weird when it has to interact with WooCommerce Blocks. That is the root of the problem. Is there a way I can debug this more easily that visually and via Developer tools in the web browser?

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    I just gave the “All products” block a try on my test site and it did load on a single product page. Here’s a screenshot to show what I’m seeing.

    You could try seeing if this works with only WooCommerce and a default theme like Twenty Twenty active. My test site was running the Storefront theme.

    Thread Starter plenet10

    (@plenet10)

    Oke that always feels so strange that it works on somebody elses machine and not your own. I will look at the Developer console perhaps there is a message i missed.

    Thread Starter plenet10

    (@plenet10)

    This could have to do with the error i’m facing

    Im getting an 404 erro on GET https://127.0.0.1/wordpress/wp-content/plugins/woo-gutenberg-products-blocks/build/product-sale0badge.js?ver=7.0.0 Net::Err_Aborted 404 (Not Found)

    And when i add a woo-block

    GET https://127.0.0.1/wordpress/wp-json/wc/store/products?per_page=0&catalog_visibility=any&search=&orderby=title&order=asc&_locale=user net::ERR_CONNECTION_RESET

    Does this clarify a bit of the problem?

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hmmm…are the permalinks set to something other than “plain?”

    Thread Starter plenet10

    (@plenet10)

    Day and Name

    Thread Starter plenet10

    (@plenet10)

    And default for products

    Thread Starter plenet10

    (@plenet10)

    Another thing once the product “Auto Saves” with the broken block inside it, it won’t allow editing the product any more, it prints out the default no-connection error as if I was offline, go back to the admin screen, and I am back online.

    I disable every thing and changed to the 2021 theme, the issue unfortunately persists

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    That’s puzzling. Which web host are you using?

    Thread Starter plenet10

    (@plenet10)

    So the tests are done on local host, the software is made by bitnami. A easy way to host wordpress on your own computer.

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    I wonder if there may be something happening in the local server configuration that’s causing this. Can you recreate it on a live server using only WooCommerce, Blocks, and the Storefront theme?

    You may want to reach out to bitnami’s support for help too.

    Thread Starter plenet10

    (@plenet10)

    First off, thanks for taking the time to try and dignose this issue with me, I’m going to try it with the storefront theme, if that doesn’t work, a fresh installation of Bitnami

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Using Blocks inside Product Pages’ is closed to new replies.