Skip to content

Commerce Pricing API Reference

advanced
📜Corecommerce

The Pricing API resolves, reads, and writes prices for catalog entries. IPriceService handles read-only price resolution. IPriceDetailService provides full CRUD for price records.

Optimizely.Commerce.Catalog.Provider

InterfacePurpose
IPriceServiceRead-only price lookups with filtering
IPriceDetailServiceFull CRUD for individual price records

GetPrices(MarketId, DateTime, CatalogKey, PriceFilter)

Section titled “GetPrices(MarketId, DateTime, CatalogKey, PriceFilter)”

Returns matching prices for a catalog entry filtered by market, currency, and customer group.

Parameters

NameTypeDescription
marketMarketIdTarget market identifier
validOnDateTimeDate for price validity check
catalogKeyCatalogKeyEntry code wrapped in CatalogKey
filterPriceFilterCurrency, quantity, and customer pricing group filters

Returns: IEnumerable<IPriceValue>

Get prices for an entry
csharp
public class PriceLookupService
{
  private readonly IPriceService _priceService;

  public PriceLookupService(IPriceService priceService)
  {
      _priceService = priceService;
  }

  public IEnumerable<IPriceValue> GetCurrentPrices(string entryCode, MarketId market)
  {
      var filter = new PriceFilter
      {
          Currencies = new[] { new Currency("USD") },
          ReturnCustomerPricing = false
      };

      return _priceService.GetPrices(
          market,
          DateTime.UtcNow,
          new CatalogKey(entryCode),
          filter);
  }
}

GetCatalogEntryPrices(IEnumerable<CatalogKey>)

Section titled “GetCatalogEntryPrices(IEnumerable<CatalogKey>)”

Bulk price lookup for multiple entries.

Parameters

NameTypeDescription
catalogKeysIEnumerable<CatalogKey>Collection of entry codes

Returns: IEnumerable<IPriceValue> — all prices for the given entries

Returns all price detail records for a catalog entry.

Parameters

NameTypeDescription
entryContentLinkContentReferenceContent reference to the variant

Returns: IList<IPriceDetailValue>

Creates or updates price records.

Parameters

NameTypeDescription
pricesIEnumerable<IPriceDetailValue>Price records to save

Returns: void

Throws: ValidationException if price data is invalid

Set a price for a variant
csharp
public void SetPrice(
  ContentReference variantLink,
  string entryCode,
  decimal amount,
  Currency currency,
  MarketId market)
{
  var priceDetail = new PriceDetailValue
  {
      CatalogKey = new CatalogKey(entryCode),
      MarketId = market,
      UnitPrice = new Money(amount, currency),
      ValidFrom = DateTime.UtcNow,
      ValidUntil = null,
      MinQuantity = 0,
      CustomerPricing = CustomerPricing.AllCustomers
  };

  _priceDetailService.Save(new[] { priceDetail });
}

Deletes price records by their IDs.

Parameters

NameTypeDescription
priceDetailIdsIEnumerable<long>Price record IDs to delete

Returns: void

Delete prices for a variant
csharp
var prices = _priceDetailService.List(variantLink);
var priceIds = prices.Select(p => p.PriceValueId).ToList();
_priceDetailService.Delete(priceIds);
PropertyTypeDescription
CatalogKeyCatalogKeyEntry code reference
MarketIdMarketIdMarket this price applies to
UnitPriceMoneyPrice amount and currency
ValidFromDateTimeStart of validity window
ValidUntilDateTime?End of validity window (null = no expiry)
MinQuantitydecimalMinimum quantity for tiered pricing
CustomerPricingCustomerPricingCustomer group restriction
  1. Customer-specific prices (matching customer pricing group)
  2. Sale prices (time-bound with ValidFrom/ValidUntil)
  3. Tiered prices (matching MinQuantity)
  4. Base price (no restrictions, MinQuantity = 0)
ExceptionCause
ValidationExceptionMissing required fields (currency, market, amount)
CatalogEntryNotFoundExceptionEntry code does not exist