Skip to main content

Pre-Orders (Advanced)

Goal​

Sell a product before it is in stock, take a deposit at checkout, and collect the balance when the product is released. A pre-order record is created from the customer's order, tracked through its own status, and settled by a scheduled job using the store's existing WooCommerce payment gateway.

Tier and entitlement​

FieldValue
TierPremium
Entitlement keypre-orders-advanced
Admin tabpre-orders
Module keypre-orders-advanced
Settings prefixaiowc_po_

Hooks register only when aiowc_module_enabled_pre-orders-advanced is true and the licence permits the pre-orders-advanced entitlement.

What the code does​

  • Two product meta fields mark a product as a pre-order and give it an expected availability date.
  • A product marked as a pre-order reports as in stock through woocommerce_product_is_in_stock, so it stays buyable while out of stock, and shows a badge in the product summary.
  • When an order is processed, every pre-order line item in it becomes a pre-order record holding the product, variation, customer, order, deposit type and amount, product price and availability date.
  • The balance is charged by taking the customer's default stored WooCommerce payment token for the gateway the order used and calling that gateway's own process_payment. The plugin ships no payment provider of its own; it drives whichever gateway the store already has.
  • A charge that cannot proceed marks the pre-order failed with a reason — wc_unavailable, order_missing, no_customer_or_gateway, no_token, gateway_unavailable, gateway_failed or exception.
  • Customer notifications logged per pre-order, sent by wp_mail. The types are confirmation, reminder, charge_due, charged, shipping_soon, shipped and failed.
  • A shortcode a customer can use to see the status of their pre-orders.

Settings​

Read through ModuleSettings with the aiowc_po_ prefix; defaults are PreOrdersAdvancedModule::DEFAULTS. The settings endpoint accepts exactly these six keys.

SettingDefaultMeaning
enable_pre_orderstrueMaster switch for pre-order behaviour
require_depositfalseWhether a deposit is taken rather than the full price
deposit_typepercentageHow deposit_amount is read
deposit_amount50.0Deposit size, as a percentage or a fixed amount depending on the type
auto_charge_on_releasetrueWhether the daily charge job settles balances automatically
notify_before_days7Days before the availability date that the reminder is sent

Product fields​

Rendered into the WooCommerce product editor on woocommerce_product_options_advanced and saved on woocommerce_process_product_meta. The save handler checks edit_product and verifies the product-meta nonce itself rather than relying on WooCommerce having done so.

Meta keyFieldMeaning
_aiowc_po_enabledEnable pre-order (checkbox)Stored as yes or no
_aiowc_po_availabilityAvailability date (YYYY-MM-DD)Expected release date

Admin screen​

Admin tab pre-orders. It lists pre-orders by status and offers the per-record actions the REST layer exposes — charge, cancel, fulfil and send a notification — plus the settings form.

Database schema​

Created by Schema/PreOrdersSchema.php at schema version 1.0.0.

TableHolds
{prefix}aiowc_pre_ordersOne row per pre-ordered line item, with deposit, balance due, status and availability date
{prefix}aiowc_pre_order_notificationsA log of notifications sent for a pre-order

REST endpoints​

Namespace aiowc/v1. All responses use the shared envelope.

MethodPathPurposeRequired argsPermission
GET/pre-ordersList pre-orders, filterable by status, paginated—Manage
POST/pre-ordersCreate a pre-order recordproduct_id, order_idManage
GET/pre-orders/{id}Read one pre-orderidOwn record or manage
POST/pre-orders/{id}/chargeCharge the outstanding balance nowidManage
POST/pre-orders/{id}/cancelCancel the pre-orderidManage
POST/pre-orders/{id}/fulfillMark the pre-order fulfilledidManage
POST/pre-orders/{id}/notifySend one notification of the given typeid, typeManage
GET/pre-orders/myThe signed-in customer's pre-orders—Signed in
GET/pre-orders/settingsRead settings—Manage
PUT / PATCH / POST/pre-orders/settingsUpdate settings—Manage

POST /pre-orders also accepts variation_id, user_id, deposit_type, deposit_amount, product_price and availability_date.

WooCommerce integration​

HookPriorityEffect
woocommerce_product_options_advanceddefaultRenders the two product fields
woocommerce_process_product_meta10Saves the two product fields
woocommerce_product_is_in_stock10Reports a pre-order product as in stock
woocommerce_single_product_summary24Prints the pre-order badge
woocommerce_checkout_order_processed30Creates pre-order records from the order's line items

Shortcode​

ShortcodePurpose
[aiowc_pre_order_status]Shows the current customer's pre-order status

No block is registered.

Emitted actions​

ActionFired when
aiowc_pre_order_chargedA balance charge succeeds, or there was nothing left to charge
aiowc_track_event with pre_order_chargedA gateway charge succeeds

Background jobs​

Both run on the WordPress cron scheduler, daily.

HookPurpose
aiowc_pre_orders_chargeCharges balances for released pre-orders when auto_charge_on_release is on
aiowc_pre_orders_notifySends availability reminders notify_before_days ahead of the release date

Entitlement limits​

The pre-orders-advanced entitlement gates the module as a whole. No cap on the number of pre-order products or records is implemented in the module's code.