• Skip to main content
  • Skip to primary sidebar

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

  • 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
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network

Display Custom Fields in WooCommerce 2.1+

April 5, 2014 By Victor M. Font Jr.

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+.

  • 2shares
  • Facebook0
  • Twitter0
  • Pinterest0
  • LinkedIn1
  • Print
  • SMS1

Filed Under: Code Snippet, Computers and Internet, How To, Plugins, Programming, Tutorial, WooCommerce, WordPress Tagged With: Code Snippet, Computers and Internet, How To, Plugins, Programming, Tutorial, WooCommerce, WordPress

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.

Primary Sidebar

Shopping Cart

Books

  • Ultimate Guide to the SDLC front cover The Ultimate Guide to the SDLC
    Rated 5.00 out of 5
    $74.95
  • Winning With WordPress Basics 2nd Edition Winning With WordPress Basics 2nd Edition $19.95

Recent Articles

  • Modern Scam Defense: How Consumers and Businesses Can Recognize and Stop Email, Phone, and Text Fraud
  • How to Write a PRD So Dense It’s Technically a Novel
  • Top 5 Plugin Names That Scare Our Legal Department
  • When Agile Meets Our 3-Year Waterfall Roadmap: A Love Story
  • Why Our Enterprise Needs 27 Stakeholders to Approve a Button Color Change

Top 10 Article Categories

Best Practice Code Snippet Computers and Internet Genesis How To Leadership Programming Servant Leadership Tutorial WordPress

 
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.