Shipping & Fulfillment
Shipping in Vendure is handled by ShippingMethods. A ShippingMethod is composed of a checker and a calculator.
- The
ShippingEligibilityCheckerdetermines whether the order is eligible for the ShippingMethod. It can contain custom logic such as checking the total weight of the order, or whether the order is being shipped to a particular country. - The
ShippingCalculatorcalculates the cost of shipping the order. The calculation can be performed directly by the calculator itself, or it could call out to a third-party API to determine the cost.
Multiple shipping methods can be set up and then your storefront can query eligibleShippingMethods to find out which ones can be applied to the active order.
When querying eligibleShippingMethods, each of the defined ShippingMethods' checker functions is executed to find out whether the order is eligible for that method, and if so, the calculator is executed to determine what the cost of shipping will be for that method.
Shipping methods can be restricted to specific zones, allowing different shipping options based on the customer's location.
Fulfillments
Fulfillments represent the actual shipping status of items in an order. When an order is placed and payment has been settled, the order items are then delivered to the customer in one or more Fulfillments. For a detailed look at how fulfillments work, see the Fulfillment guide.
For details on creating custom checkers, calculators, and fulfillment handlers, see the Developer Guide.
Code Examples
Querying eligible shipping methods
Custom ShippingEligibilityChecker
Custom checkers can be created by defining a ShippingEligibilityChecker object.
For example, you could create a checker which works with a custom "weight" field to only apply to orders below a certain weight:
Custom checkers are then passed into the VendureConfig ShippingOptions to make them available when setting up new ShippingMethods:
Custom ShippingCalculator
Custom calculators can be created by defining a ShippingCalculator object.
For example, you could create a calculator which consults an external data source (e.g. a spreadsheet, database or 3rd-party API) to find out the cost and estimated delivery time for the order.
Custom calculators are then passed into the VendureConfig ShippingOptions to make them available when setting up new ShippingMethods:
If your ShippingEligibilityChecker or ShippingCalculator needs access to the database or other providers, see the configurable operation dependency injection guide.
Custom FulfillmentProcess
The fulfillment state machine can be customized by defining a FulfillmentProcess and passing it to your VendureConfig:
