File

projects/congarevenuecloud/ecommerce/src/lib/modules/pricing/services/price.service.ts

Description

This service is a work in progress.

Price service provides a way of retrieving price for various points in the ecommerce application. Different price points are product price, product option price, order and quote totals.

Usage

Example :
import { PriceService, AObjectService} from '@congarevenuecloud/ecommerce';

export class MyComponent implements OnInit{
constructor( private priceService: PriceService)
}
// or
export class MyService extends AObjectService {
private priceService: PriceService = this.injector.get(PriceService);
}

Index

Properties
Methods

Constructor

constructor(priceListService: PriceListService, localCurrencyPipe: LocalCurrencyPipe, storefrontService: StorefrontService)
Parameters :
Name Type Optional
priceListService PriceListService No
localCurrencyPipe LocalCurrencyPipe No
storefrontService StorefrontService No

Methods

Static adjustValue
Method calcuates the adjustment amount for a line item based on its adjustment type.
adjustValue()

Method calcuates the adjustment amount for a line item based on its adjustment type.

Returns : void
getAttributePriceForProduct
Method returns a price for a given attribute and its value on a product
getAttributePriceForProduct()

Method returns a price for a given attribute and its value on a product

Returns : void
getCartPrice
Method returns the price for a given cart. If the first parameter is left blank, it will return the price for the current cart.
getCartPrice()

Method returns the price for a given cart. If the first parameter is left blank, it will return the price for the current cart.

Returns : void
getLineItemPrice
Method returns a price instance for a given cart item. If the price for the item has already been calculated, it will not do client side calculation.
getLineItemPrice()

Method returns a price instance for a given cart item. If the price for the item has already been calculated, it will not do client side calculation.

Returns : void
getOptionAdjustmentPrice
getOptionAdjustmentPrice(option: ProductOptionComponent)

Method is used to retrieve the price of an option for a given product

Example:

Example :
import { PriceService, Price, ProductOptionComponent } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
price: Price;
price$: Observable<Price>;

constructor(private priceService: PriceService){}

getOptionAdjustmentPrice(option: ProductOptionComponent){
this.priceService.getOptionAdjustmentPrice(option).subscribe(a => this.price = a);
// or
this.price$ = this.priceService.getOptionAdjustmentPrice(option);
}
}
Parameters :
Name Type Optional Description
option ProductOptionComponent No

the instance of the product option component to calculate the adjustment amount for

Returns : Observable<Price>

a hot observable containing the price of the given option

getOrderLineItemPrice
Method returns price for a given OrderLineItem instance.
getOrderLineItemPrice()

Method returns price for a given OrderLineItem instance.

Returns : void
getOrderPrice
getOrderPrice(order: Order)

Method returns a price for a given order instance.

Example:

Example :
import { PriceService, Price, Order } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
price: Price;
price$: Observable<Price>;

constructor(private priceService: PriceService){}

getOrderPrice(order: Order){
this.priceService.getOrderPrice(order).subscribe(a => this.price = a);
// or
this.price$ = this.priceService.getOrderPrice(order);
}
}
Parameters :
Name Type Optional Description
order Order No

the instance of the order to return a price for

Returns : Observable<Price>

a hot observable containing the price of the order

getProductPrice
getProductPrice(product: Product, chargeType?: ChargeType)

Method is used to retrieve the price for a given product.

Example:

Example :
import { PriceService, Price, Product } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
price: Price;
price$: Observable<Price>;

constructor(private priceService: PriceService){}

getProductPrice(product: Product){
this.priceService.getProductPrice(product).subscribe(a => this.price = a);
// or
this.price$ = this.priceService.getProductPrice(product);
}
}

/**

Parameters :
Name Type Optional Description
product Product No

the instance of the product to return the price for.

chargeType ChargeType Yes

an optional parameter representing the charge type to calculate the price for.

Returns : Observable<Price>

a hot observable containing the price instance for the given product.

getQuoteLineItemPrice
Method returns a NetPrice for a given QuoteLineItem instance.
getQuoteLineItemPrice()

Method returns a NetPrice for a given QuoteLineItem instance.

Returns : void
getQuotePrice
getQuotePrice(quote: Quote)

Method returns a price for a given Quote instance.

Example:

Example :
import { PriceService, Price, Quote} from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
price: Price;
price$: Observable<Price>;

constructor(private priceService: PriceService){}

getQuotePrice(quote: Quote){
this.priceService.getQuotePrice(quote).subscribe(a => this.price = a);
// or
this.price$ = this.priceService.getQuotePrice(quote);
}
}
Parameters :
Name Type Optional Description
quote Quote No

the instance of the Quote to return a price for

Returns : Observable<Price>

a hot observable containing the price of the Quote

Properties

cartPending
Type : boolean
Default value : false
matrixData
Type : object
Default value : {}
previousCartPrice
Type : Price
Default value : null
queryKey
Type : string
Default value : null
queryList
Type : Array<PriceListItem>

results matching ""

    No results matching ""