@nuskin/order-model
v3.1.3
Published
Order Model and conversion utility functions based on cart object and SalesOrder
Downloads
1,017
Keywords
Readme
@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.
Installing
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
Resources
- Commercetools cart object: https://docs.commercetools.com/api/projects/carts