More in Learn

Creating Orders

So far, we have only worked with fetching data via the Order API. This section explains how you can create an order using the API. It’s also possible to create and manage orders using the Crystallize App.

In order to perform these operations, ensure that you have the proper authentication (if necessary) and user permissions.

Create Order

In order to create an order via the API, we’ll be using GraphQL mutations. Refer to our GraphQL sample for creating an order, which is part of our example repository. Also check out the API docs at https://api.crystallize.com/your-tenant-identifier/orders for the full list of parameters you can specify and fetch.

The example mutation below takes information about the customer and the cart, as well as the payment details. Once an order is created, you get back the order ID.

Note that orders are created asynchronously. There is no guarantee that the order will be retrievable immediately after registering it.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Multiple Items in Cart

The example mutation above only has a single item in the cart. You can add multiple items to the cart as shown below:

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Order Metadata

In case you’d like to add more information to your order, such as information about which warehouse the product would be shipped from, you can use the meta field. Data in this field is provided as key-value pairs, as shown below.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

Additional Information

The additionalInformation field takes a string value. A good use case for this would be for when a customer makes an additional request while placing an order, such as adding a message to a gift card.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...
People showing thumbs up

Need further help?

Join and ask our
slack community.

Join our slack community