[Resolved] Woocommerce products and use of generate blocks

Home Forums Support [Resolved] Woocommerce products and use of generate blocks

Home Forums Support Woocommerce products and use of generate blocks

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1637882
    Carsten

    Hi there, I want to make some design changes to my shop page, since it has only one product, it does not look good.

    I have read this topic about integration of woocommerce in generate blocks
    https://generatepress.com/forums/topic/generate-blocks/

    Here GP support wrote:

    You can enable the Gutenberg editor on Single Products like so:

    // WP 5.0 Woo 3.4.1 or later
    // Edit Woo Product with Gutenberg
    function db_enable_gutenberg_single_product($editable, $post_type) {
    	if($post_type == 'product'){
    		$editable = true;
    	}
    	
    
    	return $editable;
    }
    add_filter('use_block_editor_for_post_type', 'db_enable_gutenberg_single_product', 10, 2);

    But the shop page, is a custom link page, with no blocks. If I add a product block then I have two of the same product on the page, the product generated by the custom link, at the one generated in my block.

    So how can code aimed at products added as blocks be used to edit products on the product page, which are not added as blocks?

    Hope my question makes sense 😉

    Thanks

    #1637941
    David
    Staff
    Customer Support

    Hi there,

    first off in Woocommerce > Settings > Products – remove the page in the: Shop page field.
    This will stop Woocommerce setting your shop page as the Product Archive.

    Now your Shop page is a static page that you can build with blocks and Woocommerce shortcodes to create what ever layout you require.

    One thing you will need to do is add the following PHP Snippet:

    function return_to_static_shop_page() {
        return 'http://yourdomain.com/your-page/';
    }
    add_filter( 'woocommerce_return_to_shop_redirect', 'return_to_static_shop_page' );

    And change the URL http://yourdomain.com/your-page/ to your new static shop page. This will ensure any Return to Shop links that Woo generates will take you to your static page.

    #1638002
    Carsten

    Hi there, sounds great, thanks for the clarification!

    Regards
    Carsten

    #1638124
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.