GitHub

DaffCompositeProductFacade

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

import { DaffCompositeProductFacade } from '@daffodil/product-composite/state'
@Injectable()
class DaffCompositeProductFacade<<T extends DaffProduct = DaffProduct>>  implements DaffCompositeProductFacadeInterface {
  compositeProductSelectors: getDaffCompositeProductSelectors<T>()
  hasDiscount: productPriceRangeHasDiscount
  hasPriceRange: productPriceRangeHasPriceRange
  getRequiredItemPricesForConfiguration(
    id: T["id"]
    configuration?: Dictionary<DaffCompositeConfigurationItem>
  ): Observable<DaffPriceRange>
  getOptionalItemPricesForConfiguration(
    id: T["id"]
    configuration?: Dictionary<DaffCompositeConfigurationItem>
  ): Observable<DaffPriceRange>
  getPricesAsCurrentlyConfigured(id: T["id"]): Observable<DaffPriceRange>
  getAppliedOptions(id: T["id"]): Observable<Dictionary<DaffCompositeProductItemOption>>
  getDiscountAmount(id: T["id"]): Observable<number>
  getDiscountPercent(id: T["id"]): Observable<number>
  isItemRequired(
    id: T["id"]
    item_id: string
  )
  dispatch(action: Action<string>)
}

Properties

Name Type Description
compositeProductSelectors getDaffCompositeProductSelectors<T>()
hasDiscount productPriceRangeHasDiscount

Returns whether a DaffPriceRange has a discount.

hasPriceRange productPriceRangeHasPriceRange

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

getRequiredItemPricesForConfiguration Observable<DaffPriceRange>

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

getOptionalItemPricesForConfiguration Observable<DaffPriceRange>

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

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.

getAppliedOptions Observable<Dictionary<DaffCompositeProductItemOption>>

Returns the applied options for a composite product.

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.

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.

isItemRequired

Returns whether the item of a composite product is required.

dispatch