orderCreated__c

Prev Next

Overview

The welisacommerce__OrderCreated__c message channel is published by the OrderCentral managed package when a new order is successfully created during checkout. This event enables external Lightning components and integrations to respond immediately to order creation—without polling or relying on URL parameters.

Typical use cases:

  • Trigger fulfillment or workflow automation after checkout
  • Refresh dashboards or UI components with new order data
  • Navigate users to custom post-checkout experiences

Event Payload Contract

Field Type Description
orderId Id Salesforce record Id of the newly created order.
orderNumber String Shopper-facing order number for confirmation and transactional messaging.

Publisher Details

The event is published by the OrderCentral checkout flow after a successful order creation. For reference, the publisher is the CheckoutPage Aura component (OrderCentral managed package), specifically after the createOrder operation completes.

Subscribing to welisacommerce__OrderCreated__c

Aura Components

<!-- Component markup -->
<lightning:messageChannel aura:id="orderCreatedChannel" type="welisacommerce__OrderCreated__c" />
// Controller/helper snippet
init: function(component, event, helper) {
    const messageService = component.find('orderCreatedChannel');
    messageService.subscribe($A.getCallback(helper.handleOrderCreated.bind(helper, component)));
},

handleOrderCreated: function(component, message) {
    const payload = message ? message.getParam('payload') : null;
    if (!payload) {
        return;
    }

    const orderId = payload.orderId;
    const orderNumber = payload.orderNumber;
    // Implement UI refresh, navigation, or downstream calls
}

Lightning Web Components (LWC)

import { LightningElement, wire } from 'lwc';
import { MessageContext, subscribe } from 'lightning/messageService';
import ORDER_CREATED_CHANNEL from '@salesforce/messageChannel/welisacommerce__OrderCreated__c';

export default class OrderCreatedListener extends LightningElement {
    subscription;

    @wire(MessageContext)
    messageContext;

    connectedCallback() {
        this.subscribeToChannel();
    }

    disconnectedCallback() {
        if (this.subscription) {
            this.subscription = null;
        }
    }

    subscribeToChannel() {
        if (this.subscription || !this.messageContext) {
            return;
        }

        this.subscription = subscribe(
            this.messageContext,
            ORDER_CREATED_CHANNEL,
            (payload) => {
                const { orderId, orderNumber } = payload;
                // Execute navigation, toast, or data refresh logic
            }
        );
    }
}

Implementation Guidance

  • Always check for null or malformed payloads before processing.
  • Use the orderId to retrieve additional order details via Apex selectors or services as needed.
  • For UI components that require both cart and order updates, pair this channel with welisacommerce__refreshShoppingCart__c.
  • Do not rely on internal implementation details of the managed package; always reference the message channel using the welisacommerce namespace.

Note: This documentation is intended for developers integrating with the OrderCentral managed package. Always use the fully qualified message channel name (welisacommerce__OrderCreated__c) in your code and configuration.