File

projects/congarevenuecloud/ecommerce/src/lib/modules/constraint-rules/services/applied-rule-action-info.service.ts

Description

This service is work in progress. Constraint rules are a powerful feature when configuring products. They allow you to include, excludes, recommend, validate and replace products based on business logic.

Extends

AObjectService

Index

Properties
Methods

Methods

deleteRulesForCart
This method is deprecated.
deleteRulesForCart(cart?: Cart)

Deletes constraint rules for the given cart.

Parameters :
Name Type Optional
cart Cart Yes
Returns : Observable<any>
fetchRulesFromPrimaryCart
fetchRulesFromPrimaryCart()

Fetches the applied rule actions from the primary cart after ensuring the cart is valid.

Example:

import { AppliedRuleActionInfo, AppliedRuleActionInfoService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
rule: Array<AppliedRuleActionInfo>;
rule$: Observable<Array<AppliedRuleActionInfo>>;

constructor(private araiService: AppliedRuleActionInfoService){}

ngOnInit(){
this.araiService.fetchRulesFromPrimaryCart().subscribe(rule => {rule = rule;});
// or
this.rule$ = this.araiService.fetchRulesFromPrimaryCart();
}
}

An observable array of AppliedRuleActionInfo.

fetchRulesFromSecondaryCart
fetchRulesFromSecondaryCart()
getAppliedActionsForCart
getAppliedActionsForCart(cart?: Cart)

Method retrieves the actions that are applied to a cart when the constraint rules are applied

  • Example:

import { AppliedRuleActionInfo, AppliedRuleActionInfoService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
rule: Array<AppliedRuleActionInfo>;
rule$: Observable<Array<AppliedRuleActionInfo>>;

constructor(private araiService: AppliedRuleActionInfoService){}

ngOnInit(){
this.araiService.getAppliedActionsForCart(cart?: Cart).subscribe(rule => {rule = rule;});
// or
this.rule$ = this.araiService.getAppliedActionsForCart(cart?: Cart);
}
}
Parameters :
Name Type Optional Description
cart Cart Yes

The cart to retrieve constraint rules for. If not provided, the current cart will be used.

An observable array of 'AppliedRuleActionInfo'

getExclusionProductActionsForCart
getExclusionProductActionsForCart()

This method can be used to fetch the list of Applied rule action info records for active cart. It returns AppliedRuleActionInfo record having constraint rule action, actionType as Exclusion.

Example:

import { AppliedRuleActionInfo, AppliedRuleActionInfoService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
rule: Array<AppliedRuleActionInfo>;
rule$: Observable<Array<AppliedRuleActionInfo>>;

constructor(private araiService: AppliedRuleActionInfoService){}

ngOnInit(){
this.araiService.getExclusionProductActionsForCart().subscribe(rule => {rule = rule;});
// or
this.rule$ = this.araiService.getExclusionProductActionsForCart();
}
}

Observable<Array> returns an observable of Array records.

getPendingActionsForCart
getPendingActionsForCart()

This method can be used to fetch the list of Applied rule action info records for active cart. It returns applied rule action info records have pending flag as true.

Example:

import { AppliedRuleActionInfo, AppliedRuleActionInfoService } from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
rule: Array<AppliedRuleActionInfo>;
rule$: Observable<Array<AppliedRuleActionInfo>>;

constructor(private araiService: AppliedRuleActionInfoService){}

ngOnInit(){
this.araiService.getPendingActionsForCart().subscribe(rule => {rule = rule;});
// or
this.rule$ = this.araiService.getPendingActionsForCart();
}
}

Observable<Array> returns an observable of Array records.

onInit
onInit()
Returns : void

Properties

appliedRuleActionSubject
Type : BehaviorSubject<Array<AppliedRuleActionInfo>>
Default value : new BehaviorSubject<Array<AppliedRuleActionInfo>>([])
type
Default value : AppliedRuleActionInfo

results matching ""

    No results matching ""