Commerce Core
Drupal Commerce is the leading flexible eCommerce solution for Drupal, powering over 60,000 online stores of all sizes.
commerce
インストール
composer require 'drupal/commerce:^3.2'
概要
Drupal Commerceは、Drupal上に構築された包括的なエンタープライズグレードのeコマースフレームワークです。商品、注文、ショッピングカート、チェックアウトフロー、決済、プロモーション、税金、マルチストア構成をサポートする、オンラインストア構築のための完全なソリューションを提供します。
モジュラーアーキテクチャにより、サイトビルダーは必要なコンポーネントのみを有効にでき、開発者は決済ゲートウェイ、チェックアウトペイン、プロモーションオファー、税タイプなどをカバーする堅牢なプラグインシステムを通じて機能を拡張できます。システムはイベント駆動アーキテクチャを広範に使用しており、カスタマージャーニー全体を通じてモジュールがコマースイベントに反応できます。
主要なアーキテクチャ機能には、Entityベースのデータモデル(Product、Order、Store、Payment)、ワークフロー管理のためのState Machine統合、マルチ通貨サポート付きの価格フィールドタイプ、プラグインベースの拡張性、ダッシュボードメトリクスとアクティビティログを備えた包括的な管理UIが含まれます。
Features
- シンプルな商品から複雑な設定可能商品まで、あらゆる商品構造を処理するための設定可能な商品タイプ、バリエーション、属性を備えた完全な商品カタログ管理
- 匿名ユーザー向けのセッション管理、アイテム結合、数量更新、放棄されたカートのカート有効期限を備えたショッピングカートシステム
- ログイン、請求情報、注文確認、決済、完了メッセージ用のカスタマイズ可能なペインを持つ設定可能なマルチステップチェックアウトフロー
- オンサイト(直接カード入力)、オフサイト(リダイレクト)、手動決済方式をサポートし、保存済み決済方法をサポートする拡張可能な決済ゲートウェイアーキテクチャ
- 柔軟なオファータイプ(固定金額、パーセンテージ、X個買うとY個無料)、条件ベースのターゲティング、使用制限、日付ベースの有効化を備えたプロモーションとクーポンシステム
- EU VAT、UK VAT、カナダGST/HSTの組み込みサポートと、時間ベースの税率変更を持つカスタム税ゾーンを備えた税計算フレームワーク
- ストア固有の通貨、タイムゾーン、税登録、請求国構成を持つマルチストアサポート
- カート変更、注文状態遷移、決済アクティビティを含むすべてのコマースイベントを追跡するアクティビティログシステム
- 設定可能なリセット戦略(無限、年次、月次)を持つ注文番号用の連番パターン生成
- メトリクス、受信トレイ通知、コマース管理機能へのクイックアクセスを備えた管理ダッシュボード
- 任意精度演算、マルチ通貨サポート、ロケール対応フォーマットを備えた価格フィールドタイプ
- 商品、注文、カート、チェックアウト、決済、プロモーションのライフサイクルイベントにモジュールがフックできる包括的なイベントシステム
Use Cases
Simple Online Store
Create a basic online store selling physical products. Enable Commerce Store, Product, Order, Cart, Checkout, and Payment modules. Create a store with your business details, add products with variations (sizes, colors), configure a checkout flow with billing information, and set up a payment gateway like PayPal or Stripe.
Multi-vendor Marketplace
Build a marketplace with multiple vendors using the multi-store architecture. Each vendor gets their own store entity with separate currencies, tax registrations, and payment configurations. Products are associated with specific stores, and the per-store number pattern sequences ensure unique order numbers per vendor.
Subscription Commerce
Implement recurring payments by extending Commerce with the Commerce Recurring module. Use stored payment methods to charge customers automatically, and create subscription product types with recurring billing periods.
B2B Commerce with Tax Exemptions
Configure EU VAT for business-to-business sales. Customers with valid VAT numbers receive zero-rated transactions for intra-community supplies. Use the tax number field on customer profiles and the EU VAT tax type's automatic VAT number validation.
Promotional Campaigns
Create complex promotional campaigns using the promotion system. Set up percentage discounts, fixed amount offers, or Buy X Get Y promotions. Target specific products using conditions, generate bulk coupon codes, set usage limits per customer, and schedule promotions with start/end dates.
Digital Downloads Store
Sell digital products by creating a product type without physical shipping requirements. Use the Commerce File module for secure download delivery after purchase, and configure instant checkout completion for immediate access.
Tips
- Use the Commerce Dashboard at /admin/commerce for quick access to orders, products, and configuration
- Partner banners can be disabled by adding $settings['commerce_show_partner_banners'] = FALSE; to settings.php
- Product variations support automatic title generation from attribute values - enable this in variation type settings
- The promotion system supports compatibility rules - set promotions to 'Cannot be combined' to prevent stacking
- Use the activity log at /admin/commerce/orders/{order}/logs to audit all changes to an order
- Cart expiration can be configured per order type to automatically clean up abandoned carts
- The price resolver chain allows custom pricing logic - add custom resolvers at higher priority to override default prices
- Checkout flows can be customized per order type using third-party settings on the order type entity
Technical Details
Admin Pages 17
/admin/commerce
Main Commerce administration dashboard providing quick access to all Commerce functionality, metrics overview, and inbox notifications from Drupal Commerce.
/admin/commerce/config
Overview page for all Commerce configuration options organized by category.
/admin/commerce/config/stores
Manage your store entities. Each store has its own name, email, default currency, timezone, address, and billing countries configuration.
/admin/commerce/config/store-types
Manage store type bundles and their field configurations.
/admin/commerce/config/currencies
Manage currencies available in your store. Import from the commerceguys/intl library or create custom currencies.
/admin/commerce/products
Manage your product catalog. Create, edit, duplicate, and delete products with their variations.
/admin/commerce/config/product-types
Manage product type bundles including variation types association, multiple variations setting, and variation field injection.
/admin/commerce/config/product-variation-types
Manage product variation type bundles including order item type association and title generation settings.
/admin/commerce/product-attributes
Manage product attributes (like Color, Size) and their values. Attributes are used to create product variations.
/admin/commerce/orders
View and manage customer orders including order status, payments, and fulfillment.
/admin/commerce/config/order-types
Manage order type bundles including workflow selection, refresh settings, and receipt email configuration.
/admin/commerce/config/order-item-types
Manage order item type bundles and their purchasable entity type association.
/admin/commerce/config/checkout-flows
Manage checkout flow configurations with customizable steps and panes for the customer checkout experience.
/admin/commerce/config/payment-gateways
Configure payment gateways for processing customer payments including on-site, off-site, and manual gateways.
/admin/commerce/promotions
Manage promotions and discounts with configurable offers, conditions, coupons, and usage limits.
/admin/commerce/config/tax-types
Configure tax types for automatic tax calculation including EU VAT, UK VAT, Canadian sales tax, and custom tax zones.
/admin/commerce/config/number-patterns
Configure sequential number patterns for generating order numbers and similar sequences.
権限 19
Hooks 2
hook_commerce_inline_form_alter
Perform alterations before a Commerce inline form is rendered
hook_commerce_inline_form_PLUGIN_ID_alter
Perform plugin-specific inline form alterations
Troubleshooting 6
Ensure PHP sessions are working correctly. Commerce stores anonymous cart IDs in the session. Check session configuration and ensure the session cookie is being set properly.
Check the currency configuration at /admin/commerce/config/currencies. Each currency has a 'Fraction digits' setting that controls decimal precision.
Verify the promotion is enabled, within date range, has available usage, and conditions match the order. Check store and order type restrictions on the promotion.
Ensure a tax type is configured at /admin/commerce/config/tax-types and its conditions match your orders. For EU VAT, verify the store has tax registrations set for applicable countries.
The payment step is hidden when the order balance is zero. Verify products have prices and promotions aren't making the order free.
Ensure a number pattern is configured and assigned to the order type at /admin/commerce/config/order-types. Check that the number pattern's target entity type is set to 'commerce_order'.
Security Notes 5
- Payment gateway credentials are stored in configuration - use environment variables or key module for production
- Cart session IDs are stored in PHP sessions - ensure session security is properly configured
- Admin permissions should be granted carefully - 'administer commerce_order' allows viewing all customer data
- Payment method storage includes sensitive card data (last 4 digits, expiration) - ensure database security
- Coupon codes are case-insensitive and stored in the database - use sufficient length and complexity for bulk-generated codes