CreateCart

Overview

A method of the Cart Service which creates a new shopping cart.

Request

Field Name

Data Type

Description

accountID

string

A unique identifier representing the ChannelAdvisor account you wish to access.

buyerEmail

string

E-mail of the buyer you wish to create an cart for.

lineItem

CartItemRequest[]

An array of items to place in the shopping cart

Example of SOAP Request for CreateCart

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/" xmlns:ord="http://api.channeladvisor.com/datacontracts/orders">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey> --- </web:DeveloperKey>
         <web:Password> --- </web:Password>
      </web:APICredentials>
   </soapenv:Header>
   <soapenv:Body>
      <web:CreateCart>
         <web:accountID> --- </web:accountID>
         <web:buyerEmail>JamesJ@channeladvisor.com</web:buyerEmail>
         <web:lineItem>
            <!-Zero or more repetitions:->
            <web:CartItemRequest>
               <ord:SKU>Disco Lights1</ord:SKU>
               <ord:Title>Groovy Item</ord:Title>
               <ord:LineItemID>0</ord:LineItemID>
               <ord:Quantity>2</ord:Quantity>
               <ord:ItemSaleSource>DEMANDWARE_STORE</ord:ItemSaleSource>
               <ord:UnitPrice>45.00</ord:UnitPrice>
               <ord:AllowNegativeQuantity>true</ord:AllowNegativeQuantity>
            </web:CartItemRequest>
         </web:lineItem>
      </web:CreateCart>
   </soapenv:Body>
</soapenv:Envelope>

Response

Field Name

Data Type

Description

CreateCartResult

APIResult<Cart>

This method returns a type named APIResultOfCart. See more information on APIResult. The cart information returned by this method will be contained in the ResultData field.

CurrencyCode

string

Return value based on account settings

UnitWeight UnitOfMeasure

integer

Return value based on account settings

Example Response from CreateCart

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <CreateCartResponse xmlns="http://api.channeladvisor.com/webservices/">
         <CreateCartResult>
            <Status>Success</Status>
            <MessageCode>0</MessageCode>
            <ResultData>
               <CartID xmlns="http://api.channeladvisor.com/datacontracts/orders">9179469</CartID>
               <CheckoutURL xmlns="http://api.channeladvisor.com/datacontracts/orders">http://chnla.beta.channeladvisor.com/r.asp?p=12001097&amp;t=10584732&amp;i=9179469</CheckoutURL>
               <LineItemList xmlns="http://api.channeladvisor.com/datacontracts/orders">
                  <CartItem xsi:type="CartItemResponse">
                     <SKU>Disco Lights1</SKU>
                     <Title>Groovy Item</Title>
                     <LineItemID>140750</LineItemID>
                     <Quantity>2</Quantity>
                     <ItemSaleSource>DEMANDWARE_STORE</ItemSaleSource>
                     <UnitPrice>45.0000</UnitPrice>
                     <CurrencyCode>USD</CurrencyCode>
                     <UnitWeight UnitOfMeasure="LB">1</UnitWeight>
                  </CartItem>
               </LineItemList>
            </ResultData>
         </CreateCartResult>
      </CreateCartResponse>
   </soap:Body>
</soap:Envelope>

Request with 2 SKUs

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/" xmlns:ord="http://api.channeladvisor.com/datacontracts/orders">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey>  XXX </web:DeveloperKey>
         <web:Password> XXX </web:Password>
      </web:APICredentials>
   </soapenv:Header>
   <soapenv:Body>
      <web:CreateCart>
         <web:accountID> XXX </web:accountID>
         <web:buyerEmail>James@channeladvisor.com</web:buyerEmail>
         <web:lineItem>
            <!-Zero or more repetitions:->
            <web:CartItemRequest>
               <ord:SKU>Disco Lights1</ord:SKU>
               <ord:Title>Groovy Item</ord:Title>
               <ord:LineItemID>0</ord:LineItemID>
               <ord:Quantity>2</ord:Quantity>
               <ord:ItemSaleSource>DEMANDWARE_STORE</ord:ItemSaleSource>
               <ord:UnitPrice>45.00</ord:UnitPrice>
               <ord:AllowNegativeQuantity>true</ord:AllowNegativeQuantity>
            </web:CartItemRequest>
            <web:CartItemRequest>
               <ord:SKU>Disco Lights2</ord:SKU>
               <ord:Title>Groovy Item</ord:Title>
               <ord:LineItemID>0</ord:LineItemID>
               <ord:Quantity>3</ord:Quantity>
               <ord:ItemSaleSource>DEMANDWARE_STORE</ord:ItemSaleSource>
               <ord:UnitPrice>4.00</ord:UnitPrice>
               <ord:AllowNegativeQuantity>true</ord:AllowNegativeQuantity>
            </web:CartItemRequest>
         </web:lineItem>
      </web:CreateCart>
   </soapenv:Body>
</soapenv:Envelope>

Response with 2 SKUs

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <CreateCartResponse xmlns="http://api.channeladvisor.com/webservices/">
         <CreateCartResult>
            <Status>Success</Status>
            <MessageCode>0</MessageCode>
            <ResultData>
               <CartID xmlns="http://api.channeladvisor.com/datacontracts/orders">9179487</CartID>
               <CheckoutURL xmlns="http://api.channeladvisor.com/datacontracts/orders">http://chnla.beta.channeladvisor.com/r.asp?p=12001097&amp;t=10584786&amp;i=9179487</CheckoutURL>
               <LineItemList xmlns="http://api.channeladvisor.com/datacontracts/orders">
                  <CartItem xsi:type="CartItemResponse">
                     <SKU>Disco Lights1</SKU>
                     <Title>Groovy Item</Title>
                     <LineItemID>140756</LineItemID>
                     <Quantity>2</Quantity>
                     <ItemSaleSource>DEMANDWARE_STORE</ItemSaleSource>
                     <UnitPrice>45.0000</UnitPrice>
                     <CurrencyCode>USD</CurrencyCode>
                     <UnitWeight UnitOfMeasure="LB">1</UnitWeight>
                  </CartItem>
                  <CartItem xsi:type="CartItemResponse">
                     <SKU>Disco Lights2</SKU>
                     <Title>Groovy Item</Title>
                     <LineItemID>140757</LineItemID>
                     <Quantity>3</Quantity>
                     <ItemSaleSource>DEMANDWARE_STORE</ItemSaleSource>
                     <UnitPrice>4.0000</UnitPrice>
                     <CurrencyCode>USD</CurrencyCode>
                     <UnitWeight UnitOfMeasure="LB">1</UnitWeight>
                  </CartItem>
               </LineItemList>
            </ResultData>
         </CreateCartResult>
      </CreateCartResponse>
   </soap:Body>
</soap:Envelope>

References