Order Model and conversion utility functions based on cart object and SalesOrder

Usage no npm install needed!

<script type="module">
  import nuskinOrderModel from 'https://cdn.skypack.dev/@nuskin/order-model';



This module defines the order model for the web commerce platform. It consists of fields from the commercetools cart object, as well as fields from the SAP SalesOrder object. It also has functions to convert between this model and SAP SalesOrder objects.


Using npm:

npm add @nuskin/order-model

Using yarn:

yarn add @nuskin/order-model

Example usage

const { order: { Order } } = require('@nuskin/order-model');

// Create a new Order object from scratch
const myOrder1 = new Order({...});
// Create a new Order object from a SalesOrderRequest
const myOrder2 = Order.fromSalesOrderRequest(mySalesOrderRequest);
// Create a new Order object from a SalesOrderResponse
const myOrder3 = Order.fromSalesOrderResponse(mySalesOrderResponse);
// Convert an order to a SalesOrderRequest
const mySalesOrderRequest = myOrder2.toSalesOrderRequest();
// Convert an order to a SalesOrderResponse
const mySalesOrderResponse = myOrder3.toSalesOrderResponse();

Updating the Order Model

When adding or removing properties from the order model. Kindly also update the type definition, which you can find in @types/index.d.ts