File

projects/congarevenuecloud/elements/src/lib/constraint-rule/services/constraint-rule-message.service.ts

Description

Service is responsible to build and format the constraint rule messages to render on the view.

Index

Properties
Methods

Constructor

constructor(constraintRuleService: ConstraintRuleService, productService: ProductService, exceptionService: ExceptionService, primaryCartService: CartService, secondaryCartService: SecondaryCartService, araiService: AppliedRuleActionInfoService, productOptionService: ProductOptionService, storefrontService: StorefrontService)
Parameters :
Name Type Optional
constraintRuleService ConstraintRuleService No
productService ProductService No
exceptionService ExceptionService No
primaryCartService CartService No
secondaryCartService SecondaryCartService No
araiService AppliedRuleActionInfoService No
productOptionService ProductOptionService No
storefrontService StorefrontService No

Methods

addMultipleProductsToCart
addMultipleProductsToCart(ruleDetail: ConstraintRuleDetail | AppliedRuleActionInfo, products: Array<Product>, quantity: number)

Adds products to the cart based on the provided rule detail.

See ConstraintRuleDetail for more details on the structure and fields required.

Parameters :
Name Type Optional Default value Description
ruleDetail ConstraintRuleDetail | AppliedRuleActionInfo No

Rule detail object specifying which products should be added to the cart.

products Array<Product> No

Array of products to add to the cart.

quantity number No 1

Quantity of the given products to add to the cart.

Returns : Observable<void>
addProductToCartFromRule
addProductToCartFromRule(ruleDetail: ConstraintRuleDetail | AppliedRuleActionInfo, product: Product, quantity: number)

Adds a product to the cart based on the associated constraint rule.

See ConstraintRuleDetail for more details on the structure and fields required.

Parameters :
Name Type Optional Default value Description
ruleDetail ConstraintRuleDetail | AppliedRuleActionInfo No

Constraint rule detail object related to the action product to add to cart.

product Product No

Action product to add for the associated constraint rule.

quantity number No 1

Quantity of the given product to add to the cart.

Returns : Observable<void>
deleteProductFromCart
deleteProductFromCart(ruleDetail: ConstraintRuleDetail | AppliedRuleActionInfo, product: Product)

Removes a product from the cart based on the given constraint rule detail object.

Parameters :
Name Type Optional Description
ruleDetail ConstraintRuleDetail | AppliedRuleActionInfo No

Constraint rule detail object pertaining to the product to remove from the cart.

product Product No

the product to remove from the cart.

Returns : Observable<string>
deleteReplacementProductsFromCart
deleteReplacementProductsFromCart(ruleDetail: ConstraintRuleDetail | AppliedRuleActionInfo, products: Product[])

Removes a condition product from the cart based on the given replacement rule detail.

Parameters :
Name Type Optional Description
ruleDetail ConstraintRuleDetail | AppliedRuleActionInfo No

replacement rule detail pertaining to the product to remove from the cart.

products Product[] No
Returns : Observable<string>
getCartRuleGroups
getCartRuleGroups()

Returns an observable of the cart level rule groups. See ConstraintRuleGroups for more details on the structure and fields required.

An Observable of ConstraintRuleGroups.

isCheckboxEnabled
isCheckboxEnabled()

Determines if the checkbox should be enabled in the rule dialog.

Returns : Observable<boolean>

An observable that emits true if the checkbox is enabled, otherwise false.

refreshCartRules
refreshCartRules()

Refreshes the cart level constraint rules behavior subject.

refreshConfigRules
refreshConfigRules()

Refreshes the product configuration level constraint rules behavior subject.

Returns : any
replaceProducts
replaceProducts(replacementRules: Array<ConstraintRuleDetail>, actionItems?: Array<ActionItem>)

Replaces products in the cart based on the provided replacement rules. Defaults to the first product from the actionItems in the first rule of the replacement.

ConstraintRuleDetail for more details on the structure and fields required. ActionItem for more details on the structure and fields required.

Parameters :
Name Type Optional Description
replacementRules Array<ConstraintRuleDetail> No
  • Array of rules specifying products to replace and their replacements.
actionItems Array<ActionItem> Yes
  • Optional array of ActionItem interfaces used to replace the products. Defaults to the first product from the actionItems in the first rule of the replacement.

ConstraintRuleDetail for more details on the structure and fields required. ActionItem for more details on the structure and fields required.

Returns : Observable<void>

Properties

cartRuleGroups$
Type : BehaviorSubject<ConstraintRuleGroups>
Default value : new BehaviorSubject<ConstraintRuleGroups>(null)

Groups of cart level constraint rules.

showRules$
Type : BehaviorSubject<boolean>
Default value : new BehaviorSubject<boolean>(true)

results matching ""

    No results matching ""