File

projects/congarevenuecloud/elements/src/lib/product-configuration/services/product-configuration.service.ts

Description

Product configuration are a complex feature when configuring products with option groups and attribute groups based on business logic.

Usage

Example :
import { ProductConfigurationService, AObjectService} from '@congarevenuecloud/ecommerce';
export class MyComponent implements OnInit{
constructor( private productConfigurationService: ProductConfigurationService)
}
// or
export class MyService extends AObjectService {
private productConfigurationService: ProductConfigurationService = this.injector.get(ProductConfigurationService);
}

Index

Properties
Methods

Constructor

constructor(primaryCartService: CartService, secondaryCartService: SecondaryCartService, storefrontService: StorefrontService, crMessageService: ConstraintRuleMessageService, araiService: AppliedRuleActionInfoService)
Parameters :
Name Type Optional
primaryCartService CartService No
secondaryCartService SecondaryCartService No
storefrontService StorefrontService No
crMessageService ConstraintRuleMessageService No
araiService AppliedRuleActionInfoService No

Methods

changeProductQuantity
changeProductQuantity(qty: number, item?: CartItem)

This method accepts and stores the quantity of the primary product in its local state.

Example:

Example :
import { ProductConfigurationService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
constructor(private productConfigurationService: ProductConfigurationService){}
changeProductQuantity(qty: number){
this.productConfigurationService.changeProductQuantity(qty);
}
}
Parameters :
Name Type Optional Description
qty number No

is of type number.

item CartItem Yes

is instance of cartitem, Its optional paramter, if passed then

getPrimaryItem
getPrimaryItem(product: Product)

The method is responsible for fetching the primary lineitem of the product.

Example:

Example :
import { ProductConfigurationService, Product, CartItem } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
primaryLineItem: CartItem;
constructor(private productConfigurationService: ProductConfigurationService){}
getPrimaryItem(product: Product){
this.primaryLineItem = this.productConfigurationService.getPrimaryItem(product);
}
}
Parameters :
Name Type Optional Description
product Product No

requires instance of product object.

Returns : CartItem

an instance of cartItem object.

onChangeConfiguration
onChangeConfiguration(configuration: ConfigurationState)

The method is responsible to emit the latest configuration state.

Example:

Example :
import { ProductConfigurationService } from '@congarevenuecloud/ecommerce';
import { ConfigurationState } from '../../../shared/interfaces/configuration-state.interface';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
constructor(private productConfigurationService: ProductConfigurationService){}
onChangeConfiguration(configuration: ConfigurationState){
this.productConfigurationService.onChangeConfiguration(configuration);
}
}
Parameters :
Name Type Optional Description
configuration ConfigurationState No

accepts the info about the current configuration state in product detail page.

Returns : void

Properties

configurationChange
Type : BehaviorSubject<ConfigurationState>
Default value : new BehaviorSubject({} as ConfigurationState)

Behavior subject emits the configuration state change.

isDiscovery
Type : BehaviorSubject<boolean>
Default value : new BehaviorSubject(false)
parentPrimaryLineNumber
Type : number
Default value : 0
primaryTxnLineNumber
Type : number
Default value : 0
Public productQuantity
Type : number
Default value : 1

stores the quantity of the primary product

results matching ""

    No results matching ""