May 29, 2023

Remove WooCommerce Checkout Fields for Virtual Products with Code Snippets

Play Video

What is the tutorial about?

Brought to you by the Web Squadron, this tutorial focuses on how to remove WooCommerce checkout fields for virtual products with the help of Code Snippets. It’s a simple, yet impactful change that can streamline the checkout process for your customers, making their shopping experience smoother and more enjoyable. This tutorial is perfect for those who deal with virtual products on their WooCommerce platform and want to optimize their checkout process.

Tutorial Steps

  1. Install the Code Snippets Plugin:
    Navigate to your WordPress dashboard. Under the “Plugins” section, click on “Add New”. In the search bar, type “Code Snippets”. Once you find the plugin, click “Install” and then “Activate”.
  2. Create a New Snippet:
    After the plugin is activated, return to your WordPress dashboard. Find the “Snippets” section and click on “Add New”.
  3. Copy the Required Code:
     * Snippet Name:    WooCommere Remove Checkout Billing Fields For Virtual Products
     * Snippet Author:
    add_filter( 'woocommerce_checkout_fields' , 'ecommercehints_remove_checkout_billing_fields_if_virtual_product' );
    function ecommercehints_remove_checkout_billing_fields_if_virtual_product( $fields ) {
       $only_virtual_in_cart = true; // If there is a physical product too, don't remove the fields
       foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
          if ( ! $cart_item['data']->is_virtual() ) {
              $only_virtual_in_cart = false;
        if ($only_virtual_in_cart) {
         return $fields;

    Source: Code Snippets

  4. Paste the Code into the Snippet:
    Return to your WordPress dashboard and paste the copied code into the new snippet you created. After pasting, click “Save Changes” and then “Activate”.
  5. Verify the Changes:
    Now, revisit the checkout page for your virtual product. You’ll see that the number of fields has been significantly reduced, simplifying the checkout process.

Use Cases for this Tutorial

  • Digital Product Stores:
    If your store sells digital products like eBooks or online courses, this tutorial can help you optimize your checkout process.
  • Service-Based Businesses:
    For businesses offering non-physical services such as consulting or coaching, this tutorial can simplify your client’s checkout experience.
  • Subscription-Based Platforms:
    If you operate a subscription-based platform where physical delivery isn’t required, this tutorial can make the subscription process more user-friendly.

Required Resources

WooCommerce Logo
Free Options
Code Snippets Logo
Free Options
Credit to Web Squadron
Web Squadron is a popular YouTube channel dedicated to providing informative tutorials, tips, and insights on web development and design. With a strong focus on WordPress and website builders like Bricks Builder, the channel aims to help users of all skill levels, from beginners to advanced developers, create and optimize their websites. By offering easy-to-understand, step-by-step guidance, Web Squadron provides practical and valuable content.
Remove WooCommerce Checkout Fields for Virtual Products with Code Snippets
Welcome back!
Enter your Helwp credentials to sign in.

No Account yet? Sign Up

My Account
Give Feedback
Describe your feedback *
Rate Helwp
Problem *
Describe the problem
Want us to reply?
Your E-Mail
Affiliate Disclosure

At Helwp, we’re committed to transparency and honesty. Therefore, we want to inform you that some of the links on our website are affiliate links. This means that, at no additional cost to you, we may earn a small commission if you click through and make a purchase.

We only promote products or services that we genuinely believe in. These affiliate commissions help us to maintain the website and continue to provide you with free, high-quality WordPress content.

If you are interested in how you can support us even further, check out our support page.