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 Pro 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_state — order-item meta, the source of truth. One of packed, awaiting, or absent (= still to pack). The two set states are mutually exclusive.
  • _powc_status — order 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 Pro are registered only when Pro 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-all—Mark every shippable item on the order packed.
POST /powc/v1/orders/{order}/reset—Clear all packing state on the order.
POST /powc/v1/reorder/suppliers/{term}/place-order Pro—Create and place a supplier-order batch from that supplier’s awaiting items.
POST /powc/v1/reorder/orders/{order}/items/{item}/resolve ProactionResolve a batched line — received, next, or remove.

Action hooks

These are the seams the Pro 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 Prothe How-it-works guide renders (fires only when Pro is active)—
powc_fs_loadedFreemius has finished loading (safe to call powc_fs())—

Filter hooks

HookChangesArguments
powc_is_prothe master “is Pro active” gate — return true to treat the install as licensedfalse
powc_awaiting_show_statusreturn true to add a Status column to the Awaiting list (Pro 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 Pro tier:

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

JavaScript

  • No admin-AJAX of its own. Every write goes through the REST API above via fetch with the X-WP-Nonce header — the plugin registers no wp_ajax_* actions.
  • Self-healing saves (1.1.0). Writes run one at a time, in order. If a write fails with rest_cookie_invalid_nonce (a tab left open too long), the client fetches a fresh nonce from core’s admin-ajax.php?action=rest-nonce and retries once. A logged-out session shows a reload dialog instead.
  • JS config objects: window.POWC (free — restRoot, nonce, nonceUrl, status labels, and wakeMinutes on the packing page), plus POWC_REORDER and POWC_PICK Pro (POWC_PICK also carries wakeMinutes). nonceUrl and wakeMinutes were added in 1.1.0.
  • Action attributes: buttons carry data-powc-action — await, pack-all, reset (free), and place-order, resolve, pick-await, print Pro.
  • 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). Pro 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 Pro 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 keep-screen-awake setting powc_wake_minutes, the Pro 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.