DEV Community

Rahul Sharma
Rahul Sharma

Posted on

CF7 eCommerce Contact Form to Order/ERP API: A Complete Implementation Guide

An eCommerce store often needs more than just a standard "contact us" form. Customers submit custom order requests, ask about bulk pricing, or inquire about product availability. Manually copying this data from form submission emails into your ERP or order management system is slow, error-prone, and does not scale.

This guide walks through how to automate the process using Contact Form 7 and the "Contact Form to Any API" plugin, sending eCommerce inquiries directly into your order or ERP API as structured records.

Why eCommerce Forms Need ERP Integration

eCommerce contact forms generate data that belongs in your order pipeline, not in an inbox.

Custom order requests. A customer filling out a form for a custom product needs that request to become an order or a quote in your system, with all the product details attached.

Bulk and B2B inquiries. Wholesale customers often submit forms with quantity requests. This data needs to flow into your ERP for pricing, inventory checks, and fulfillment planning.

Product-specific questions. When a customer asks about a specific SKU, that inquiry should be linked to the product record in your ERP for the sales team to follow up.

Without automation, every inquiry is a manual data entry task. With automation, every submission becomes a structured record ready for processing.

The Architecture: CF7 → API Plugin → ERP/Order API

The integration follows a straightforward path:

CF7 Form → Contact Form to Any API → ERP/Order API → Record Created
Enter fullscreen mode Exit fullscreen mode

The plugin sends form submissions directly to your API endpoint using secure methods. It supports any endpoint that accepts POST or GET requests with structured data, including ERP systems like Odoo, Sage CRM, and custom order management APIs.

eCommerce Form Fields That Matter

A custom order or product inquiry form needs specific fields that map to your ERP or order API. Here is a field set designed for eCommerce integration:

CF7 Field Purpose ERP/Order API Mapping
your-name Customer name contact_name or customer_name
your-email Email address email_from or customer_email
your-phone Phone number phone
product-sku Product identifier product_id or item_code
quantity Requested quantity product_qty
product-notes Customization details description or note
budget Budget indication (for quotes) expected_revenue
your-message Additional message description

These fields map directly to standard order and ERP lead fields.

Setting Up the API Integration

Step 1: Configure the ERP/Order API Endpoint

In the "Contact Form to Any API" plugin settings, enter your ERP's API endpoint. For Odoo, this is typically the JSON-RPC or XML-RPC endpoint. For other systems, consult the API documentation for the order or lead creation endpoint.

Step 2: Map CF7 Fields to ERP Fields

The plugin provides field mapping between CF7 form fields and the API payload parameters. The mapping syntax follows this pattern:

Form Fields → API Parameters

[your-name]    → contact_name
[your-email]   → email_from
[product-sku]  → product_id
[quantity]     → product_qty
Enter fullscreen mode Exit fullscreen mode

For a deeper dive into JSON structure mapping, read this guide on Contact Form 7 JSON mapping.

Step 3: Configure Authentication

ERP systems often require robust authentication. The plugin supports Basic Auth, API Key, and Bearer Token headers. For OAuth 2.0 flows, the PRO add-on handles automatic token renewal, ensuring integrations continue running without interruption.

A critical note on Basic Auth: The plugin's header field is a static textarea. PHP functions like base64_encode() do not execute when placed directly in this field. You must manually encode your credentials before pasting them into the header.

Step 4: Build the JSON Payload

The payload structure depends on your ERP's API requirements. A typical custom order or quote request payload might look like:

{
  "name": "Custom Order - [product-sku]",
  "contact_name": "[your-name]",
  "email_from": "[your-email]",
  "phone": "[your-phone]",
  "product_id": "[product-sku]",
  "product_qty": "[quantity]",
  "description": "[product-notes]",
  "type": "lead"
}
Enter fullscreen mode Exit fullscreen mode

eCommerce Specific Considerations

Product SKU as Order Context

