woocommerce-thumbToday is Thanksgiving here in the USA and I thought it would be appropriate to share the WooCommerce code snippets that I’m most thankful to have in my arsenal.

WooCommerce is great out-of-the-box but many times you need to customize it’s look and feel or functionality. The following code snippets will help you do both.

Customizing WooCommerce Content

WooCommerce has default text throughout the shopping experience that you may want to change. For instance, I recently built a site for a non-profit that didn’t want any mention of “cart”, “product”, or “order”. While this may be hard to change in some eCommerce systems, WooCommerce makes it pretty easy.

Change Add to Cart button text

This will change the button text for the “Add to Cart” inputs. Update the text to suit your needs.

Custom Add To Cart Message & Custom “Continue Shopping Link”

When you add a product to your cart a message appears with default text notifying you of the recent add and asking you to continue shopping. For some, this isn’t ideal. Here’s how to change that message:

Customizing WooCommerce Checkout

The checkout page is the most important page in your shop. It’s where you ask your customers to shell out their hard earned money to purchase your products. Why not spend a little extra time making it easier and better optimized to convert? Here’s several snippets I find myself using regularly to do just that.

Customizing Checkout Field Order

Sometimes the default ordering of fields isn’t optimal for your business. You can modify the order the fields appear by customizing the following function:

Change Default Checkout Country

A default install of WooCommerce may not have your preferred country selected. If you typically sell primarily to one country then it makes sense to set that country as the default.

Change Default Checkout State

If you are selling a product mainly locally it doesn’t make sense to ask the user to select the state. Manually set the state and make the checkout process easier.

Phone Field Not Required

The telephone number field is kinda silly to have as a required field. 99% of the time I don’t want people to call me and I don’t want to give them my phone number. I’ve had numerous clients ask me to make this field not required. Here’s the snippet I add:

Skip the Cart

This is probably one of my favorite snippets. Why? Because it makes checking out faster by removing the “Cart” page that appears prior to entering the checkout page. Many times, you don’t even need a cart page to display. Most times users are only shopping for a single product. The cart page adds an unnecessary step that users can bounce out from and abandon their cart. Skip the cart and increase conversions.

Custom Order Now Button Text

Sometimes you want to personalize the button text on the most important button in your entire shop: the “Order Now” button. This is the button that the user clicks when they’re ready to spend money. The money button.

Removing WooCommerce Elements

Depending on the site you’re building you may need to heavily customize WooCommerce. Thankfully it is very well documented and has tons of actions and filters for you to hook into. Here’s several snippets I find myself using all the time to remove elements found in a default WooCommerce implementation such as breadcrumbs, tabs, reviews and page headers.

Remove WooCommerce Breadcrumbs

Breadcrumbs are great, sometimes. Many designs don’t have them, so here’s how you get rid of them.

Remove WooCommerce Tabs

I’m not a fan of the tabs on WooCommerce product pages. I almost always from them using:

… adios tabs!

Remove Product Reviews

Product reviews can be great for some businesses, but many times my clients don’t want them. Thankfully, removing them is easy:

 Remove Sidebar from WooCommerce

Who needs a sidebar, anyways? For many designs I’ve built out into WooCommerce there hasn’t been a sidebar in the shop. Remove that bad boy:

Additional Woo Goodness

Here are a number of snippets that don’t fall in the categories above but are very useful.

Optimize WooCommerce Scripts

WooCommerce like to place all their scripts on every page of your site. You can tell it to load only on the shop pages using the following code. For more information see this article.

Custom Columns on Woo Orders Page (in admin)

Sometimes it’s useful to add additional custom column data to the standard order columns in the WordPress backend.

Auto-complete All Orders

If you sell digital products then you’re not shipping anything. You can autocomplete your orders using the following code:

 

Final Thoughts

As you can see WooCommerce is incredibly flexible and you can easily customize and remove various elements throughout the cart. If you have a snippet you think should be included please use the comments below!

Devin Walker is a San Diego-based WordPress Developer and enthusiast. He is the author of several popular and highly-rated WordPress themes and plugins. In his free time he enjoys playing Golf and traveling.

Follow Devin:

