GitHub

DaffCompositeProductFacadeInterface

import { DaffCompositeProductFacadeInterface } from '@daffodil/product-composite/state'

A facade for interacting with the composite product state. Exposes many parts of the state for easy access and allows dispatching of actions.

interface DaffCompositeProductFacadeInterface {
  getRequiredItemPricesForConfiguration(
    id: string
    configuration?: Dictionary<DaffCompositeConfigurationItem>
  ): Observable<DaffPriceRange>
  getOptionalItemPricesForConfiguration(
    id: string
    configuration?: Dictionary<DaffCompositeConfigurationItem>
  ): Observable<DaffPriceRange>
  getPricesAsCurrentlyConfigured(id: string): Observable<DaffPriceRange>
  getAppliedOptions(id: string): Observable<Dictionary<DaffCompositeProductItemOption>>
  isItemRequired(
    id: string
    item_id: string
  ): Observable<boolean>
  hasDiscount(priceRange: DaffPriceRange): boolean
  getDiscountAmount(id: string): Observable<number>
  getDiscountPercent(id: string): Observable<number>
  hasPriceRange(priceRange: DaffPriceRange): boolean
}

() Methods

getRequiredItemPricesForConfiguration
Observable<DaffPriceRange>

Get a DaffPriceRange for a composite product based on the configuration provided excluding unselected, optional item prices.

Parameters
Parameterid: string
Description

an id for a composite product

Parameterconfiguration: Dictionary<DaffCompositeConfigurationItem>
Description

a Dictionary of DaffCompositeConfigurationItems

getOptionalItemPricesForConfiguration
Observable<DaffPriceRange>

Get the broadest possible DaffPriceRange for a composite product based on the configuration provided including optional item prices.

Parameters
Parameterid: string
Description

the id of the composite product.

Parameterconfiguration: Dictionary<DaffCompositeConfigurationItem>
Description

a Dictionary of DaffCompositeConfigurationItems

getPricesAsCurrentlyConfigured
Observable<DaffPriceRange>

Get the DaffPriceRange for a composite product based on the current configuration of selected item options in redux state and excluding unselected, optional item prices.

Parameters
Parameterid: string
Description

the id of the composite product.

getAppliedOptions
Observable<Dictionary<DaffCompositeProductItemOption>>

Returns the applied options for a composite product.

Parameters
Parameterid: string
Description

the id of the composite product.

isItemRequired
Observable<boolean>

Returns whether the item of a composite product is required.

Parameters
Parameterid: string
Description

the id of the composite product.

Parameteritem_id: string
Description

the id of the item_id.

hasDiscount
boolean

Returns whether a DaffPriceRange has a discount.

Parameters
ParameterpriceRange: DaffPriceRange
Description

a DaffPriceRange

getDiscountAmount
Observable<number>

Returns the discount amount of a composite product based on the current configuration of the selected item options in redux state and excluding unselected, optional item prices. Will return undefined if all required options are not chosen.

Parameters
Parameterid: string
Description

the id of the composite product.

getDiscountPercent
Observable<number>

Returns the discount percent of a composite product based on the current configuration of the selected item options in redux state and excluding unselected, optional item prices. Will return undefined if all required options are not chosen. Note: This percent is computed client-side and should be treated as an estimate rather than an exact value.

Parameters
Parameterid: string
Description

the id of the composite product.

hasPriceRange
boolean

Returns whether the min and max prices of a DaffPriceRange are different.

Parameters
ParameterpriceRange: DaffPriceRange
Description

a DaffPriceRange