When a customer submits an inquiry about a specific product, the SKU should be included in the record. This allows your ERP to link the inquiry to the correct product for pricing, inventory, and fulfillment checks. Map a hidden CF7 field containing the product SKU to the ERP's product field.

Example hidden field in CF7:

[hidden product-sku default:get "sku"]
Enter fullscreen mode Exit fullscreen mode

This captures the SKU from the page URL or a shortcode parameter.

Quantity and Pricing Logic

For bulk or custom orders, the quantity field is critical. Your ERP may need to calculate pricing based on quantity tiers or check available inventory. The API payload should include the requested quantity so the ERP can perform these calculations automatically.

Order vs Lead: Which Record Type?

Some ERP systems distinguish between a "lead" (unqualified inquiry) and an "order" (confirmed purchase). For eCommerce contact forms, the appropriate record type depends on your workflow.

Lead/Quote: If the customer is inquiring about a product and needs a price quote before committing.

Order: If the form is a direct order submission with all required payment and shipping details.

The payload's type field determines which record is created in the ERP.

Common Challenges and Solutions

ERP integrations have specific pitfalls. Here are the most common ones and how to avoid them.

Authentication Failures. ERP systems often use OAuth 2.0 or token-based access. If tokens expire or are misconfigured, data transmission halts without warning. Solution: Use token refresh logic and test authentication during setup.

ERP System Downtime. If your ERP goes offline for maintenance, form submissions cannot be delivered. Solution: Set up a retry mechanism that queues failed submissions and resends them once the ERP is back online.

Field Mapping Errors. Data gets lost or misrouted when fields between CF7 and the ERP are not accurately mapped. Solution: Perform field audits before going live.

Format Mismatches. ERPs have strict requirements for data format. Dates might need ISO standards, or dropdown values must match predefined codes. Solution: Use transformation logic to sanitize and validate data before submission.

Missing Required Fields. If the ERP API requires a field that is not mapped or is left empty, the request fails. Solution: Ensure all required fields are mapped and never empty.

The Debugging Checklist

Work through this sequence when an eCommerce form fails to create an ERP record:

Step Action What It Tells You
1 Check the plugin's API Logs Was a request sent? What response code came back?
2 Inspect the response code 401 = Auth issue. 422 = Payload issue. 500 = ERP server error.
3 Verify Basic Auth encoding Is the header manually Base64 encoded?
4 Check the endpoint URL Does it target the correct ERP API endpoint?
5 Verify field mapping Are all required fields mapped and populated?
6 Test with minimal payload Hardcode values to isolate structure issues from mapping issues.
7 Test credentials in Postman Isolates plugin issues from API issues.

For a comprehensive breakdown of authentication errors across different APIs, see this guide on Contact Form 7 API authentication errors.

Beyond ERP: One Form, Multiple Destinations

Once your ERP integration works, you might want to send the same submission to other tools: an email marketing platform, a help desk system, or a notification service.

A good connector plugin supports multiple API integrations from a single form submission. You can create an ERP record, subscribe the contact to Mailchimp, and send an SMS notification via Twilio, all from one CF7 submission. For a cost comparison, see this article on Zapier vs a dedicated API plugin.

Key Takeaways

eCommerce form data belongs in your ERP, not your inbox. Automate the flow from CF7 submission to ERP record.

Authentication is the most fragile part of the integration. Use token refresh for OAuth systems, and manually Base64-encode Basic Auth credentials before pasting them into the plugin's header field.

Field mapping must be exact. Match CF7 field names to your ERP's API field names precisely. Perform field audits before going live.

Start with a minimal payload. Hardcode a test record first. Once that works, add product-specific fields one at a time.

Plan for failures. ERP downtime and API errors will happen. Implement retry logic and monitor the plugin's logs to catch issues early.

With the correct API configuration, field mapping, and authentication, your CF7 eCommerce forms will deliver custom order requests and product inquiries directly into your ERP pipeline. No manual data entry, no missed opportunities, no delay.

Top comments (0)