16 Responses to “15 WooCommerce Code Snippets that I’m Most Thankful For”

  1. Phill Coxon

    Awesome – thank you!

    Reply
  2. Eric Platt

    Here’s the code I found and used to remove reviews (placed in functions.php – might move it to a child theme). I this any better/worse than your example code?

    // Disable reviews

    add_filter( ‘woocommerce_product_tabs’, ‘woo_remove_product_tabs’, 98 );

    function woo_remove_product_tabs($tabs) {

    unset($tabs[‘reviews’]);

    return $tabs;

    }

    Reply
  3. The Church State Guy

    Awesome stuff, especially dequeueing the styles and scripts except on the pages. I added this to dequeue Amazon Advanced Payments (an awesome and free extension — for now):

    wp_dequeue_style( ‘amazon_payments_advanced’ );
    wp_dequeue_script( ‘amazon_payments_advanced’ );

    Reply
  4. Úmêr Çhêémẳ

    I like your blog very much.]i need help i want to generate
    woocommerce new order email when customer click on place order button.i
    tried it but not success ;(

    please tell me accurate way to generate email when click on place order with this also change status of order to complete.

    Thanks

    Reply
  5. John Mackin

    I tried to use the “Change Add to Cart Button text” snippet by adding it to the functions.php file in my child theme, but got no change on my web site. Does it need to go somewhere else? Thanks.

    Reply
  6. Din Bogdan

    Hi, i looking for snippets / code how list products ids for order, how make that ? where i find that…. thx

    Reply
  7. Mona Ali


    شركة تخزين عفش بالرياض


    شركة ترميمات بالرياض


    شركة دهانات بالرياض


    شركات تنظيف المنازل بجدة


    شركة كشف تسربات المياة بجدة


    شركة مكافحة حشرات في جدة


    شركة تنظيف خزانات بجدة


    شركات نقل عفش جدة


    شركات تنظيف منازل بجدة


    شركات رش المبيدات حشرية بجدة


    عزل بالرياض


    عزل اسطح
    الرياض


    عزل خزانات
    الرياض


    تنظيف خزانات
    بالرياض


    تصغير المعدة


    تكميم المعدة


    تدبيس المعدة


    جراح المرارة بالمنظار


    شركات مكافحة
    القوارض بالرياض


    شركة مكافحة حشرات بالرياض


    شركة رش مبيد بالرياض


    شركة عزل خزانات بالرياض


    شركة تخزين عفش بالرياض


    شركة تنظيف بيارات بالرياض


    شركة تخزين عفش بالمدينة المنورة


    نقل عفش بالمدينة المنورة


    غسيل خزانات بالمدينة المنورة


    نقل عفش جدة


    شركات مكافحة الحشرات في جدة


    شركة تنظيف بجدة


    شركات رش المبيدات الحشرية بجدة


    شركة مكافحة حشرات بالدمام


    شركات تنظيف المنازل بالدمام


    شركة تسليك مجاري بالدمام


    شركة المنارة لنقل العفشبالرياض


    نقل أثاث
    بالرياض


    nile7seo

    nile7

    nile7

    nile7

    Reply
  8. Ryan

    Nice post! Very helpful.

    BTW, what is the code display plugin that you’ve used on this post?

    Reply
  9. Kamlesh Nishad

    Hey your post really help me out. have little issue if you could help me it would be great. I want to make limitations on the purchase of products if the user fail to make minimum purchase they have to pay extra amount.

    Reply
  10. Justin Edwards

    The hook isn’t woocommerce_add_to_cart_message it is wc_add_to_cart_message.

    The code works flawlessly once the correct hook is called.

    Reply
  11. Robby Barr

    I’m sure this all works, but where exactly do I put these code snippets? Do you have to edit the code thats in the ftp woocommerce plugin files? Thanks.

    Reply
    • Jonathan Soifer

      01. Create a child theme. If you don’t know how to do this, just google it, it’s simple.
      02. Within your child theme, one of the files is functions.php, insert those codes there.

      Reply
  12. Eric Arrington

    Awesome list. Just used three of them on my new ecom site. Thanks.

    Reply

Leave a Reply