Skip to main content

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

  1. Make sure WooCommerce is installed and active. The action does not appear in the Actions list otherwise.
  2. In WordPress, edit your form > Actions tab > Add Action > Create WooCommerce Order.
  3. Select the product and adjust the contact field mappings if your form uses different field names.

Settings Reference

Setting Required Default Description
Email 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

  1. A draft order is created and the billing email/name are set from the resolved settings.
  2. If a WordPress user with the submitted email exists, the order is attached to it. Otherwise a new subscriber user is created with a random password.
  3. 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."
  4. The order records created_via = core-forms and a _cf_submission_id meta with the submission ID.
  5. Each line of the order meta map is saved as order meta (keys are sanitized; values support data variables).
  6. 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_notification action.
  • No redirect: The handoff URL only overrides the form redirect when the action succeeds. Check the action log for failures.