Select version
v7.16 v7.13 v7.12 v7.11 v7.9 v7.8 v7.7 v7.6 v7.5 v7.3 v7.1 v7.0 v6.8 v6.7 v6.6 v6 v5 v4 v3 v2

Product Price Calculation

Whenever you're going to show prices on your frontend it being on the category listing or the product page you're going to use CatalogLibrary to get a price calculation for your product(s). In this article we'll go more in depth with how price calculations work.

How it works

The price calculation APIs and DTOs are designed to let you get multiple prices for multiple products in multiple price groups - if you want. This makes it easy to do price lists when browsing categories or product pages and lets you easy show different price points for the same product if you're using tiered pricing or differentiated pricing. Basically you'll get a matrix back where you can get the price for a product in a specific price group and a specific price tier.

Product Price Calculation DTOs

UCommerce.Catalog.Models.ProductPriceCalculationResult

Property Type Description
Properties IDictionary<string,object> Dynamic list of properties for custom use.
Items IList<UCommerce.Catalog.Models.ProductPriceCalculationResult.Item> Individual price calculations for products in different price groups and price tiers.

UCommerce.Catalog.Models.ProductPriceCalculationResult.Item

Property Type Description
Properties IDictionary<string,object> Dynamic list of properties for custom use.
ProductGuid Guid Identifier for the product
PriceGroupGuid Guid Identifier for the price group used.
Sku string Identifier for the product.
VariantSku string Identifier for the price group used. Null if product family.
MinimumQuantity int Associated with a price tier. This is the minimum amount of products you can have in your basket to fit this price tier.
MaximumQuantity int Associated with a price tier. This is the maximum amount of products you can have in your basket to fit this price tier.
PriceInclTax decimal The price the customer needs to pay with discounts subtracted including tax.
PriceExclTax decimal The price the customer needs to pay with discounts subtracted exluding tax.
PriceTax decimal tax for the calculated price.
ListPriceInclTax decimal List price for the product as configured in the backend including tax.
ListPriceExclTax decimal List price for the product as configured in the backend exluding tax.
ListTax decimal tax for the ListPrice.
DiscountInclTax decimal The effective discount for the price including tax.
DiscountExclTax decimal The effective discount for the price excluding tax.
AmountOff decimal Total fixed discount for the product without tax. Does not include the percentageOff discounts.
PercentageOff decimal The percentage discount for the product without tax.

Top level APIs

To get price calculations you can use the top level API for that.

    
    
    	UCommerce.EntitiesV2.Product currentProduct = UCommerce.Runtime.SiteContext.Current.CatalogContext.CurrentProduct;
    	UCommerce.EntitiesV2.PriceGroup = UCommerce.Runtime.SiteContext.Current.CatalogContext.CurrentPriceGroup;
    
    	UCommerce.Catalog.Models.ProductPriceCalculationResult = UCommerce.Catalog.Models.ProductPriceCalculationResult CalculatePrice(new List<Guid>() { product.Guid }, new List<Guid>() { product.Guid });
    
    

Price Query

The underlying price calculation are implemented in two different ways:

  • One that evaluates marketing foundation
  • One that leaves out marketing foundation

In some cases you might want to leave out marketing foundation which is possible by either disableing all active campaigns, or if you want to leave out discounts calculated when showing prices, but not when adding them to your basket.

The actual components that are calculating prices for display purpose are implemented as two queries of the query type

NHibernateQueryBase<ProductPriceQueryArgs, ProductPriceQueryResult>:

UCommerce.NHibernate.Impl.DiscountAppliedProductPriceQuery UCommerce.NHibernate.Impl.ProductPriceQuery

If you want to swap them out, this is done via configuration to castle windsor.

Ucommerce Aps - Vestergade 58N, 4th. floor - 8000 Aarhus C - Denmark
Phone +45 61 799 997 - Email [email protected] Ucommerce logo