• Skip to main content

Victor Font Consulting Group, LLC

Digital Business Strategists

Call Us Toll Free:

1-844-VIC-FONT (842-3668)

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Our Team
    • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network
You are here: Home / Code Snippet / Display Custom Fields in WooCommerce 2.1+

Display Custom Fields in WooCommerce 2.1+

By Victor M. Font Jr.
April 5, 20142 Comments

Genesis HTML5 "Return to Top" Tutorial

A popularly used feature in WooCommerce is the ability to access "hooks" to capture and display custom fields on the plugin's built-in pages. In fact, if you research how to do this on the web, you'll find source code examples similar to the following block all over the internet.

During the recent migration of the American RX website to a new server, the former developer provided this code block to be added to the new theme's functions.php file. American Rx is an Alabama-based compounding pharmacy that gained national recognition for topical pain creams used in the pain management of osteoarthritis, rheumatoid arthritis, degenerative joint conditions, fibromyalgia, tendonitis, neuropathy, and radiculopathy. In 2013 it launched a new division focused on the manufacture and distribution of hormone pellets, an increasingly popular treatment for hormone replacement therapy. A mandatory business requirement is to capture and display a customer's DEA number on each order. A DEA number is a number assigned to a health care provider (such as a medical practitioner, dentist, or veterinarian) by the U.S. Drug Enforcement Administration allowing them to write prescriptions for controlled substances.

The above code worked fine on the old website, but when ported to the new site, it does not work. The dea number is correctly captured in both the WordPress user_meta and post_meta tables. It just doesn't display on the order form. The difference between the two sites is that the old site uses WooCommerce 2.0 and the new site uses WooCommerce 2.1+.

WooCommerce 2.1+

In February 2014, WooThemes released WooCommerce 2.1, the Peppy Penguin. This release is a major rewrite of core functionality. As welcome and good as this release is, the documentation seems to be a little lacking. As I researched the issue of the non-displaying DEA number, I continually saw examples of the above code, which doesn't work any long. The same code above is even listed in source code repository owned by one of the WooCommerce developers. After reading through many posts, I finally came across this one on WordPress.org: https://wordpress.org/support/topic/custom-order-fields-changed-in-woocommerce-21. As a result, I changed the following section in the above code to that which is displayed below and can confirm that it absolutely works in WooCommerce 2.1+.

  • 1share
  • Facebook0
  • Twitter0
  • Pinterest0
  • LinkedIn1
  • Print
  • SMS0

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Reader Interactions

VictorFont.com runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Comments

  1. Hermes Alves

    March 8, 2015 at 10:48 am

    It’s possible to put a upload file field on admin order?

    Reply
    • Victor M. Font Jr.

      March 12, 2015 at 9:11 pm

      I don’t know what you mean by admin order.

      Reply

Toll free: 844-VIC-FONT (844.842.3668)

Send us an E-mail Fax: 919.205.4446

Accessibility Statement | Affiliate Marketing Disclosure | Capability Statement

Cookie Policy | Comment & Product Review Policy | Privacy Policy | Site Map | Terms & Conditions

Copyright © 2003–2021 Victor M. Font Jr.

Return to top of page
Cover image: 5 Things You Can Fix On Your Website In The Next Week To Increase Engagement

Attract New Customers Automatically for Free!

  • Learn how to use the Internet to attract REAL clients
  • Avoid the 3 big mistakes EVERYBODY makes
  • Put this system on AUTOPILOT with the tools the Pros use!

GET YOUR COPY!

This little ebook has helped hundreds of business professionals get real results.
Now it's your turn!

ebook lead capture
Privacy Policy
{"cookieName":"wBounce","isAggressive":false,"isSitewide":true,"hesitation":"","openAnimation":false,"exitAnimation":false,"timer":"","sensitivity":"","cookieExpire":"7","cookieDomain":"","autoFire":"","isAnalyticsEnabled":false}
We only use analytical cookies on our website that allow us to recognize and count the number of visitors, but they do not identify you individually. They help us to improve the way our website works. By clicking Accept you, agree to cookies being used in accordance with our Cookie Policy.OkNoCookie policy