Magento 2 Checkout Customization
Before writing code
Fetch live docs:
- Web-search
site:developer.adobe.com commerce php tutorials frontend custom-checkout for checkout customization tutorials
- Web-search
site:developer.adobe.com commerce php tutorials frontend custom-checkout add-payment-method for payment method tutorial
- Web-search
site:developer.adobe.com commerce php development components checkout for checkout architecture
Conceptual Architecture
Checkout Flow
Two-step checkout built with UI Components + KnockoutJS:
- Shipping Step — address, shipping method selection
- Payment & Review Step — payment method selection, order review, place order
Quote Model
The central data structure during checkout:
Magento\Quote\Model\Quote — the cart/checkout session
- Contains items, addresses (billing + shipping), payment, totals
- Converted to an Order on successful placement
Payment Methods
Three Categories
| Type |
Description |
| Gateway |
Data passes through Magento to processor (Stripe, Braintree) |
| Offline |
No external provider (Check/Money Order, Bank Transfer, COD) |
| Hosted |
Redirects to external payment page (PayPal Redirect) |
Implementation Components
- Payment Model — uses Payment Gateway Command pattern with
Magento\Payment\Model\Method\Adapter as a virtual type (recommended). Note: Magento\Payment\Model\Method\AbstractMethod is deprecated; avoid for new payment methods.
- Config Provider — implements
ConfigProviderInterface, returns JS config for checkout
- JS Renderer — KnockoutJS component rendering the payment form in checkout
- di.xml — register config provider into composite config provider
- system.xml/config.xml — admin configuration fields for enabling/configuring the method
Payment Gateway Command Pattern
Modern approach (since 2.1) with configurable command chain:
- Command objects for each operation (authorize, capture, refund, void)
- Request builders construct gateway-specific payloads
- Response handlers process gateway responses
- Validators verify responses
- Transfer factory creates HTTP transfer objects
Shipping Methods
Carrier Implementation
Shipping carriers extend Magento\Shipping\Model\Carrier\AbstractCarrier:
collectRates() — returns available shipping rates for the cart
getAllowedMethods() — returns method code/name pairs
- Configuration in
config.xml (defaults) and system.xml (admin fields)
- Tracking capability via
getTrackingInfo()
Totals Collectors
What Totals Collectors Do
Calculate order totals (subtotal, shipping, tax, discount, grand total):
- Declared in
etc/sales.xml
- Extend
Magento\Quote\Model\Quote\Address\Total\AbstractTotal
collect() — performs calculation, modifies quote address totals
fetch() — returns the result for display
Collector Order
Collectors run in sequence. Standard order: subtotal → discount → shipping → tax → grand_total. Custom collectors must declare their position relative to existing ones.
Checkout UI Customization
Layout Modification
Checkout layout is defined in checkout_index_index.xml. Modify via:
- Adding new UI components to checkout steps
- Moving/removing existing components
- Plugin on
LayoutProcessorInterface for dynamic modifications
Custom Checkout Steps
Add entire new steps via JavaScript UI components registered in the checkout layout.
Best Practices
- Use the Payment Gateway Command pattern for new payment methods
- Test payment methods in sandbox/test mode before production
- Handle payment failures gracefully with clear customer messaging
- Use config providers to pass server config to checkout JS
- Follow PCI compliance — never log or store raw card data
- Test shipping rate calculation with various cart compositions
Fetch the checkout customization tutorials for exact class signatures, XML configurations, and JS component patterns before implementing.
1---2name: magento-checkout3description: Customize Magento 2 checkout — payment methods, shipping carriers, totals collectors, and checkout UI. Use when building custom payment/shipping integrations or modifying the checkout flow.4allowed-tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch5metadata:6 source: https://skillmd.com/skills/orcaqubits/magento-checkout7---89# Magento 2 Checkout Customization1011## Before writing code1213**Fetch live docs**:141. Web-search `site:developer.adobe.com commerce php tutorials frontend custom-checkout` for checkout customization tutorials152. Web-search `site:developer.adobe.com commerce php tutorials frontend custom-checkout add-payment-method` for payment method tutorial163. Web-search `site:developer.adobe.com commerce php development components checkout` for checkout architecture1718## Conceptual Architecture1920### Checkout Flow2122Two-step checkout built with UI Components + KnockoutJS:231. **Shipping Step** — address, shipping method selection242. **Payment & Review Step** — payment method selection, order review, place order2526### Quote Model2728The central data structure during checkout:29- `Magento\Quote\Model\Quote` — the cart/checkout session30- Contains items, addresses (billing + shipping), payment, totals31- Converted to an Order on successful placement3233## Payment Methods3435### Three Categories3637| Type | Description |38|------|-------------|39| **Gateway** | Data passes through Magento to processor (Stripe, Braintree) |40| **Offline** | No external provider (Check/Money Order, Bank Transfer, COD) |41| **Hosted** | Redirects to external payment page (PayPal Redirect) |4243### Implementation Components44451. **Payment Model** — uses Payment Gateway Command pattern with `Magento\Payment\Model\Method\Adapter` as a virtual type (recommended). Note: `Magento\Payment\Model\Method\AbstractMethod` is deprecated; avoid for new payment methods.462. **Config Provider** — implements `ConfigProviderInterface`, returns JS config for checkout473. **JS Renderer** — KnockoutJS component rendering the payment form in checkout484. **di.xml** — register config provider into composite config provider495. **system.xml/config.xml** — admin configuration fields for enabling/configuring the method5051### Payment Gateway Command Pattern5253Modern approach (since 2.1) with configurable command chain:54- Command objects for each operation (authorize, capture, refund, void)55- Request builders construct gateway-specific payloads56- Response handlers process gateway responses57- Validators verify responses58- Transfer factory creates HTTP transfer objects5960## Shipping Methods6162### Carrier Implementation6364Shipping carriers extend `Magento\Shipping\Model\Carrier\AbstractCarrier`:65- `collectRates()` — returns available shipping rates for the cart66- `getAllowedMethods()` — returns method code/name pairs67- Configuration in `config.xml` (defaults) and `system.xml` (admin fields)68- Tracking capability via `getTrackingInfo()`6970## Totals Collectors7172### What Totals Collectors Do7374Calculate order totals (subtotal, shipping, tax, discount, grand total):75- Declared in `etc/sales.xml`76- Extend `Magento\Quote\Model\Quote\Address\Total\AbstractTotal`77- `collect()` — performs calculation, modifies quote address totals78- `fetch()` — returns the result for display7980### Collector Order8182Collectors run in sequence. Standard order: subtotal → discount → shipping → tax → grand_total. Custom collectors must declare their position relative to existing ones.8384## Checkout UI Customization8586### Layout Modification8788Checkout layout is defined in `checkout_index_index.xml`. Modify via:89- Adding new UI components to checkout steps90- Moving/removing existing components91- Plugin on `LayoutProcessorInterface` for dynamic modifications9293### Custom Checkout Steps9495Add entire new steps via JavaScript UI components registered in the checkout layout.9697## Best Practices9899- Use the Payment Gateway Command pattern for new payment methods100- Test payment methods in sandbox/test mode before production101- Handle payment failures gracefully with clear customer messaging102- Use config providers to pass server config to checkout JS103- Follow PCI compliance — never log or store raw card data104- Test shipping rate calculation with various cart compositions105106Fetch the checkout customization tutorials for exact class signatures, XML configurations, and JS component patterns before implementing.