Shipping Labels
The default shipping label generator service creates an empty PDF, but we'll make the default implementation a little more useful soon.
Replacing the ShippingLabelGeneratorService
Implement IShippingLabelGeneratorService, for example:
public class CustomShippingLabelGeneratorService : IShippingLabelGeneratorService
{
public CustomShippingLabelGeneratorService() { }
public async Task<GeneratedDocumentResponse> GenerateLabel(Order order)
{
var memoryStream = new MemoryStream();
/// ...
return new GeneratedDocumentResponse()
{
ContentType = "application/pdf",
Name = "ShippingLabel.pdf",
Stream = memoryStream,
};
}
}
Now register this as a singleton using a composer:
public class CustomShippingLabelGeneratorComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.AddSingleton<IShippingLabelGeneratorService, CustomShippingLabelGeneratorService>();
}
}
Note that Rescope.Commerce.Shipping.*
packages already include the above composer.