• Resolved lauracgeorge

    (@lauracgeorge)


    I’ve removed all the choices for “related products”, upsells, and cross-sells in every product I have on my site (I don’t like the way they format so gigantically, distracting the potential customer with shiny new things to look at, and distorting my pictures). Yet, two related products still show up at the bottom of each product page. Is there a line of code I could remove or something to get these to stop showing up?

    https://www.ads-software.com/extend/plugins/woocommerce/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hi, you can try below code at your theme functions.php:

    /*
    * 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);
    Plugin Contributor James Koster

    (@jameskoster)

    A slightly lighter solution (every byte counts!)

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

    thanks for the tips, james ??

    Thread Starter lauracgeorge

    (@lauracgeorge)

    Eep! I tried James’ solution and totally screwed everything up!

    I can’t get into my dashboard now. My site isn’t working.
    I just popped the remove action code into the functions.php and holy crapola, batman!
    Is there something I can do in ftp to fix this ASAP and get myself back up and running tonight? Clearly I need to hire someone to fix this little bit of code for me.

    Hi Laura, you can FTP and download your theme functions.php file, remove the newly added code, save and upload replace that.

    Hope it will get your site back.

    Thread Starter lauracgeorge

    (@lauracgeorge)

    Sweet! That was easy and I’m back in. Site functions. All is well. I’ll hire a developer to handle this issue for me. Lesson learned! Thanks Terry for the quick response!!

    You are welcome, Laura ??

    Have you tried below code (added to functions.php)?

    function wc_remove_related_products( $args ) {
      return array();
    }
    add_filter('woocommerce_related_products_args','wc_remove_related_products', 10);

    Thread Starter lauracgeorge

    (@lauracgeorge)

    I’m much too scared to do it myself, but I’m saving these snippets of code to send to whoever I hire to handle it. Asking around for good pros right now. Thanks for another option! Hopefully one will work and things will look awesome.

    Haha, ok. All the best, cheers!

    loosefast

    (@loosefast)

    terrytsang
    thanks for the code!

    caseythehost

    (@caseythehost)

    terrytsang’s code works great. Product Enquiry even works now for some reason.

    Doug

    (@douggraphicsolutiongroupcom)

    Hi, Terry

    It is not working for me; can you look further and advise?

    https://usasharp.graphicsolutiongroup.com/product/knife-rack-plastic/

    Thank you,
    Doug

    P.S. Do you know why there is extra <div> appearing that adds 87px of space after the product image?

    This code from James works just fine for me:

    remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 );

    Add it to your child themes functions.php

    Make sure you can acces your functions.php by ftp.
    In case after adding the code you can not acces your dashboard, go to functions.php by ftp and remove the code there.

    In my case non of that happened and worked like a charme!

    Annie

    The code added worked for me!!

    remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 );

    So thanks a lot for you ideas! ??

    James’ initial code is fine.

    Woo uses an action hook in the content-single-product.php file, which you can find in this path:
    wp-content>>plugins>>woocommerce>>templates>>content-single-product.php.
    You’ll notice around line 61 the section dealing with after single product summary, to which woocommerce_output_related_products is hooked.
    Removing that hook is the correct (and easy) way to get rid of those related products.

    Note:
    For those who had issues with the code. Dont edit that template file directly. the code below should go in your own functions.php file. Some times when you copy from the web and place into your code, depending on which editor you use, it can reformat quotes.
    make sure the code is exactly as it’s shown here, and dont forget the trailing semi-colon.

    /* Disable Related products on single product pages */
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20);
Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Remove "Related Products" from bottom of product pages’ is closed to new replies.