Site logo

[Resolved] WooCommerce product list layout

Home Forums Support [Resolved] WooCommerce product list layout

Home Forums Support WooCommerce product list layout

  • This topic has 27 replies, 2 voices, and was last updated 5 years ago by Leo.
Viewing 15 posts - 1 through 15 (of 28 total)
  • Author
    Posts
  • #543459
    Vincenzo Quarta

    Hi,
    can I obtain a Woocommerce product list layout like this https://gyazo.com/79d205fb19e08e43aae85b06767250e3 with price and buy button on right?
    Thanks.

    #543580
    Vincenzo Quarta

    I’m editing post for screenshot link.
    Thank you.

    #544201
    Tom
    Lead Developer
    Lead Developer

    It should be possible.

    First, I would set the image alignment to the left in Customize > Layout > WooCommerce.

    Then if you can link me to your site, I may be able to do the rest with CSS.

    Let me know ๐Ÿ™‚

    #544243
    Vincenzo Quarta

    Thank you Tom,
    can I send you the link by email? ๐Ÿ˜‰

    #544594
    Tom
    Lead Developer
    Lead Developer

    If you edit your original post in this topic, you’ll see a URL field which only admins can see ๐Ÿ™‚

    #544635
    Vincenzo Quarta

    Done!

    #544879
    Tom
    Lead Developer
    Lead Developer

    Alright, the HTML needs tweaking a bit.

    Let’s add this function:

    add_action( 'after_setup_theme', 'tu_move_wc_elements' );
    function tu_move_wc_elements() {
        remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
        add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_price', 30 );
    
        add_action( 'woocommerce_after_shop_loop_item', 'tu_before_wc_items', 7 );
        add_action( 'woocommerce_after_shop_loop_item', 'tu_after_wc_items', 40 );
    }
    
    function tu_before_wc_items() {
        echo '<div class="wc-items-container">';
    }
    
    function tu_after_wc_items() {
        echo '</div>';
    }

    Once we do that, the CSS should be a lot easier.

    Let me know ๐Ÿ™‚

    #544959
    Vincenzo Quarta

    Done, I added the function!

    #545612
    Vincenzo Quarta

    Sorry Tom,
    I added the function but it only put the price below the button.
    Do you need to work more on CSS?
    Thank you. ๐Ÿ™‚

    #545934
    Tom
    Lead Developer
    Lead Developer

    Yes, sorry! More complicated than I had hoped.

    I had it working, but wasn’t super happy with the code to achieve it.

    I just adjusted the PHP above – can you replace the code you added with it?: https://generatepress.com/forums/topic/woocommerce-product-list-layout/#post-544879

    That should give it a container which we can target better.

    Let me know ๐Ÿ™‚

    #546003
    Vincenzo Quarta

    Hi Tom,
    code replaced!

    If you can be useful this is a site that uses the layout that I would like (https://courseroot.com) but does not use WooCommerce.

    I also saw a theme that allows me to have that layout with Woocommerce but I love Generatepress! ๐Ÿ™‚
    Thank you

    #546440
    Tom
    Lead Developer
    Lead Developer

    Give this a shot:

    @media (min-width: 769px) {
        .archive li.product {
            display: flex;
        }
    
        .archive .woocommerce-LoopProduct-link.woocommerce-loop-product__link {
            flex-grow: 1;
        }
    
        .archive .wc-items-container {
            min-width: 200px;
            text-align: center;
        }
    }

    Depending on the browsers you need to support, you might want to run that code through this tool: https://autoprefixer.github.io/

    #547242
    Vincenzo Quarta

    Thank you Tom, code works fine!
    Can I align title and short description to top and increase price font size?
    Thank you

    #547564
    Tom
    Lead Developer
    Lead Developer

    The CSS seems to be broken right now. display: flex is missing in the CSS I provided.

    #548497
    Vincenzo Quarta

    Hi Tom,
    I restored display flex and I added some customization.
    But sometimes in pagination the container is smaller then other page.
    I edit original post with url.

    Let me know ๐Ÿ™‚

Viewing 15 posts - 1 through 15 (of 28 total)
  • The topic ‘WooCommerce product list layout’ is closed to new replies.