Shipping Extensions
A collection of shipping calculators, checkers and promotion conditions that help you create customizable shipping options.
A collection of shipping calculators, checkers and promotion conditions that help you create customizable shipping options:
- Country and Weight: Shipping eligibility checker that checks if an order has the configured weight and is placed in country.
- Facet Value and Country: Shipping eligibility checker that checks if an order has configured facet values and is placed in country.
- Flat Rate Item Based Shipping calculator: Flat rate shipping calculator, that uses the highest tax rate of order lines or surcharges as the shipping tax rate.
- Distance based Shipping calculator, to calculate your shipping price based on the distance from your store
- A promotion condition that checks the order's shipping country. For example to only give free shipping to countries X, Y and Z
Getting started
- Add the following to the plugins in
vendure-config.ts:
- Start your server
- Login to the admin UI and go to
Shipping methods - Create a new shippingmethod
- Under
Shipping eligibility checkeryou should seeCheck by weight and countryandCheck by facet and country - Under
Shipping calculatoryou should seeDistance Based Shipping Calculator - Under Promotions conditions you should see
Order is in countrycondition.
Shipping by weight and country
Some examples:
- Create a shipping method for orders placed in Australia, with a total order weight between 10kg and 40kg
- Create a shipping method for all orders except the ones placed in Canada and Norway, with a total order weight below 1100 grams
The weight of a product can be configured on the customfield Product.weight. You can configure the units to be in KG,
grams or whatever unit you like.
Custom weight calculation
By default, the plugin will calculate the weight of an order based on the custom field weight:
- It will use the
productVariant.customFields.weightof each order line - If that's not set, it will look for the
productVariant.product.customFields.weightof each order line.
If you'd like to change this behaviour, you can specify a custom weightCalculationFunction:
Shipping by facets and country
Similar to the Shipping by weight and country, this shipping eligibility checker allows you to create shipping methods for orders that have certain facets and are placed in a country, for example:
- Shipping method is eligible for orders placed in BE, NL and all items in cart have facet
Mailbox package
Additional eligibility check
You can configure an additional eligibility check that can block the final eligibility check. This is then applied to all eligibility checks.
For example: You have different methods configured based on weights and countries, but you only allow pick up for oversized items. You can then configure the plugin to always return false when the order has an oversized item in cart:
Distance based shipping calculator
A configurable OrderAddressToGeolocationConversionStrategy is used to convert the shippingAddress of an Order to a geographic latitudinal and longitudinal, which in turn is used to calculate the distance. The built-in strategy converts a UK postalcode to a lat/lon.
To support distance based calculation in other countries you'd have to implement your own strategy:
Changelog
- Upgraded to Vendure 3.5.3
- Documentation update
- Updated official documentation URL
- Upgrade to Vendure to 3.3.2
- Don't hydrate order object in
weightAndCountryChecker, this caused tax calculations to be incorrect
- Don't hydrate order object in
getHighestTaxRateOfOrder, this causes discounts to be lost
- Removed
ZoneAwareShippingCalculator - Added
flatRateSurchargeFnto add surcharges to the Flat Rate calculator based on custom logic
- Deprecated
ZoneAwareShippingCalculator. Tax of shipping should be dependent on items in cart. - Added
FlatRateItemBasedShippingCalculator: Flat rate shipping calculator with tax based on the items in cart. - Added additional eligibility strategies, to make the shipping checkers in this plugin not eligible based on consumers custom logic.
- Added new shipping checker: Check by country and facet values
- Optimization of the Weight and Country checker: Hydrate all
lines.productVariant.productin one call.
- Update Vendure to 3.1.1
- Resolve to channels default tax zone if no tax rate found
- Update compatibility range (#480)
- Added zone aware shipping calculator and tax category form input component
- Updated Vendure to 2.2.6
- Fix #417
- Include
RequestContextas an additional argument toShippingExtensionsOptions.weightCalculationFunction
- Made
ShippingExtensionsOptions.weightCalculationFunctionasync and acceptInjectoras an additional argument
- Don't log errors when invalid postalcode for UK strategy
- Distance based strategies are allowed to return an undefined geolocation
- Added
orderInCountryPromotionCondition, which checks if the order's shipping country matches one of the configured countries
- Added minimum price instead of fallback price.
- Fallback was removed in favor of a minimum price
- Allow setting a fallback price for distance based calculator
- Allow a custom weightCalculationFunction
- Docs update
- Added distance based
ShippingCalculator - Introduced
OrderAddressToGeolocationConversionStrategy
- Updated vendure to 2.1.1
