Pack Orders

Developer docs

Pack Orders is built to be extended. Packing state lives on WooCommerce’s own order line items, the plugin exposes a small REST namespace, and it fires actions and filters at every meaningful seam. There are no external services and no custom tables — the only network dependency is Freemius for Flow licensing. This page covers the public surface for v1.0.0 (code prefix POWC / powc_).

The packing model

Packing state is stored per line item, and the order-level status is only ever a derived cache — so it can never drift from the items.

  • _powc_stateorder-item meta, the source of truth. One of packed, awaiting, or absent (= still to pack). The two set states are mutually exclusive.
  • _powc_statusorder meta, a derived cache: to-pack, partly-packed, awaiting, or packed. Always recomputed from the items, never authoritative.
  • Rollup rule: any one awaiting item ⇒ the order is awaiting (blocked); else all packed ⇒ packed; some packed ⇒ partly-packed; none ⇒ to-pack. Only shippable items count (virtual/downloadable are skipped).
  • The cache is recomputed on woocommerce_order_status_changed, woocommerce_saved_order_items, and woocommerce_order_refunded.

Pack Orders never changes the WooCommerce order status — packing is a parallel layer. It reads status only to decide which orders are packable (default: Processing).

REST API

Namespace powc/v1. Every route is a write (POST), guarded by the edit_shop_orders capability and the standard X-WP-Nonce (wp_rest) header. Each response returns a recomputed summary so the client updates from server truth. Endpoints marked Flow are registered only when Flow is active.

EndpointBodyPurpose
POST /powc/v1/orders/{order}/items/{item}/statestateSet one item’s state — to-pack, packed or awaiting.
POST /powc/v1/orders/{order}/pack-allMark every shippable item on the order packed.
POST /powc/v1/orders/{order}/resetClear all packing state on the order.
POST /powc/v1/reorder/suppliers/{term}/place-order FlowCreate and place a supplier-order batch from that supplier’s awaiting items.
POST /powc/v1/reorder/orders/{order}/items/{item}/resolve FlowactionResolve a batched line — received, next, or remove.

Action hooks

These are the seams the Flow add-on itself hangs off — so your own add-ons can use them too. Everything ships in the free plugin.

HookFires whenArguments
powc_register_submenusthe Packing admin menu is built (add your own submenus)$parent_slug, $cap
powc_settings_fieldsthe Settings form renders (add cards inside it)
powc_settings_after_formafter the Settings form (add standalone tool forms)
powc_guide_after_sections Flowthe How-it-works guide renders (fires only when Flow is active)
powc_fs_loadedFreemius has finished loading (safe to call powc_fs())

Filter hooks

HookChangesArguments
powc_is_prothe master “is Flow active” gate — return true to treat the install as licensedfalse
powc_awaiting_show_statusreturn true to add a Status column to the Awaiting list (Flow fills it)false
powc_awaiting_status_cellthe Status cell HTML for a product on the Awaiting list'', $product

Example — gate your own code on the Flow tier:

if ( apply_filters( 'powc_is_pro', false ) ) {
    // Flow is active — safe to use supplier / re-order data.
}

JavaScript

  • No admin-AJAX. Every write goes through the REST API above via fetch with the X-WP-Nonce header — there are no wp_ajax_* actions.
  • JS config objects: window.POWC (free — restRoot, nonce, status labels), plus POWC_REORDER and POWC_PICK Flow.
  • Action attributes: buttons carry data-powc-actionawait, pack-all, reset (free), and place-order, resolve, pick-await, print Flow.
  • No shortcodes, no WP-CLI — the public surface is REST (write) + the hooks above.

Data & privacy

  • No custom tables. Packing state lives in WooCommerce’s own order-item meta (_powc_state) and a derived order-meta cache (_powc_status). Flow adds a powc_supplier product taxonomy (with contacts in term meta) and a private powc_supplier_order batch post type.
  • No third-party calls — nothing about an order leaves your store; the only network dependency is Freemius for Flow licensing.
  • Capability-gated everywhere: every screen and REST write requires edit_shop_orders; REST writes also require the wp_rest nonce.
  • Clean uninstall removes the plugin’s options (packable statuses, the Flow auto-flag toggle, the per-user page size) but deliberately keeps _powc_state/_powc_status, so packing history survives a reinstall.

Building an integration and need a hook that isn’t here? These are the stable, documented entry points for v1.0.0 — open a thread on the plugin’s WordPress.org support forum and we’ll point you at the right one.