Digital Products
Digital products include things like ebooks, online courses, and software. They are products that are delivered to the customer electronically, and do not require physical shipping.
This guide will show you how you can add support for digital products to Vendure.
Creating the plugin
The complete source of the following example plugin can be found here: example-plugins/digital-products
Define custom fields
If some products are digital and some are physical, we can distinguish between them by adding a customField to the ProductVariant entity.
You will need to create a migration after adding this custom field. See the Migrations guide for more information.
We will also define a custom field on the ShippingMethod entity to indicate that this shipping method is only available for digital products:
Lastly we will define a custom field on the Fulfillment entity where we can store download links for the digital products. If your own implementation you may
wish to handle this part differently, e.g. storing download links on the Order entity or in a custom entity.
Create a custom FulfillmentHandler
The FulfillmentHandler is responsible for creating the Fulfillment entities when an Order is fulfilled. We will create a custom handler which
is responsible for performing the logic related to generating the digital download links.
In your own implementation, this may look significantly different depending on your requirements.
This fulfillment handler should then be added to the fulfillmentHandlers array the config ShippingOptions:
Create a custom ShippingEligibilityChecker
We want to ensure that the digital shipping method is only applicable to orders containing at least one digital product. We do this with a custom ShippingEligibilityChecker:
Create a custom ShippingLineAssignmentStrategy
When adding shipping methods to the order, we want to ensure that digital products are correctly assigned to the digital shipping method, and physical products are not.
Define a custom OrderProcess
In order to automatically fulfill any digital products as soon as the order completes, we can define a custom OrderProcess:
Complete plugin & add to config
The complete plugin can be found here: example-plugins/digital-products
We can now add the plugin to the VendureConfig:
Create the ShippingMethod
Once these parts have been defined and bundled up in a Vendure plugin, we can create a new ShippingMethod via the Dashboard, and make sure to check the "isDigital" custom field, and select the custom fulfillment handler and eligibility checker:
Mark digital products
We can now also set any digital product variants by checking the custom field:
Storefront integration
In the storefront, when the customer is checking out, we can use the eligibleShippingMethods query to determine which shipping methods
are available to the customer. If the customer has any digital products in the order, the "digital-download" shipping method will be available:
If the "digital download" shipping method is eligible, it should be set as a shipping method along with any other method required by any physical products in the order.

