Skip to content

Order Data & Events

The Order drop-in uses the event bus to emit and listen to events for communication between drop-ins and external integrations.

Version: 3.1.0
EventDirectionDescription
cart/resetEmitsEmitted when the component state is reset.
order/placedEmitsEmitted when an order is placed.
companyContext/changedListensFired by Company Context (companyContext) when a change occurs.
order/dataEmits and listensTriggered when data is available or changes.
order/errorEmits and listensTriggered when an error occurs.

The following sections provide detailed information about each event, including its direction, event payload, and usage examples.

Emitted when the component state is reset.

import { events } from '@dropins/tools/event-bus.js';
events.on('cart/reset', (payload) => {
console.log('cart/reset event received:', payload);
// Add your custom logic here
});

Fired by Company Context (companyContext) when a change occurs.

string | null | undefined
import { events } from '@dropins/tools/event-bus.js';
events.on('companyContext/changed', (payload) => {
console.log('companyContext/changed event received:', payload);
// Add your custom logic here
});

Emitted when order data is loaded or updated. This includes order details, items, shipping information, and payment status.

OrderDataModel

See OrderDataModel for full type definition.

import { events } from '@dropins/tools/event-bus.js';
events.on('order/data', (payload) => {
console.log('order/data event received:', payload);
// Add your custom logic here
});

Emitted when an error occurs during order operations such as fetching order details, reordering items, or processing returns.

{ source: string; type: string; error: Error | string }
import { events } from '@dropins/tools/event-bus.js';
events.on('order/error', (payload) => {
console.log('order/error event received:', payload);
// Add your custom logic here
});

Emitted when an order is placed.

OrderDataModel

See OrderDataModel for full type definition.

import { events } from '@dropins/tools/event-bus.js';
events.on('order/placed', (payload) => {
console.log('order/placed event received:', payload);
// Add your custom logic here
});

The following data models are used in event payloads for this drop-in.

Used in: order/data, order/placed.

type OrderDataModel = {
giftReceiptIncluded: boolean;
printedCardIncluded: boolean;
giftWrappingOrder: {
price: MoneyProps;
uid: string;
};
placeholderImage?: string;
returnNumber?: string;
id: string;
orderStatusChangeDate?: string;
number: string;
email: string;
token?: string;
status: string;
isVirtual: boolean;
totalQuantity: number;
shippingMethod?: string;
carrier?: string;
orderDate: string;
returns: OrdersReturnPropsModel[];
discounts: { amount: MoneyProps; label: string }[];
coupons: {
code: string;
}[];
payments: {
code: string;
name: string;
}[];
shipping?: { code: string; amount: number; currency: string };
shipments: ShipmentsModel[];
items: OrderItemModel[];
totalGiftCard: MoneyProps;
grandTotal: MoneyProps;
grandTotalExclTax: MoneyProps;
totalShipping?: MoneyProps;
subtotalExclTax: MoneyProps;
subtotalInclTax: MoneyProps;
totalTax: MoneyProps;
shippingAddress: OrderAddressModel;
totalGiftOptions: {
giftWrappingForItems: MoneyProps;
giftWrappingForItemsInclTax: MoneyProps;
giftWrappingForOrder: MoneyProps;
giftWrappingForOrderInclTax: MoneyProps;
printedCard: MoneyProps;
printedCardInclTax: MoneyProps;
};
billingAddress: OrderAddressModel;
availableActions: AvailableActionsProps[];
taxes: { amount: MoneyProps; rate: number; title: string }[];
appliedGiftCards: {
code: string;
appliedBalance: MoneyProps;
}[];
};
type OrderItemProductModel = {
onlyXLeftInStock?: number;
priceRange?: {
maximumPrice?: {
regularPrice?: MoneyProps;
};
};
uid: string;
__typename: string;
stockStatus?: string;
canonicalUrl?: string;
urlKey?: string;
id: string;
image?: string;
imageAlt?: string;
name: string;
productType: string;
sku: string;
thumbnail: {
url: string;
label: string;
};
giftWrappingAvailable?: boolean;
};
type OrderItemModel = {
giftMessage: {
senderName: string;
recipientName: string;
message: string;
};
giftWrappingPrice: MoneyProps;
productGiftWrapping: {
uid: string;
design: string;
selected: boolean;
image: {
url: string;
label: string;
};
price: MoneyProps;
}[];
taxCalculations: {
includeAndExcludeTax: {
originalPrice: MoneyProps;
baseOriginalPrice: MoneyProps;
baseDiscountedPrice: MoneyProps;
baseExcludingTax: MoneyProps;
};
excludeTax: {
originalPrice: MoneyProps;
baseOriginalPrice: MoneyProps;
baseDiscountedPrice: MoneyProps;
baseExcludingTax: MoneyProps;
};
includeTax: {
singleItemPrice: MoneyProps;
baseOriginalPrice: MoneyProps;
baseDiscountedPrice: MoneyProps;
};
};
productSalePrice: MoneyProps;
status?: string;
currentReturnOrderQuantity?: number;
eligibleForReturn: boolean;
productSku?: string;
type?: string;
discounted?: boolean;
id: string;
productName?: string;
productUrlKey?: string;
regularPrice?: MoneyProps;
price: MoneyProps;
product?: OrderItemProductModel;
selectedOptions?: Array<{
label: string;
value: any;
}>;
thumbnail?: {
label: string;
url: string;
};
downloadableLinks: {
count: number;
result: string;
} | null;
prices: {
priceIncludingTax: MoneyProps;
originalPrice: MoneyProps;
originalPriceIncludingTax: MoneyProps;
price: MoneyProps;
discounts: {
label: string;
amount: { value: number };
}[];
};
itemPrices: {
priceIncludingTax: MoneyProps;
originalPrice: MoneyProps;
originalPriceIncludingTax: MoneyProps;
price: MoneyProps;
discounts: {
label: string;
amount: { value: number };
}[];
};
bundleOptions: Record<string, string> | null;
totalInclTax: MoneyProps;
priceInclTax: MoneyProps;
total: MoneyProps;
configurableOptions: Record<string, string | number | boolean> | undefined;
giftCard?: {
senderName: string;
senderEmail: string;
recipientEmail: string;
recipientName: string;
message: string;
};
quantityCanceled: number;
quantityInvoiced: number;
quantityOrdered: number;
quantityRefunded: number;
quantityReturned: number;
quantityShipped: number;
requestQuantity?: number;
totalQuantity: number;
returnableQuantity?: number;
quantityReturnRequested: number;
};