Posted on

WooCommerce: Remove Link to Product @ Order Table

There is a slightly annoying thing on the WooCommerce Thank-You Page and WooCommerce emails. Users looking at the order table can actually click on the Products they just purchased and abandon the page before taking the action you want them to take (see image below).

So, I coded a simple PHP snippet to remove such links. As usual, 1 line of code is more than sufficient:)

The annoying hyperlink to the product on the WooCommerce order table
The annoying hyperlink to the product on the WooCommerce order table

/**
 * @snippet       WooCommerce Remove Product Permalink @ Order Table
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=20455
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.5
 */

add_filter( 'woocommerce_order_item_permalink', '__return_false' );

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert, WordCamp speaker and Internet marketer, Rodolfo Melogli has worked as a WooCommerce freelancer since 2011. He helps entrepreneurs and developers overcome their WooCommerce nightmares :) Rodolfo is the organiser of WordCamp Dublin, the Dublin WooCommerce Meetup, the Dublin Ecommerce Meetup and the Dublin WordPress Meetup. He enjoys interacting with people, travelling and chasing tennis & soccer balls. Of course, he loves pizza too.

22 thoughts on “WooCommerce: Remove Link to Product @ Order Table

  1. When using WC Subscriptions, the thank-you page also has a section titled “Related subscriptions” where the first column is labeled “Subscription” and links to the subscription. Any help getting this snippet to work for that, too? Thanks!

    1. Hello Will, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  2. Ciao Rodolpho,
    This snippet doesn’t appear to be working in WC 3.5.0 and WP 4.9.8

    Nice warm weather today! 🙂

    1. Hey Andrew, thanks for your comment! I’ve updated the snippet – let me know if this new version works 🙂

    2. Thanks for the help Rodolpho. I didn’t get a notification that you’d replied to this comment BTW. I just happened to have this tab open still and saw it this morning. The new snippet didn’t work either. I edited the functions.php file, tried it in Opera with the VPN function turned on and in a private window and the link to the cart contents was still active. I’m pretty sure it’s not something I’m doing wrong. The only thing I can see is that there’s no function in the new snippet, just the filter. Maybe that’s the problem or did WC just get less wordy?

    3. It works with me – so you have some conflict. Temporarily switch theme and disable every plugin but Woo – does the snippet work?

    4. Oh man that sounds like a struggle. I think the end result is a good idea but it’s not worth that much effort … yet 🙂 Thanks for your help though sir.

  3. Thanks Rodolfo, I’m getting an error in my logs: CRITICAL Uncaught ArgumentCountError: Too few arguments to function remove_permalink_order_table(), 2 passed in /wp-includes/class-wp-hook.php on line 286 and exactly 3 expected in /wp-content/themes/theme-child/functions.php:114
    What would you do to fix this please? Many thanks.

    1. Hey Jo, thanks so much for your comment! I just retested the snippet and I get no error – did you modify the snippet?

  4. Hi Rodolfo,

    thanks for this snippet! Works great!

    Do you know if there is a similar solution for the downloads table in case of digital products? The table contains the name of the product in form of a link to the product, and I need to remove this link, but could not find the corresponding hook. Thanks in advance!

    Cheers, Onno

    1. Onno, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  5. You are awesome, It worked

  6. Wonderful thank you

  7. I am trying to understand where do I add this snippet. Thanks!

    1. Hey Brigitte thanks for your comment! You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: http://businessbloomer.com/woocommerce-customization-hangout/. Hope this helps!

  8. PS – I did remove my that cart file and then realised that your snippet doesn’t work for the cart – obviously I was too enthusiastic to see that right away.
    Is there any way to remove the links from the products in the order table on the cart page? (apart from copying core files to child theme and editing them there)? I’d love that 🙂

    1. Ah Henriet, thanks for your 2 comments! Yes, the cart uses a different (yet, very similar) method. If you take a look at cart.php you will find the filter “woocommerce_cart_item_permalink”, which can be customised in a very similar way to the Order Table example. Hope this helps 🙂

    2. Hi Rodolfo! Sorry for the late reaction, but didn’t see your reply until I checked back on this page. Followed up on your hint and found the filter, combined it with the snippet you gave above and it works like a charm 🙂
      Made my day! Thanks a million, and wish you a great day and time in Chili, or where-ever you’re in South America now ^^.

    3. This is awesome. Thanks a lot Henriët!

  9. Hi Rodolfo 🙂
    Thank you so much for this snippet! Works great.
    I wanted to do this but I couldn’t find a similar snippet anywhere nor did I have enough coding abilities to do it myself… After a lot of searching on the internet I ended up by the last resort: editing the core files (yes, I copied them to my child theme first). That wasn’t a very great solution at all even though it worked. I knew that.
    This is so much better : no more tinkering with the cart file 😀
    ~Henriët *happy*

Questions? Feedback? Support? Leave your Comment Now!
If you're writing code, please wrap it between: [php] code_here [/php]

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.