Skip to main content

Database Schema & Data Layer

StoreEngine stores transactional, high-volume data in custom database tables rather than wp_posts/wp_postmeta. This page maps the full schema so you know where each piece of data lives before you query, extend, or migrate it.

Not everything is a post. Products and coupons remain custom post types (see Post Types & Taxonomies), but orders, order items, subscriptions, carts, stock, tax, shipping, and payment data all live in dedicated tables built for relational queries and scale.

How the schema is defined

Each table has a CREATE TABLE definition in includes/database/create-*.php. Tables are registered in includes/database.php and installed/upgraded by includes/installer.php on activation and version bumps.

All tables use the site's WordPress table prefix. On a default install that prefix is wp_, so storeengine_orders becomes wp_storeengine_orders. Examples below use the wp_ prefix; read it as {$wpdb->prefix} in code.

Orders and subscriptions share one table

Both orders and subscriptions are stored in wp_storeengine_orders. A type column discriminates the row: 'order' for a regular order, 'subscription' for a subscription. There is no separate subscriptions post type or master table — the schedule detail for a subscription lives in wp_storeengine_subscriptions, keyed back to the order row.

Coupons are a CPT, not a table

Unlike orders, coupons are stored as the storeengine_coupon custom post type. There is no storeengine_coupons table.

Orders & Subscriptions

TablePurpose
storeengine_ordersMaster record for both orders and subscriptions. The type column (order / subscription) discriminates. Holds status, currency, totals, customer id, and dates.
storeengine_orders_metaArbitrary key/value metadata attached to an order or subscription row.
storeengine_order_itemsLine rows for an order. The order_item_type column distinguishes line_item (product), tax, shipping, fee, coupon, and refund rows.
storeengine_order_item_metaMetadata for individual order items (e.g. product id, price id, quantity, subtotals).
storeengine_order_addressesBilling and shipping addresses for an order, one row per address type.
storeengine_order_operational_dataOperational fields such as the human-readable order number and paid/completed timestamps.
storeengine_subscriptionsSchedule data for subscription rows: next payment date, period, interval, trial, retry, and related dates.

Products & Attributes

TablePurpose
storeengine_product_priceA product has many prices/plans. Each row is a purchasable unit identified by price_id — the thing that gets added to cart and referenced by order items. See Products.
storeengine_product_variationsVariation rows for variable products.
storeengine_product_variation_metaMetadata for individual variations.
storeengine_variation_term_relationsMaps variations to attribute terms.
storeengine_attribute_taxonomiesDefinitions for global (store-wide) product attributes.

Cart, Sessions & Stock

TablePurpose
storeengine_cartPersisted cart contents, keyed to a session or user.
storeengine_sessionsFront-end session storage for guests and logged-in customers.
storeengine_reserved_stockTemporary stock holds placed during checkout to prevent overselling.
storeengine_stock_movementsAppend-only ledger of stock increases and decreases for auditing.

Downloads

TablePurpose
storeengine_downloadable_product_permissionsGrants that allow a customer to download a purchased file.
storeengine_download_logRecords each download event.
storeengine_product_download_directoriesApproved directories from which downloadable files may be served.

Tax

TablePurpose
storeengine_tax_ratesTax rate definitions (rate, class, priority, labels).
storeengine_tax_rate_locationsLocation constraints (postcode/city) attached to a tax rate.

Shipping

TablePurpose
storeengine_shipping_zonesShipping zone definitions.
storeengine_shipping_zone_locationsCountries/states/postcodes that belong to a zone.
storeengine_shipping_zone_methodsShipping methods enabled within a zone.

Payment

TablePurpose
storeengine_payment_tokensSaved payment methods (tokenized cards, etc.) for customers.
storeengine_payment_tokenmetaMetadata for saved payment tokens.
storeengine_payoutsPayout records (used by affiliate/marketplace flows).

Analytics & Lookup

TablePurpose
storeengine_order_product_lookupDenormalized per-product order rows for fast reporting.
storeengine_customer_lookupDenormalized customer aggregates for analytics.

Integrations & Misc

TablePurpose
storeengine_api_keysREST API key/secret pairs. See REST API › Authentication.
storeengine_integrationsStored third-party integration connections.
storeengine_email_logLog of emails sent by the store.
storeengine_logsGeneral-purpose application log.

Querying custom tables

Because this data is not in wp_posts, WP_Query and get_post_meta() do not reach it. Use the domain objects instead — they wrap the tables and give you typed getters:

use StoreEngine\Classes\Order;

$order = new Order( 123 ); // load by id
echo $order->get_total();
echo $order->get_status();

Reach for the raw $wpdb API only for reporting-style aggregate queries:

global $wpdb;
$count = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM {$wpdb->prefix}storeengine_orders WHERE type = %s AND status = %s",
'order',
'completed'
)
);
Owning your own tables

If your addon needs its own table, follow the same install/upgrade pattern StoreEngine uses. See Building Addons › Database Tables.

See also