Hide menu Last updated: Aug 31 2017
Area: Episerver Commerce Applies to versions: 10 and higher
Other versions:

Pricing examples

The examples in this topic show how to get, save, and delete prices with the Episerver Commerce API.

Episerver Commerce provides two interfaces related to prices:

  • IPriceService. Used for read-only prices.
  • PriceDetailService. Used for editing prices.

Listing prices

Use IPriceDetailService.List() in the following examples to get price details for a catalog entry. If it is a variant or package, this method returns its own price. If it is a product or a bundle, this method returns prices for its child variants. There are overloads of List() which support filtering and paging, as exemplified below.

Listing all prices

Use IPriceDetailService.List(ContentReference) to get price details for an entry.

Listing price with paging

Use IPriceDetailService.List(ContentReference, int, int , int) to get price details for an entry with paging.

Listing price with PriceFilter

Use IPriceDetailService.List(ContentReference, MarketId, PriceFilter, int, int , int) to get price details for an entry with filtering and paging.

Saving prices

Use IPriceDetailService.Save(IEnumerable<IPriceDetailService>) to add/edit price details. Commerce also provides an extension for IPriceDetailService.Save(IPriceDetailService) to add/edit only one price.

Deleting prices

Use IPriceDetailService.Delete(IEnumerable<long>) to delete price details. You also can use the IPriceDetailService.Delete(long) extension to delete a specific price detail.

The example below illustrates how to delete all prices for an entry.