WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce: remove related products info (27 posts)

  1. texins5
    Member
    Posted 2 years ago #

    I'm setting up WooCommerce for a very simple site with just a few products, and I'm trying to figure out how to remove the "related products" info that shows up on each product page.

    Each model is made for a specific type of car, and I don't want to confuse them by showing the other models available.

    http://ultimateshowstoppers.com/wordpress/shop/doorstopper-c34-ss/

    Has anyone else done this?

    Thanks!

  2. Lynn
    Member
    Posted 2 years ago #

    I just did this. This worked for me, and hasn't broken anything so far.

    Go to wp-content/plugins/woocommerce/woocommerce-hooks.php

    In the woocommerce-hooks.php file, comment out the following line (it is at line 51 in my version) under the comment After Single Products Summary Div:

    add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);

    Result:
    /* add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20); */

    Now I am trying to figure out how to format the single product page. It is pretty gross, very narrow for no reason. Given that there will only be one product on a detail page, it is really bad design to format that page with the tiniest thumbnail and a very narrow column. If you have any hints about fixing that formatting, please post!

  3. texins5
    Member
    Posted 2 years ago #

    Thanks! I just took that and modified slightly and put in my functions.php file in my child theme. I was a little worried about modifying the actual plug-in files, and I had already figured out how to remove the sidebar on all WooCommerce pages using a functions.php file, so I figured I could add it to that. Worked great!

    Here's what I put in my functions.php file, based on your suggestion:

    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);

    I think your product page layout will really vary depending on what theme you are using. From what I understand, WooCommerce looks great with some themes and not so great with others. I'm using TwentyEleven. Here's a link to one of my product pages, if you want to see how that theme looks with WooCommerce:

    http://ultimateshowstoppers.com/wordpress/shop/doorstopper-c34-ss/

    Still working on the site, but it's getting there.

  4. Lynn
    Member
    Posted 2 years ago #

    The site is really nice. Clean and simple.

    In WooCommerce you can override the use of the plugin's CSS, but that leads to other problems on the shop and category pages, so I think I need to work with the Woo CSS and the single product page itself. I'm using Genesis + ClipCart66 child theme.

    Best of luck with wrapping up your site. We all know that the last bit of work can take as long as the first 80%.

  5. WayLay Design
    Blocked
    Posted 2 years ago #

    @texins5 @Lynn

    Thanks for the code snippet. I didn't want to mod the core plugin either because of upgrades and all. Texins suggestion of adding it to functions.php worked perfectly. Thanks.

  6. sutenm
    Member
    Posted 2 years ago #

    How to resized related products for woocommerce plugin wordpress
    Find woocommerce\assets\css\woocommerce.css if you see

    .related ul.products li.product img, .upsells.products ul.products li.product img, .related ul li.product img, .upsells.products ul li.product img{
    height: auto;
    width: 100%;
    }

    edit width: 100%; to width: 30%; or other number you want to resized.

  7. arkatona
    Member
    Posted 2 years ago #

    Thank you very much as this helped me as well!!

  8. JanuszJG
    Member
    Posted 2 years ago #

    Thanks, useful information !

    I’m setting up web shop and I use the sommerce theme and the latest versions of WP and Woocommerce.

    What I want is not remove the Related Products but change it from left to right in de tab bar. It is very annoying if you open the product page that not immediately the Description is showing but instead Related Products.

    Where can I change this “order”

    See this example:
    http://www.rembrandtlights.com/?product=high-power-4-channel-led-flasher

    Thanks,

    Janusz

  9. jitenoswal1
    Member
    Posted 2 years ago #

    Hey JanuszJG Hi,

    1 Question for you can you please tell me how did you get the related products tab on each products page ??
    I want that feature on my site and I don't know how to enable it. You can see this example - http://wh10.droa.com/~c1182561/product/vitamin-c-cream/

  10. sschmitt
    Member
    Posted 1 year ago #

    Try this plugin:

    woocommerce-custom-product-tabs-lite

    There is also this code you can put in your themes functions.php file:

    http://pastebin.com/N39FFBgK

  11. venkatforphp
    Member
    Posted 1 year ago #

    I think this is useful to you,

    In woocommerce\templates\single-product\related.php page line no 29 like if ( $products->have_posts() ) : ?>

    <div class="related products">

    <h2><?php _e('Related Products', 'woocommerce'); ?></h2>

    <ul class="products">

    <?php while ( $products->have_posts() ) : $products->the_post(); ?>

    <?php woocommerce_get_template_part( 'content', 'product' ); ?>

    <?php endwhile; // end of the loop. ?>

    </div>

    <?php
    endif;

    if you comment on this code(put before the code /* and end with */), then that related products are not displayed in single product page.

  12. Jason Judge
    Member
    Posted 1 year ago #

    I've solved this same problem using a slightly different approach. Instead of removing the hook, I've just overridden the template in my theme. The related products are queried in the WooCommerce template, so overriding the template removes that overhead (and it was an overhead of several seconds for me, as the query was randomising up to 10,000 products, before picking five, and that was heavy lifting for the database).

    This method also means I can put my own alternative "related products" into the template.

    The template is:

    {your-theme}/woocommerce/single-product/related.php

    Just create an empty file in that location and the related products will be gone.

    -- Jason

  13. Murray644
    Member
    Posted 1 year ago #

    Thanks for this code- worked great!

  14. aroldoa
    Member
    Posted 1 year ago #

    I have seen so many posts on editing or hiding the Related Products code set for Woocommerce, but I need help moving only the Related Products to another area of my page... I am super new to Woo Commerce, I just can't for the life of me figure out how to move ONLY the related products section to another place on my page...

    Please help!!

  15. Popovski
    Member
    Posted 1 year ago #

    Anyone out there would be willing to help with woocommerce. My client wants the products listed on a single page with out showing the thumbnail product images. Is the an easy way to do that? Also, how can I display more details about a product on a "[recent_products per_page="12" columns="4" orderby="date" order="desc"]" type page? Thanks in advance!!!

  16. jjbbrr
    Member
    Posted 1 year ago #

    Another way to remove the related products from the bottom of a product page is by adding the following to your style.css:

    .related.products { display: none; }

  17. Jason Judge
    Member
    Posted 1 year ago #

    Although what Julian says is true - hiding elements using CSS does hide them visually - I would not recommend taking that approach in most instances.

    Making something not visible still involves creating it in the first place and delivering it to the browser. That still involves time and database queries, also transfer bytes. It is also still there in the page, so may still get indexed (you may or may not want that).

    In my case, generated the related items was adding over a second to each page generation. It really had to be stopped at source.

    -- Jason

  18. Jason Judge
    Member
    Posted 1 year ago #

    Popovski - you may be better starting a new thread. It sound like you are looking for a text-formatted product listing.

  19. crashjohnson
    Member
    Posted 1 year ago #

    Judge is correct in saying:

    Making something not visible still involves creating it in the first place and delivering it to the browser. That still involves time and database queries, also transfer bytes.

    His approach is good if you have thousands of products, like he does.

    If you don't though... the easiest way might be a twist on Julian's method.

    Another way to remove the related products from the bottom of a product page is by adding the following to your style.css:

    .related.products { display: none; }

    If you are going to use Julian's approach, don't modify the style.css file. modify the custom.css file, found in the same folder. There is also a place for that in the theme's settings on the dashboard.

    remember to FTP in and backup that file before a template update. Then replace after the update. Otherwise you will lose the changes.

  20. Brian
    Member
    Posted 1 year ago #

    The best way to do this is to *not* modify core files as stated above.

    Rather, add this to your functions.php file:

    function woocommerce_remove_related_products(){
        remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
    }
    add_action('woocommerce_after_single_product_summary', 'woocommerce_remove_related_products');

    Using this method, you will not lose any modifications when upgrading Woocommerce.

  21. Jason Judge
    Member
    Posted 1 year ago #

    Note also when brian420 says "your functions.php" he really does mean your functions.php and not the one you will find in any third-party theme, otherwise even that will be lost when the theme is updated.

    You will need to create a child theme of your own (which is very simple, and can inherit everything from its third-party parent theme) and modify that.

    Of course, you could be using your own custom theme already, but I strongly suspect you are not, as there is a lot of fluff that goes into a WooCommerce theme to make things work smoothly.

  22. awholelotofnothing
    Member
    Posted 1 year ago #

    @judgej

    If I'm not editing the theme's functions.php file, what do you mean by "your" functions.php?

  23. Jason Judge
    Member
    Posted 1 year ago #

    Yes, you edit the theme's functions.php, but ideally it is not a thirty-party theme that you will be upgrading from time-to-time. Instead, you can create your own child theme and you can do what you like with functions.php in there, without it being overwritten when the third-party theme is upgraded.

    However, make sure your child theme does not have the same name as any theme on the WordPress.com site, otherwise a careless update in the WordPress admin pages can overwrite your child theme from something from WordPress.com

  24. doublesharp
    Member
    Posted 1 year ago #

    Another option if you don't want to use a child theme is to use a functions plugin. The advantages of doing it this way is that you can change your theme without losing your customizations.

    If you bought Theme A and use it with WooCommerce and later decide you want to use Theme B, you don't have to create a new child them since the custom plugin is still active and loading the content of /wp-content/plugins/functions.php (though it has occurred to me that perhaps /wp-content/themes/functions.php would be a better fit)

    You can see an example on my site here http://justin.ag/technology/wordpress-plugins/wordpress-plugin-custom-functions-php/

  25. Brad Smith
    Member
    Posted 1 year ago #

    @Brian
    Thanks for posting the related items cart filter.
    Very much appreciated.

  26. sandayspinner
    Member
    Posted 1 year ago #

    I too am trying to remove the Related Products section, due to its rather arbitrary selection of "related" items.

    I am using Woocommerce with the Merchant theme from Woo on WordPress and all files and plugins are up to date.

    I added Brian's code snippet to my functions.php file but the Related Items have failed to do a vanishing trick.

    Example URL: http://www.sandayspinners.co.uk/product/knitpro-symfonie-straight-needles-35cm/

    Can anybody help, please?

    Alternatively - I'd be happy to keep Related Products if I had control over it. Am I missing a trick here? Because I cannot find a setting for the number of items to output and/or the categories to include. (Nor do I understand why this section exists, when there is the better Up Sell and Cross sell mechanism.) Any experienced users know how to do this?

    TIA

  27. sandayspinner
    Member
    Posted 1 year ago #

    My problem is solved. I eventually navigated to Woo site to find thispage
    http://wcdocs.woothemes.com/snippets/remove-related-posts-output/

    the code snippet there does the job beautifully

    /*
    * wc_remove_related_products
    *
    * Clear the query arguments for related products so none show.
    * Add this code to your theme functions.php file.
    */
    function wc_remove_related_products( $args ) {
    return array();
    }
    add_filter('woocommerce_related_products_args','wc_remove_related_products', 10);

Topic Closed

This topic has been closed to new replies.

About this Topic