WC_Data Family Trees


When digging in on a specific project, it’s helpful to have a clear idea of the existing class structure before looking for avenues of customization. Make a note of the complexity of each class structure. This will play a key role in our decision on how to customize a given family’s behavior In this topic we’ll discuss each of the WC_Data family trees, including:


Key Patterns to Observe

  • Many Classes implement a legacy class as a direct descendant of WC_Data. These classes hold backward compatible functionality However, their methods are deprecated and will throw a Notice.
  • Several descendants of WC_Data implement the ArrayAccess interface, allowing developers to interact with the object’s properties using both object notation and array notation
  • The WC_Data families range from very complex (e.g. Products) to very simple (e.g. Coupons), however, they all share the common features of:
  1. They are all extendable*
  2. They all interact with data stores, which can be customized*

*The techniques and limitations of these customizations are discussed in the next topics

Product Classes

Order Classes

Order Item Classes

Coupon Classes

Payment Token Classes

Customer Classes

Customer Download & Download Log classes

Shipping Zone Classes

Webhook classes


Now that you can see where there’s simplicity in the system, and where it’s complex. Complex families are typically loaded through factories, which can actually simplify the customization process. While simple families are usually directly loaded, causing us to default to filter and action hooks for customization

Next, we get into some of the good stuff: the filter and action hooks that are available to developers to make low-level adjustments throughout the behavior of the WC_Data classes.

But first, let’s review a little

Knowledge Check

Hint: You can zoom into any of the diagrams using CTRL+click


Keyboard shortcuts

CTRL+Shift+F Search slideshow
F Fullscreen view
CTRL+Click Zoom in
Esc Topic overview
Right arrow,
Down arrow
Next slide
Left arrow,
Up arrow
Previous slide

Color codes

Hover over text more additional info
Link to an external resource
Link to an internal slide
If buttons aren't working, click in the screen to "focus" your browser