A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.umbraco.com/umbraco-commerce/how-to-guides/order-number-customization below:

Order Number Customization | Umbraco Commerce

Order Number Customization | Umbraco Commerce
  1. How-To Guides
Order Number Customization

Learn how to customize the default order number generated in Umbraco Commerce.

In Umbraco Commerce, the default order number generation can be customized by implementing the IOrderNumberGenerator interface. This interface defines two methods: GenerateCartNumber(Guid storeId) and GenerateOrderNumber(Guid storeId), which you can override to create a custom numbering system.​

Implementing a Custom Order Number Generator

To create a custom order number generator, define a class that implements the IOrderNumberGenerator interface, for example, CustomOrderNumberGenerator.cs:

CustomOrderNumberGenerator.cs
using Umbraco.Commerce.Core.Generators;

public class CustomOrderNumberGenerator : IOrderNumberGenerator
{
    public string GenerateCartNumber(Guid storeId)
    {
        // Implement custom logic for cart numbers
    }

    public string GenerateOrderNumber(Guid storeId)
    {
        // Implement custom logic for order numbers
    }
}
Registering the Custom Implementation

After creating your custom generator, register it in Program.cs to replace the default implementation:

builder.Services.AddUnique<IOrderNumberGenerator, MyOrderNumberGenerator>();

The AddUnique method ensures that your custom generator replaces the default IOrderNumberGenerator. For more details on dependency injection, see the Dependency Injection article.

Before implementing a custom order number generator, be aware of the following:

By understanding these factors, you can implement a custom order number generator that aligns with your specific requirements while maintaining optimal performance and compliance.

Last updated 4 months ago


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4