PHPackages                             xwoo/data-type - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xwoo/data-type

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xwoo/data-type
==============

A library for working and standardizing working with WooCommerce data types.

v1.4.1(1mo ago)126[1 issues](https://github.com/x-wp/wc-data-type/issues)2GPL-3.0-or-laterPHPPHP &gt;=8.0CI passing

Since Mar 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/x-wp/wc-data-type)[ Packagist](https://packagist.org/packages/xwoo/data-type)[ Docs](https://extended.woo.rs)[ GitHub Sponsors](https://github.com/seebeen)[ RSS](/packages/xwoo-data-type/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (27)Versions (22)Used By (2)

WC Data Type
============

[](#wc-data-type)

### Model-driven custom data objects for WooCommerce

[](#model-driven-custom-data-objects-for-woocommerce)

[![Packagist Version](https://camo.githubusercontent.com/a5b021f6d1ffe2f8a5b7d91514f1b61c3b2131dd7646d8bdcbdb8ff4237cf139/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f782d77702f77632d646174612d747970653f6c6162656c3d52656c65617365267374796c653d666c61742d737175617265)](https://packagist.org/packages/x-wp/wc-data-type)[![Packagist PHP Version](https://camo.githubusercontent.com/edf8ab0275b002e38202f21110a1fcaa7b62020f21256bf6f21c77d5460d0c8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f782d77702f77632d646174612d747970652f7068703f6c6162656c3d504850266c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6f676f53697a653d6175746f267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/edf8ab0275b002e38202f21110a1fcaa7b62020f21256bf6f21c77d5460d0c8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f782d77702f77632d646174612d747970652f7068703f6c6162656c3d504850266c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6f676f53697a653d6175746f267374796c653d666c61742d737175617265)[![Static Badge](https://camo.githubusercontent.com/7be7af0284a72836b9704a9175b22941064f2f75103093077829e5ef6538ab5e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f57502d253345253344362e392e342d3338353865393f7374796c653d666c61742d737175617265266c6f676f3d776f72647072657373266c6f676f53697a653d6175746f)](https://camo.githubusercontent.com/7be7af0284a72836b9704a9175b22941064f2f75103093077829e5ef6538ab5e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f57502d253345253344362e392e342d3338353865393f7374796c653d666c61742d737175617265266c6f676f3d776f72647072657373266c6f676f53697a653d6175746f)[![Static Badge](https://camo.githubusercontent.com/1096617f99162265b3f4af7dbbebc42f0de54d2e08efb0f1fd10239efde1428c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f57432d25334525334431302e362e312d3766353462333f7374796c653d666c61742d737175617265266c6f676f3d776f6f636f6d6d65726365266c6f676f53697a653d6175746f)](https://camo.githubusercontent.com/1096617f99162265b3f4af7dbbebc42f0de54d2e08efb0f1fd10239efde1428c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f57432d25334525334431302e362e312d3766353462333f7374796c653d666c61742d737175617265266c6f676f3d776f6f636f6d6d65726365266c6f676f53697a653d6175746f)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/d9f9e1062a43b669ae2fd49967ef24ef0d44879198e88c27b3b50b53bd6be58e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f782d77702f77632d646174612d747970652f74657374732e796d6c3f6c6162656c3d5465737473266576656e743d70757368267374796c653d666c61742d737175617265266c6f676f3d676974687562616374696f6e73266c6f676f436f6c6f723d7768697465266c6f676f53697a653d6175746f)](https://github.com/x-wp/wc-data-type/actions/workflows/tests.yml)

This library provides a standardized way to define and work with custom WooCommerce-style data objects. Define a model once, then reuse consistent property handling, factories, queries, and data-store behavior around it.

Key Features
------------

[](#key-features)

1. Model-driven setup: Define object shape with the `#[Model]` attribute.
2. WooCommerce-style objects: Extend `XWC_Data` and keep a familiar CRUD workflow.
3. Typed properties: Support for core props, meta props, and taxonomy props.
4. Shared object helpers: Load single objects or collections through package utilities.
5. Extensible architecture: Swap in custom data stores, factories, and meta stores when needed.
6. WordPress-native integration: Designed for plugin code already built around WordPress and WooCommerce lifecycles.

Installation
------------

[](#installation)

You can install this package via Composer:

```
composer require x-wp/wc-data-type
```

Tip

We recommend using `automattic/jetpack-autoloader` with this package to reduce autoloading conflicts in WordPress environments.

Usage
-----

[](#usage)

Below is a simple example that defines a custom data object and loads it through the package helpers.

### Defining a model

[](#defining-a-model)

```
