Skip to main content

Orders

Fetch Orders#

Return the list of orders for the current user.

Params#

NameType
NoneNone
FlyBuy.Core.Orders.fetchOrders();

Create Order using Site ID#

Create a new order for the current user.

By default, orders are created with a state of created. If you wish to provide a different OrderState, you can provide that optional argument. If you do not wish to provide a different state, omit the parameter.

Most orders will have a pickup time of “ASAP”. If you have a different pickup window, you can pass a pickupWindow parameter. If you want the default of “ASAP”, omit the parameter.

Params#

This function only needs an object as a param.

NameTypeExample
siteIdInt15942
pidStr'573836'
customerInfoCustomerInfo{name: 'Lamia Selmane',carType: 'Tesla',carColor: 'Silver',licensePlate: 'AB 0496' phone: '555-555-5555',}
pickupWindowPickupWindow{start: new Date().toISOString(),end: new Date('2022-12-02').toISOString(),}
orderStateStr'delayed'
pickupTypeStr'delivery'

Example#

const pickupWindow = {
start: new Date().toISOString(),
end: new Date('2022-12-02').toISOString(),
};
FlyBuy.Core.Orders.createOrder({
siteId: 15942,
pid: '573836',
customerInfo: {
name: 'Lamia Selmane',
carType: 'Tesla',
carColor: 'Silver',
licensePlate: 'AB 0496',
phone: '555-555-5555',
},
pickupWindow: pickupWindow,
orderState: 'delayed',
pickupType: 'delivery'
});

Create Order using Site Partner Identifier#

If the app does not have the Flybuy siteID or only wants to create the order if the site operational status is live, the sitePartnerIdentifier can be used to create an order. An orderPartnerIdentifier and customerInfo also need to be provided. This customer information does not need to be the same as the customer that is logged in. It should be the information for the person that is picking up the order.

Optionally, the orderState, pickupType, and pickupWindow can be set when creating an order if these are not created via a backend integration.

Most orders will have a pickup time of “ASAP”. If you have a different pickup window, you can pass a pickupWindow parameter. If you want the default of “ASAP”, omit the parameter.

Params#

This function only needs an object as a param.

NameTypeExample
sitePidStrsitePartnerIdentifier: '15942'
orderPidStrorderPartnerIdentifier: '573836'
customerInfoCustomerInfo{name: 'Lamia Selmane',carType: 'Tesla',carColor: 'Silver',licensePlate: 'AB 0496' phone: '555-555-5555',}
pickupWindowPickupWindow{start: new Date().toISOString(),end: new Date('2022-12-02').toISOString(),}
orderStateStr'delayed'
pickupTypeStr'delivery'

Example#

const pickupWindow = {
start: new Date().toISOString(),
end: new Date('2022-12-02').toISOString(),
};
FlyBuy.Core.Orders.createOrder({
sitePid: '15942',
orderPid: '573836',
customerInfo: {
name: 'Lamia Selmane',
carType: 'Tesla',
carColor: 'Silver',
licensePlate: 'AB 0496',
phone: '555-555-5555',
},
pickupWindow: pickupWindow,
orderState: 'delayed',
orderType: 'delivery'
});

Claim Order#

Claim an order for the current customer.

Params#

NameTypeExample
pidStr'9898899'
customerInfoCustomerInfo{name: 'Lamia Selmane',carType: 'Tesla',carColor: 'Silver',licensePlate: 'AB 0496',phone: '555-555-5555',}
pickupTypeStr'pickup'

Example#

FlyBuy.Core.Orders.claimOrder(
'9898899',
{
name: 'Lamia Selmane',
carType: 'Tesla',
carColor: 'Silver',
licensePlate: 'AB 0496',
phone: '555-555-5555',
},
'pickup'
);

Update Order State#

You can update an order’s state, if necessary, with any valid state:

Params#

NameTypeExample
orderIDInt46084566
stateStr'ready'

Example#

FlyBuy.Core.Orders.updateOrderState(46084566, 'ready');

Update Order Customer State#

Params#

NameTypeExample
orderIDInt46084566
stateStr'departed'

Example#

FlyBuy.Core.Orders.updateOrderCustomerState(46084566, 'departed');

Send spot identifier#

Params#

NameTypeExampleDescription
orderIDInt46084566
stateStr'waiting'
spotStr'1'Max 35 characters

Example#

FlyBuy.Core.Orders.updateOrderCustomerStateWithSpot(46084566, 'departed', '1');

Rate Order#

If you collect customer ratings in your app, you can pass them to Flybuy.

Params#

NameTypeExample
orderIDInt46084566
ratingInt5
commentsStr'Awesome!'

Example#

FlyBuy.Core.Orders.rateOrder(46084566, 5, 'Awesome!');

Listen to orders update#

Set up event listeners to get updates about orders.

Example#

React.useEffect(() => {
const eventListener = FlyBuy.eventEmitter.addListener(
'orderUpdated',
(event) => {
console.log('event', event);
}
);
return () => {
eventListener.remove();
};
}, []);