Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Product Price Calculation

Whenever you are going to show prices on your frontend it being on the category listing or the product page you are going to use CatalogLibrary to get a price calculation for your product(s). In this article, we will 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 easily show different price points for the same product if you are using tiered pricing or differentiated pricing. Basically, you will 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

description


Properties

  • Return type IDictionary<String, Object>
  • Description
    Properties

Items

  • Return type IList<Ucommerce.Catalog.Models.Item>
  • Description
    Items

Ucommerce.Catalog.Models.ProductPriceCalculationResult.Item

description


Properties

  • Return type IDictionary<String, Object>
  • Description
    Properties

ProductGuid

  • Return type Guid
  • Description
    ProductGuid

PriceGroupGuid

  • Return type Guid
  • Description
    PriceGroupGuid

CurrencyISOCode

  • Return type String
  • Description
    CurrencyISOCode

Sku

  • Return type String
  • Description
    Sku

VariantSku

  • Return type String
  • Description
    VariantSku

MinimumQuantity

  • Return type Int
  • Description
    MinimumQuantity

MaximumQuantity

  • Return type Int
  • Description
    MaximumQuantity

PriceInclTax

  • Return type Decimal
  • Description
    The price the customer actually pays including Tax.

PriceExclTax

  • Return type Decimal
  • Description
    The price the customer actually pays excluding Tax.

ListPriceInclTax

  • Return type Decimal
  • Description
    Unmodified list price of product including Tax.

ListPriceExclTax

  • Return type Decimal
  • Description
    Unmodified list price of product excluding Tax.

DiscountInclTax

  • Return type Decimal
  • Description
    Unit discount on product including Tax.

DiscountExclTax

  • Return type Decimal
  • Description
    Unit discount on product excluding Tax.

DiscountTax

  • Return type Decimal
  • Description
    DiscountTax

DiscountPercentage

  • Return type Decimal
  • Description
    DiscountPercentage

PriceTax

  • Return type Decimal
  • Description
    Tax payable.

ListTax

  • Return type Decimal
  • Description
    ListTax

Top level APIs

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

    Ucommerce.Api.ICatalogContext catalogContext = ObjectFactory.Instance.Resolve<Ucommerce.Api.ICatalogContext>();
    Ucommerce.Api.ICatalogLibrary catalogLibrary = ObjectFactory.Instance.Resolve<Ucommerce.Api.ICatalogLibrary>();
    
    Ucommerce.Search.Models.Product currentProduct = catalogContext.CurrentProduct;
    Ucommerce.Search.Models.PriceGroup currentPriceGroup = catalogContext.CurrentPriceGroup;
    
    Ucommerce.Catalog.Models.ProductPriceCalculationResult result = 
        catalogLibrary.CalculatePrices(
            new List<Guid>() {currentProduct.Guid}, 
            new List<Guid>() {currentPriceGroup.Guid});
    
    

Price Query

The underlying price calculation is 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 disabling 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 of Castle Windsor.