• Log in
  • Contact Sales
  • Evaluate

Get in touch  

Concepts • Products

How Inventory works

Last updated: 01 Jul 2019

Our inventory service allows you and your business to keep track of the quantity of each product that you have in stock, including a transactional historic log.

There are 3 numbers associated with inventory in Moltin:

  • Total: The total number of products in the warehouse, including available and allocated (explained below)
  • Available: The total number of products minus those already allocated.
  • Allocated: For "reserved" products that are not available to buy, but are still in the warehouse.

Order flow

There are three mandatory steps to a complete Moltin order in relation to inventory:

  1. Added to a cart
  2. Checked out
  3. Paid
  4. Shipped (optional)

Unpaid order flow

The flowchart below depicts the process of an unpaid order.

assets_-LAd6Ukz09rrCC8fdze5_-LKX0qWkF8CF20rrtosd_-LKX13wdgty3w2Q75c2R_Unpaid Order Flow@2x

Payment flow

The flowchart below depicts the process of paying for an order.

assets_-LAd6Ukz09rrCC8fdze5_-LKXDJUaNNH0b2WVAaeJ_-LKXDOqsR9aZyBnZcqXa_Payment Flow@2x (1)

How stock is managed

When a customer attempts to add products to the cart, Moltin will first check if there is enough available stock. If there’s not enough stock available at that time, you will receive a 400 HTTP response from Moltin with a warning that there is not enough stock to cater for the requested quantity. It will not describe what products cannot be added, nor will it return how many are in stock at that time.

Should a customer be successful in adding products to a cart, because there is enough stock available, they can then check out, creating an unpaid order. When they attempt to checkout and create an unpaid order, a final check on available stock will be done.

Once the unpaid order has been created, payment can then be taken. As the user attempts to pay for an order, Moltin will allocate that stock (reserve stock, so it can’t be bought by anyone else) just before the payment is processed internally. Any time before this point of payment, a customer might lose their order, if they are slower than everyone else.

If the payment fails, the temporary stock allocation will be removed, and the stock will become available again for anyone to buy. If payment succeeds, that stock is still allocated, and the items are the customer’s, unless for any reason they are re-allocated before shipment, e.g. the customer cancels, or you realise the order is fraudulent. Finally, when the order is marked as shipped, that stock is finally fully decremented. That means the allocation number is reduced, and therefore the total, is no longer in the warehouse.

How to check inventory of a product

Make a request to the inventories service https://api.moltin.com/v2/inventories/:productId and expect this inventories response to be always up to date and accurate.

If you request a product directly, you will also notice a stock field, please do not use this field to read any stock values, as it is not currently updated. In future, this value will reflect the true inventory service value.

Implications of the Moltin inventories flows

  • It’s possible for more products to be in carts than there are in stock at that time.
  • It’s possible for more products to be checked out than there are in stock at that time.
  • It’s not possible for more stock to be paid for than is in stock at that time.
  • It’s a race for your customers to pay for an order, and whoever doesn’t pay fast enough, will be left disappointed.

Further reading

Explore More Concepts

01 Jul 2019

How to calculate cart and order totals

There are two methods that may be used to calculate cart and order totals. The method used depends on the calculation_method setting. The default is currently the simple method and this will continue...

Read More
author
James Carter
in Orders | Carts
18 Jun 2019

How promotions work

Promotions allow you to provide discounts to customers. By defining a Promotion and a code, you put in place the facility to offer discounts to customers applied directly to their shopping carts.

Read More
author
George FitzGibbons
in Carts | Promotions
06 Jun 2019

When to use a custom cart

Custom carts allow you to process an order for any type of item you wish to sell. The item does not need to exists in Moltin, which means custom cart items can be used for all sort of use cases.

Read More
author
George FitzGibbons
in Carts