Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Place an order via the Commerce Layer CLI

Place an order for a t-shirt via the Commerce Layer CLI

  1. Search for the desired t-shirt:
commercelayer resources:get skus -w name_i_cont_all=t-shirt,pink -w name_not_i_cont_all=women,white

Example ID of t-shirt selected: NzWOpOSyBx.

  1. Get the markets:
cl resources:get markets

Example ID of market selected: DvlGRmhdgX.

  1. Create a new order:
cl resources:create orders -r market=markets/DvlGRmhdgX

Example ID of order created: eqkykhrAwO.

  1. Create a line item:
cl resources:create line_items -a quantity=1 -r order=orders/eqkykhrAwO -r item=skus/NzWOpOSyBx

Example ID of line item created: EvPrYtbryZ.

  1. Check if the line_item has been added correctly:
cl resources:get orders eqkykhrAwO -i=line_items
  1. Update the order with a customer (customer creation shorthand):
cl resources:update orders/eqkykhrAwO -a
  1. Check if the customer has been added correctly:
cl resources:get orders eqkykhrAwO -i=customer

Example ID of customer created: lnjmyhjykx.

  1. Create an address:
cl resources:create addresses -a first_name=Silvio last_name=Relli line_1="Via Foo Bar, 123" city=Florence zip_code=50100 state_code=FI country_code=IT phone=33812345678

Example ID of address created: YBoeluGlWN.

  1. Update the order with the address:
cl resources:update orders/eqkykhrAwO -r billing_address=addresses/YBoeluGlWN shipping_address=addresses/YBoeluGlWN
  1. Check if the address has been added correctly:
cl resources:get orders eqkykhrAwO -i billing_address,shipping_address
  1. Get the order shipments and the available shipping methods:
cl resources:get orders eqkykhrAwO -i shipments,shipments.available_shipping_methods

Example ID of order shipment created: WPwnrCkJep. Example ID of shipment method selected: JnEdaPFAOP.

  1. Update the shipment with the selected shipping_method:
cl resources:update shipments/WPwnrCkJep -r shipping_method=shipping_methods/JnEdaPFAOP
  1. Check if the shipping method has been added correctly:
cl resources:get shipments WPwnrCkJep -i shipping_method
  1. Get the available payment methods for the order:
cl resources:get orders eqkykhrAwO -i available_payment_methods

Example ID of payment method created: gXmLyeszkP.

  1. Update the order with the selected payment method:
cl resources:update orders/eqkykhrAwO -r payment_method=payment_methods/gXmLyeszkP
  1. Create the payment source and add it to the order:
cl resources:create wire_transfer -r order=orders/eqkykhrAwO
  1. Check if the payment method and the payment source have been added correctly:
cl resources:get orders eqkykhrAwO -i payment_method,payment_source
  1. Place the order:
cl resources:update orders/eqkykhrAwO -a _place=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment