Ecwid.OnOrderPlaced

Ecwid.OnOrderPlaced() event allows you to get details of an order placed by a customer in storefront right after an order is placed. This event provides the order object in callback function so that you can get order details right after the event occurs.

Get order number of a placed order:

Ecwid.OnOrderPlaced.add(function(order){
  console.log(order.orderNumber);
});

// 781

📘

Alternatively, you can execute your code using the custom tracking code feature

Order object

Describes the details of a placed order by customer.

Fields

NameTypeDescription
itemsArray<OrderItems>Items purchased in order
productsQuantityintegerTotal quantity of purchased items in order
couponNamestringApplied coupon name. undefined if no coupon was used
weightnumberTotal order weight
paymentMethodstringSelected payment method name. undefined if no method selected
shippingCarrierNamestringSelected shipping carrier name. undefined if no method selected
shippingMethodstringSelected shipping method name. undefined if no method selected
totalnumberOrder total
totalWithoutTaxnumberOrder total without taxes
subtotalnumberOrder subtotal
subtotalWithoutTaxnumberOrder subtotal without taxes
taxnumberOrder total tax
couponDiscountnumberCoupon discount applied to order
volumeDiscountnumberSum of discounts based on subtotal
customerGroupDiscountnumberSum of discounts based on customer group
discountnumberTotal discount amount for order
shippingnumberTotal shipping cost for order
shippingWithoutTaxnumberTotal shipping cost for order without taxes
handlingFeenumberHandling fee applied to order
handlingFeeWithoutTaxnumberHandling fee applied to order without taxes
shippingAndHandlingnumberSum of shipping and handlingFee fields
billingPerson<PersonInfo>Customer billing information
shippingPerson<PersonInfo>Customer shipping information
affiliateIdstringAffiliate ID value for order
orderNumbernumberInternal order ID [Deprecated]
vendorNumberstringOrder ID. It is the same ID as order has in idfield here: Get order
datestring (UNIX Timestamp)Date when order was placed as a UNIX Timestamp, e.g. "1484638550"
paymentStatusstringPayment status of an order. One of: AWAITING_PAYMENT, PAID, CANCELLED, REFUNDED, PARTIALLY_REFUNDED, INCOMPLETE
fulfillmentStatusstringFulfillment status of an order. One of: AWAITING_PROCESSING, PROCESSING, SHIPPED, DELIVERED, WILL_NOT_DELIVER, RETURNED, READY_FOR_PICKUP
customer<CustomerInfo>Basic customer info
extraFields<OrderExtraFieldsInfo>Information about extra fields in the order

OrderItems

NameTypeDescription
quantityintegerQuantity of an item in order
product<ProductInfo>Product details
optionsMap<OptionsInfo>Selected product options

ProductInfo

NameTypeDescription
idIntegerInternal unique product ID
nameStringProduct name
priceIntegerProduct price
shortDescriptionStringProduct description truncated to 120 characters
skuStringProduct SKU
urlStringURL to this product details page in store front (store front URL is generated from a field in Ecwid Control panel > Settings > General > Store profile)
weightIntegerWeight of a product

OptionsInfo

NameTypeDescription
selectedOptionstringSelected option name as a key, its value as a value of that key. For dropdown, radio, textarea, textfield options value is a string; for checkbox option the value is a comma-separated list of selected values in a single string; for date option the value is a selected date according to the store format; for files option the value is a string in a format: "4 files"

PersonInfo

NameTypeDescription
namestringCustomer's name
companyNamestringCustomer's company name
streetstringCustomer's street address
citystringCustomer's city
countryNamestringCustomer's country name. countryCode can be used instead
countryCodestringCustomer's country code. countryName can be used instead
postalCodestringCustomer's zip code
stateOrProvinceCodestringCustomer's state or province code
stateOrProvinceNamestringCustomer's state or province name
phonestringCustomer's phone number

CustomerInfo

NameTypeDescription
namestringCustomer's name
emailstringCustomer's email

OrderExtraFieldsInfo

NameTypeDescription
orderByintegerExtra field position at an order section in Ecwid Control Panel. The smaller the number, the higher the position is
titlestringTitle of the field
orderDetailsDisplaySectionstringSection where the extra field is displayed
typestringType of the field
valuestringWhat the user has typed in/selected