Commerce Webform Order

Integrates Drupal Webform with Drupal Commerce, enabling the creation of commerce orders from webform submissions via a specialized webform handler.

commerce_webform_order
519 sites
39
drupal.org

インストール

Drupal 11, 10, 9 v3.0.6
composer require 'drupal/commerce_webform_order:^3.0'

概要

Commerce Webform Orderは、DrupalのWebformモジュールとCommerceモジュールの間に強力な統合レイヤーを提供します。サイトビルダーは、Webformを通じて顧客データを収集し、送信データから自動的にCommerce注文を生成することで、複雑な注文ワークフローを作成できます。

このモジュールは、寄付フォーム、会員申請、サービス予約、およびDrupal Commerceの堅牢なEコマースシステムを通じて支払いを処理しながらユーザーから詳細な情報を収集する必要があるあらゆるシナリオに特に有用です。

Webform送信を直接販売する類似モジュールとは異なり、Commerce Webform OrderはCommerceの上位レイヤーとして機能し、PurchasableEntityInterfaceを実装する任意のEntityを販売できます。これにより、複雑なEコマースシナリオに対してより高い柔軟性を提供します。

Features

  • Webform送信からCommerce注文を作成するWebformハンドラー(豊富な設定オプション付き)
  • Payment Gatewayの選択フォームをWebformに直接埋め込むPayment Method Webformエレメント
  • Webform送信内で現在の注文状態を同期・表示するOrder State Webformエレメント
  • 支払いステータス情報を追跡・表示するPayment Status Webformエレメント
  • Webformから開始された支払いを処理するためのカスタムCheckoutペイン(Payment Process)
  • 注文状態/支払いステータスとWebform送信データの自動同期
  • 動的な注文作成のためのハンドラー設定でのToken値のサポート
  • カートを空にする、新しいカート、カートを結合するオプションを含むカート動作制御
  • Webform送信後にユーザーをCheckoutにリダイレクトするオプション
  • 注文の所有者、請求先プロファイル、Payment Gateway、支払い方法の設定サポート
  • Webformデータからカスタム注文アイテムフィールドを入力するための注文アイテムフィールドマッピング
  • 関連する注文がドラフト状態でなくなった場合のWebform送信更新の防止
  • 開発およびトラブルシューティング用のデバッグモード
  • 保存前に注文、注文アイテム、Webform送信をカスタマイズするためのAlter hook

Use Cases

Donation Form with Custom Amounts

Create a donation webform where users can enter custom donation amounts. Map a number field to the order item amount, allowing donors to specify their contribution. The handler creates an order with the custom price, and users are redirected to checkout for payment processing.

Event Registration with Payment

Build an event registration form that collects attendee information and creates a commerce order for the registration fee. Use the Order State element to display payment status on the confirmation page and trigger email notifications based on order completion.

Membership Application

Create a membership application form that collects member details and processes membership fees. Use the billing profile setting to pre-populate checkout with information collected in the form, streamlining the payment process.

Product Customization Form

Allow customers to customize products through a webform (e.g., engraving text, color selections) and map these values to order item custom fields. The order item stores the customization details alongside the standard commerce data.

Multi-Step Checkout Replacement

Replace Commerce's standard checkout flow with a webform-based checkout. Embed the Payment Method element to collect payment information directly in the form, then use the custom Payment Process checkout pane to handle the transaction.

Recurring Donation Setup

Create a donation form that collects payment method information for recurring donations. The Payment Method element supports stored payment methods, enabling future automated charges when integrated with Commerce recurring payment modules.

Tips

  • Use token values (e.g., [webform_submission:values:amount]) in handler settings for dynamic order creation based on submission data.
  • Add the :clear suffix to tokens (e.g., [current-user:name:clear]) to remove tokens that have no replacement value.
  • When using the Payment Method element, replace the standard 'Payment process' checkout pane with 'Payment process (Commerce Webform Order)' and disable the 'Payment information' pane.
  • Enable debugging during development to see detailed order creation information, but remember to disable it in production.
  • Use the Order State and Payment Status elements to trigger conditional actions in other webform handlers based on commerce events.
  • For anonymous donations, consider enabling 'Bypass access checks' for store access to avoid permission issues.
  • The handler supports unlimited cardinality - add multiple handlers to create multiple order items from a single submission.
  • Use YAML format in the 'Custom order data' field to add arbitrary data to orders that can be used by other modules or custom code.

Technical Details

Admin Pages 1
Add Commerce Webform Order Handler /admin/structure/webform/manage/{webform}/handlers/add/commerce_webform_order

Configuration form for adding the Commerce Webform Order handler to a webform. Allows setting up order creation rules and behavior.

Hooks 1
hook_commerce_webform_order_handler_postsave_alter

Alter the order, order item and webform submission in the webform handler before they are saved. Allows custom modifications to commerce entities created from webform submissions.

Security Notes 4
  • The 'Bypass access checks' options should be used carefully as they override normal Drupal access controls.
  • Debug mode displays order information to all users - only use in development environments.
  • Payment method information is processed through Commerce Payment's secure APIs - no sensitive data is stored in webform submissions.
  • The prevent_update feature helps maintain data integrity by blocking changes to submissions linked to completed orders.