WooCommerce Integration
Create a WooCommerce customer and a draft (pending) order when a form is submitted, with an optional handoff straight to the order payment page.
Action type: woocommerce
Label: Create WooCommerce Order
Dependency: WooCommerce (available only when wc_create_order() exists)
Handler: Core_Forms\Integrations\IntegrationHandlers::woocommerce
Source: src/integrations/class-integration-manager.php, src/integrations/class-integration-handlers.php
Setup
- Make sure WooCommerce is installed and active. The action does not appear in the Actions list otherwise.
- In WordPress, edit your form > Actions tab > Add Action > Create WooCommerce Order.
- Select the product and adjust the contact field mappings if your form uses different field names.
Settings Reference
| Setting | Required | Default | Description |
|---|---|---|---|
| Yes | [email] |
Customer billing email | |
| First name | No | [first_name] |
Customer billing first name |
| Last name | No | [last_name] |
Customer billing last name |
| Phone | No | [phone] |
Customer phone |
| Product | Yes | -- | WooCommerce product to add to the order (published and draft products, up to 200, are listed) |
| Quantity | No | 1 |
Line-item quantity (minimum 1) |
| Order meta map | No | -- | One meta_key=value per line, saved as order meta |
| WooCommerce email | No | Off | Trigger the pending-order email notification |
| Handoff | No | Off | Redirect the visitor to the order payment page after submission |
All text settings support Core Forms data variables, e.g. [email], [first_name], or any form field like [company].
How It Works
- A draft order is created and the billing email/name are set from the resolved settings.
- If a WordPress user with the submitted email exists, the order is attached to it. Otherwise a new
subscriberuser is created with a random password. - The selected product is added with the configured quantity, totals are calculated, and the order is set to pending with the note "Draft order created by Core Forms."
- The order records
created_via = core-formsand a_cf_submission_idmeta with the submission ID. - Each line of the order meta map is saved as order meta (keys are sanitized; values support data variables).
- With Handoff enabled, the visitor is redirected to the order's checkout payment URL so they can pay immediately.
Each run is idempotent: Core Forms builds a key from the submission ID, action type, and resolved settings, so re-processing the same submission never creates a duplicate order.
Example: Lead-to-Order Form
Form with email, first_name, last_name, and a notes field:
- Product: your service product
- Order meta map:
customer_notes=[notes] lead_source=contact-form - Handoff: enabled, so the customer lands on the payment page.
Troubleshooting
- Action missing from the Actions list: WooCommerce must be active. The action settings panel also shows "Dependency unavailable" when it is not.
- "WooCommerce product not found": The selected product was deleted or the ID is invalid. Re-select a product.
- No pending-order email: Enable the WooCommerce email checkbox; it fires the
woocommerce_order_status_pending_notificationaction. - No redirect: The handoff URL only overrides the form redirect when the action succeeds. Check the action log for failures.