Skip to content
Jaah edited this page Aug 30, 2020 · 18 revisions

Place order

Placing order involves two steps:
Note: You should have an active checkout session. Read more about checkout session

Available methods:

Methods Returns Promise Description
addCoupon NO Add coupon code to your order
removeCoupon NO Remove coupon code to your order
setAddress NO Set address to your order
makeBill YES Prepare bill to place an order
placeOrder YES Place order

Add/Remove coupon to order.

  • To add coupon, call c.addCoupon({coupon:<coupon code>, phone:<phone no>})

Phone is required, if user is not loggedin.

  • To remove the coupon from your order, call c.removeCoupon()

Note: After adding/removing coupon you have to call makeBill()

1) Create a bill (Pre-processing).

.makeBill()

Important: The bill object will contain the available payment options for that specific order. User should not be allowed to select any other payment option while placing an order.

However, this values can be overridden by passing the obj in .makeBill.
c.makeBill will always have to be called before calling placing order.
c.makeBill will return the bill which includes all required information that can be shown in UI.

Note: charges, total, taxes should not be calculated client-side. Information will be available in the response of c.makeBill. Or the last generated bill can be accessed by calling .getBill

2) Set delivery address:

.setAddress(param)

If fulfillment mode is delivery you must provide a valid address:
You can call c.setAddress(param) where params can be:
Read more about user addresses

For logged in user param is {address_id}:

{
     address_id:<address_id>
}

For guest user the param is:

{
     address_1:<address line 1>,
     address_2:<address line 2 | Optional>,
     sub_locality: <sub locality>,
     city: <city>,
     pin: <pin | Optional>,
     lat: <latitude | Optional>, 
     lng: <longitude | Optional>     
}

3) Place order:

placeOrder(params)

Params:

{
    phone: <phone no>,
    payment_option: <cash | prepaid | payment_gateway>,
    delivery_datetime: <timestamp>,
    instructions: <instructions>
}

Important :

  • If the user is not logged in or the user is not registered, guest checkout can be enabled for the phone no. - Guest checkout
  • How to use Payment gateway.

How to handle delivery time:
There are two types of deliverable time:

  • Slot based time (i.e. 12:30pm - 3:30pm)
    Pass the day in milliseconds in delivery_datetime.
    Set start time in time_slot_start end time in time_slot_end and in the format hh:mm:ss
{
    phone: <phone no>,
    payment_option: <cash | prepaid | payment_gateway>,
    delivery_datetime: <timestamp>,
    instructions: <instructions>,
    time_slot_start: "10:00:00",
    time_slot_end: "12:30:00"
}

Time slots are part of store object. Refer store

  • Specific time (i.e. 4.30pm)
    Pass the time in milliseconds in delivery_datetime.

Note: delivery_datetime is a mandatory field for both specific delivery time or slot based delivery time.

Clone this wiki locally