Example 5: Extending the checkout flow
Both the multi-step and single-step checkout flows share most of their Blocks, which makes it easy to maintain both standard and custom code. Extending the checkout flow is straight forward.
Let’s say you want to add a notification that customers get free shipping on orders which exceed 500€ (you need a matching discount in the backend, but that won’t be covered here).
The procedure should be familiar by now:
- Open the eCom7/CartV2/Step/Blocks/CustomBlocks.cshtml template
- Add @using Dynamicweb.Rapido.Blocks.Extensibility to get a list of imported resources
- First, you want to calculate how much more a customer needs to buy for to qualify for free shipping:
- Then write the Block definition:
- Then, before adding the Block to the Checkout step, you want to verify that you’re on step 0 of the checkout flow – this ensures that the code works for both single and multi-step checkout – and also that the order does not already qualify for free shipping:
- Finally, write a small helper method for the markup:
After implementing the above, a single-step checkout flow should look like Figure 2.2).