placeOrder(action: BasketAction, shouldRedirect: boolean): Promise<void>¶
The placeOrder
method allows to place an order.
Input parameters¶
action¶
action
is a mandatory parameter of the BasketAction type that represents the action that we want to perform with a given order.
shouldRedirect¶
shouldRedirect
is a mandatory parameter of the boolean
type that represents whether the user should be redirected to the page where their full order is shown or should this page just be visited. The difference is that the whole page refreshes during redirecting and visiting skips this step.
Returned value¶
A returned value has a type of Promise<void>
as it returns nothing.
Example¶
In this example we make a basketUpdaterApi
call to place an order. We also retrieve a place order action with the help of a basketOverallApi
useStorefront(async (storefront) => {
const basketOverallApi = storefront.getApiSync('basketOverallApi');
const basketUpdaterApi = storefront.getApiSync('basketUpdaterApi');
const placeOrderAction = basketOverallApi.getActions().placeOrder;
basketUpdaterApi.placeOrder(placeOrderAction, false);
});
Basket Updater API methods reference¶
- getBasket - Retrieve the contents of a basket
- getCurrentBasket - Retrieve the current active basket
- refreshBasket - Refresh the contents of a basket
- addItem - Add an item to the basket
- emitUpdateBasketEvent - Emit an update basket event
- uploadVariantFile - Upload a file for a variant
- queueOrder - Queue an order for processing