Buy online, pickup in store
Buy online, pickup in store (BOPIS) is a popular fulfillment option that allows customers to purchase items online and pick them up in-store.
The Commerce boilerplate template does not include a BOPIS checkout flow by default, but you can easily implement one using Adobe’s drop-in components.
Step-by-step
The following steps describe how to modify the commerce-checkout.js block file in the boilerplate template to allow users to choose between delivery and in-store pickup during the checkout process.
Prerequisites
Before you start, you must configure in-store delivery options in the Adobe Commerce Admin to define pickup locations. The fetchPickupLocations
function retrieves the list of available pickup locations using a GraphQL query.
Update content fragment
To create a new section for the delivery options, additional DOM elements are required. You can add these elements by modifying the content fragment.
You must also add new selectors to render the required components and content.
Add toggle buttons
During initialization, the code renders two buttons:
- Delivery
- In-store pickup
These buttons allow users to toggle between the two options.
Toggle between options
The onToggle
function manages switching between the delivery and in-store pickup options. It updates the selected state of the buttons and toggles the visibility of the corresponding forms.
Fetch pickup locations
The fetchPickupLocations
function retrieves the list of available pickup locations using a GraphQL query. Users can choose a location where they’d like to pick up their order.
Render location options
After the code fetches the pickup locations, it renders options as radio buttons. The user can select a location, which updates the shipping address with the corresponding pickup location code.
Finalize the flow
After a user selects In-store pickup and chooses a location, the pickup form is shown, while the shipping form is hidden. This provides a clear and seamless way for users to choose how they want to receive their order.
Example
See blocks/commerce-checkout-bopis
in the demos
branch of the boilerplate repository for complete JS and CSS code for the BOPIS checkout flow.