b2c-ordering
БесплатноБез исполняемых скриптовНе проверенManage the order lifecycle in B2C Commerce including order creation, status transitions, failure handling, and checkout completion. Use this skill whenever…
от SalesforceCommerceCloud★ 58 звёзд на GitHubОб этом скилле
B2C Ordering
The OrderMgr API provides order creation, status management, and querying. Understanding the order lifecycle is essential for checkout implementation and order processing.
Order Lifecycle
Orders progress through these statuses:
Basket → CREATED → NEW → (COMPLETED or CANCELLED or FAILED)
| Status | Description | Can Transition To |
|---|---|---|
CREATED |
Order created, not yet placed | NEW, FAILED |
NEW |
Order placed, awaiting fulfillment | OPEN, COMPLETED, CANCELLED, FAILED |
OPEN |
Order in processing | COMPLETED, CANCELLED |
COMPLETED |
Order fulfilled | - |
CANCELLED |
Order cancelled | NEW (via undoCancel) |
FAILED |
Order failed (payment, validation) | - (cannot be reopened) |
Important: Once an order reaches FAILED status, it cannot be reopened or cancelled. Use failOrder(order, true) to reopen the basket for retry instead.
Creating Orders
Standard Flow (Synchronous)
var OrderMgr = require('dw/order/OrderMgr');
var Transaction = require('dw/system/Transaction');
var Status = require('dw/system/Status');
function createOrder(basket) {
var order;
Transaction.wrap(function() {
// Create order from basket (status: CREATED)
order = OrderMgr.createOrder(basket);
});
if (!order) {
return { error: true, message: 'Order creation failed' };
}
// Authorize payment
var paymentResult = authorizePayment(order);
if (!paymentResult.success) {
Transaction.wrap(function() {
OrderMgr.failOrder(order, true); // Reopen basket
});
return { error: true, message: 'Payment failed' };
}
// Place the order (status: CREATED → NEW)
var placeResult;
Transaction.wrap(function() {
placeResult = OrderMgr.placeOrder(order);
});
if (placeResult.error) {
return { error: true, message: 'Order placement failed' };
}
// Set confirmation status
Transaction.wrap(function() {
order.setConfirmationStatus(order.CONFIRMATION_STATUS_CONFIRMED);
});
return { error: false, order: order };
}
SCAPI Flow: Create, Authorize Through Order PI, Then Place
Lead with the Shopper Orders state machine instead of manually placing from order.afterPOST:
POST /checkout/shopper-orders/v1/organizations/{orgId}/orders
-> commits order in CREATED
PATCH /checkout/shopper-orders/v1/organizations/{orgId}/orders/{orderNo}/payment-instruments/{piId}
-> invokes dw.order.payment.authorizeCreditCard or dw.order.payment.authorize
-> passes successfullyAuthorized to order.payment_instrument.afterPATCH
-> default afterPATCH places when authorized coverage reaches the order total
NEW -> success
CREATED -> not fully placed; authorize remaining PIs, fail safely, or reconcile
Return undefined from a successful custom order-PI afterPATCH implementation so the platform's
default coverage-based placement behavior runs. A non-null Status ends execution and suppresses
that implementation.
On a deterministic payment failure, use the Shopper Orders fail action with reopenBasket=true.
On an indeterminate gateway result, retain the CREATED order for reconciliation rather than
risking a duplicate authorization.
Use dw.ocapi.shop.order.afterPOST as the alternative when checkout deliberately needs a single
server-side phase that creates, authorizes, and performs the Commerce-side place-or-fail transition,
or when the processor cannot participate in order-PI authorization. That hook runs inside order
creation's transaction: do not add a nested Transaction.wrap, and understand that Status.ERROR
rolls back the Commerce order but not an external gateway side effect. See
"Alternative: Authorize and Place in order.afterPOST" in the b2c-hooks skill.
OrderMgr API Reference
Order Creation
| Method | Description |
|---|---|
createOrder(basket) |
Create order with auto-generated number |
createOrder(basket, orderNo) |
Create order with specific number |
createOrderNo() |
Generate next order number |
createOrderSequenceNo() |
Get next sequence number (for custom formatting) |
Order Status
| Method | Description |
|---|---|
placeOrder(order) |
Place order (CREATED → NEW) |
failOrder(order, reopenBasket) |
Fail order (set to FAILED status) |
cancelOrder(order) |
Cancel order (set to CANCELLED status) |
undoCancelOrder(order) |
Revert cancelled order to NEW |
Note: There is no undoFailOrder() method. Failed orders cannot be reopened. Use failOrder(order, true) to reopen the basket for retry.
Order Queries
| Method | Description |
|---|---|
getOrder(orderNo) |
Get order by number |
searchOrder(query, ...args) |
Search for single order |
searchOrders(query, sortString, ...args) |
Search for multiple orders |
| `queryOrder(query |
Установить b2c-ordering в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл b2c-ordering?
Manage the order lifecycle in B2C Commerce including order creation, status transitions, failure handling, and checkout completion. Use this skill whenever the user needs to create an order from a basket, transition order status, handle failed or cancelled orders, implement payment authorization in checkout, or understand async order processing — even if they just say "my order is stuck" or "finish the checkout flow".
Как установить скилл b2c-ordering?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл b2c-ordering запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic