Implementing Dynamically Priced Products
Learn how to implement dynamically priced products in Umbraco Commerce.
Sometimes products do not have a fixed price. Depending on the customer's requirements, the price of the product can change. Examples could be window blinds that a priced based on the size of the window, or wallpaper that is priced by the meter.
This guide shows you how to implement dynamically priced products in Umbraco Commerce.
Capturing User Input
Add a new field on the product's frontend page, to capture the desired length we want to purchase.

The selected length will reflect on the cart value.

To provide the correct calculations for an order, the captured data will need to go through two different processes behind the scenes:
Store the user input against the order line property.
Implement a custom order line calculator to calculate the prices based on the user input.
Storing the User Input
Add a new property to the
AddToCartDtoclass to capture the length.
Update the
AddToCartmethod of theCartSurfaceControllerto store the length against the order line as a property.
Calculating the Order Line Price
We will calculate the price/tax rate of a given order line by multiplying the specified length by the unit price. This is done using a custom order line calculator.
Create a new class that implements the
IOrderLineCalculatorinterface.
Register the custom calculator in the
Startup.csfile or in anIComposer.
Backoffice UI
A useful extra step is to expose the captured data in the order's details in the Backoffice.
This is implemented as a custom UI Extension.
Create a new umbraco-package.json file in a folder in the App_Plugins directory in the root of your project and add the following code:
The length property is now displayed in the order details in the Backoffice.

Last updated
Was this helpful?