Abuja Digital Studio · Est. 2018
Start a Project
Reference

Plans

OMembershiporravo.com/docs/omembership/plans

Plans (E1)

A plan is the unit of sale. Plans live in the wp_omem_plans table and are managed through OMembership_Plans (CRUD + lookups) and OMembership_Plans_Woo (the WooCommerce bridge).

Plan shape

id                BIGINT PRIMARY KEY
product_id        BIGINT NULL              -- linked Woo product (hidden, virtual)
name              VARCHAR(190)
slug              VARCHAR(190) UNIQUE
type              ENUM('free','one_time','subscription','team')
visibility        ENUM('public','invite','application')
pricing           LONGTEXT (JSON)          -- multi-tier price points
trial             LONGTEXT (JSON)
settings          LONGTEXT (JSON)
status            ENUM('draft','active','archived')

Pricing is stored as JSON so a single plan can carry multiple tiers (e.g. monthly + annual + lifetime):

json{
  "default": { "amount": 19, "interval": "month", "interval_count": 1, "currency": "USD" },
  "tiers": {
    "annual":   { "amount": 199, "interval": "year",  "interval_count": 1, "currency": "USD" },
    "lifetime": { "amount": 499, "interval": "month", "interval_count": 999, "currency": "USD" }
  }
}

The Woo bridge

OMembership_Plans_Woo::ensure_product_for_plan() creates a hidden, virtual WC_Product_Simple per paid plan and stores the back-link in product meta _omembership_plan_id. When Woo fires woocommerce_order_status_completed (or processing), the bridge walks the order items, resolves each product to a plan, and calls OMembership_Memberships::start_for_order().

Subscription lifecycle

The bridge listens on both OSubscribe and standard Woo Subscriptions:

  • osubscribe/subscription/cancelled -> mark membership cancelled
  • osubscribe/subscription/renewed -> extend current_period_ends_at
  • osubscribe/subscription/paused -> pause without expiration
  • woocommerce_subscription_status_cancelled
  • woocommerce_subscription_renewal_payment_complete

Falling back to OSubscribe is the recommended path; standard WC Subscriptions remains supported.

Saving a plan from code

php$plan_id = OMembership_Plans::save( [
    'name'       => 'Pro',
    'type'       => 'subscription',
    'visibility' => 'public',
    'pricing'    => [
        'default' => [ 'amount' => 19, 'interval' => 'month', 'interval_count' => 1 ],
    ],
    'status'     => 'active',
] );

The omem/plans/before_save filter lets integrations normalise input; omem/plans/saved fires on success. Audit log entries land in wp_omem_audit automatically.

Plans · OMembership Docs | Orravo