Carts

Carts

Handle Tillhub Carts from the v1 Model

Constructor

new Carts()

Source:
Examples
// create a cart from existing products in order to sell them on the POS clients
const Tillhub = require('@tillhub/node-sdk')

const th = new Tillhub({
  credentials: {
    username: 'user@example.com',
    password: '123455'
  }
})

await th.init()
const carts = th.carts()

const { data, metadata } = await carts.create({
  items: [
    {
      product: '880ddc0c-7351-45de-99ba-d42541d64fc2',
      qty: 1,
      currency: 'EUR'
    }
  ]
})
console.log(data)
// {
//   id: '7c1d5998-b421-4531-8e9d-443ed7f17c22',
//   [...]
//   items: [
//     {
//       product: '880ddc0c-7351-45de-99ba-d42541d64fc2',
//       qty: 1,
//       currency: 'EUR',
//       vat_rate: 0.19,
//       tax: 'd524e4c5-704c-43a2-ba62-5e6cf275045c',
//       account: '3621c565-9002-4392-9274-1da57ea89c25',
//       amount: {
//         gross: 10.99
//       }
//       [...]
//     }
//   ]
// }
// get all the carts

const Tillhub = require('@tillhub/node-sdk')

const th = new Tillhub({
  credentials: {
    username: 'user@example.com',
    password: '123455'
  }
})

await th.init()
const carts = th.carts()

const { data, metadata } = await carts.getAll()
console.log(data) // [...]

Methods

create(cart, optionsOrCallbackopt, callbackopt)

Create a cart to consume in Tillhub Clients.

Parameters:
Name Type Attributes Description
cart Object

the cart body

optionsOrCallback Object | function <optional>

query for carts with allowed paramaters, or specify an optional callback

callback function <optional>

optional callback. If not specified, this function returns a promise

Source:

getAll(queryOrCallbackopt, callbackopt)

Get all carts from client account.

Parameters:
Name Type Attributes Description
queryOrCallback Object | function <optional>

query for carts with allowed paramaters, or specify an optional callback

callback function <optional>

optional callback. If not specified, this function returns a promise

Source: