Basics: Orders

Basics: Orders

Introduction

This section will cover the basics of order related APIs.

API Reference

You can find all available BigCommerce module methods and their description in the API Reference.

Order creation is handled through the Embedded Checkout

Get Orders

To get an orders data associated to the customer, you can use the Get Orders method.

The customer must be authenticated first to use this method. The id of the customer and the channel will be picked up from the requests's cookie.

import { sdk } from '~/sdk.config.ts';
 
const ordersResponse = await sdk.bigcommerce.getOrders();

Get Order By Cart

To fetch data about an order made for a certain cart, you can use the getOrderByCart method, by passing the cart id.

This method will make three calls, combine the data and return it in a single object:

  1. Get Orders
  2. Get Order Products
  3. Get Order Addresses
import { sdk } from '~/sdk.config.ts';

const getOrderByCartResponse = await sdk.bigcommerce.getOrderByCart({
 cartId: '7c3ab631-782c-4747-8ccc-873e87de5152'
})

Get Orders With Details

To fetch data about multiple orders made for a certain cart, you can use the getOrdersWithDetails method, by passing the cart id.

This method will make three calls, combine the data and return it in a single object:

  1. Get Orders
  2. Get Order Products
  3. Get Order Addresses
import { sdk } from '~/sdk.config.ts';

const getOrdersWithDetailsResponse = await sdk.bigcommerce.getOrdersWithDetails({
 cart_id: '7c3ab631-782c-4747-8ccc-873e87de5152'
})

Get Order Products

To fetch the products data for a placed order, you can use the getOrderProducts method. The customer must be authenticated first and the id of the customer will be picked up from the requests's cookie.

import { sdk } from '~/sdk.config.ts';
const orderProductsResponse = await sdk.bigcommerce.getOrderProducts({ orderId: 286 })

Get Order Shipping Addresses

To fetch a shipping address for a placed order, you can use the get method. The customer must be authenticated first and the id of the customer will be picked up from the requests's cookie.

import { sdk } from '~/sdk.config.ts';

const orderShippingAddressResponse = await sdk.bigcommerce.getOrderShippingAddresses({ orderId: 286 })