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

Building a Product Page

In this article we'll show you how to build a product page using best practices.

Getting Current Product

    
    Ucommerce.Api.ICatalogContext catalogContext = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<ICatalogContext>();
    Ucommerce.Search.Models.Product currentProduct = catalogContext.CurrentProduct;
               
    

Variants

If you have your product definition for the current product

    
    Ucommerce.Api.ICatalogLibrary catalogLibrary = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<ICatalogLibrary>();
    Ucommerce.Search.ResultSet<Ucommerce.Search.Models.Product> variants = catalogLibrary.GetVariants(currentProduct);
    
    

Prices

    
    var currentPriceGroup = catalogContext.CurrentPriceGroup;
    
    var unitPrice = new Money(currentProduct.UnitPrices[currentPriceGroup.Name] * (1.0M + currentPriceGroup.TaxRate), currentPriceGroup.CurrencyISOCode).ToString();
    var withoutVat = new Money(currentProduct.UnitPrices[currentPriceGroup.Name], currentPriceGroup.CurrencyISOCode).ToString();
    var vat = new Money(currentProduct.UnitPrices[currentPriceGroup.Name] * currentPriceGroup.TaxRate, currentPriceGroup.CurrencyISOCode).ToString();
         
    

Properties

    
    object myDynamicProperty = currentProduct["fieldName"];
    string image = currentProduct.PrimaryImageUrl;