File

projects/apttus/ecommerce/src/lib/modules/cart/services/cart-item.service.ts

Description

Cart Item service returns the selling term and the end date of a recurring product.

Extends

LineItemService

Index

Properties
Methods

Methods

addCartItems
addCartItems(cartItems: Array)
Parameters :
Name Type Optional
cartItems Array<CartItem> No
Returns : Observable<Array<CartItem>>
getBundleItemsForCartItem
getBundleItemsForCartItem(item: CartItem | AssetLineItem | QuoteLineItem | OrderLineItem, context?: Array)

This method returns the bundled options for the cart line item passed.

Parameters :
Name Type Optional
item CartItem | AssetLineItem | QuoteLineItem | OrderLineItem No
context Array<CartItem | AssetLineItem | QuoteLineItem | OrderLineItem> Yes
Returns : Observable<Array<CartItem | AssetLineItem | QuoteLineItem | OrderLineItem>>

An observable containing the array of option line items for a given cart item.

getCartItem
getCartItem(cartItemId: string)
Parameters :
Name Type Optional
cartItemId string No
Returns : Observable<any>
getCartItemsForAsset
getCartItemsForAsset(cartItem: CartItem, context?: Cart)

Method will generate the default cart items for a given asset.

Parameters :
Name Type Optional Description
cartItem CartItem No

the primary cart item with a related asset. Generated from the amend / configure asset API

context Cart Yes
Returns : Observable<Array<CartItem>>
getCartItemsForCart
getCartItemsForCart(cartId: string, lineType?: "Product/Service" | "Option" | "Misc")

This method returns cart line items based on the cart id and line type passed.

Parameters :
Name Type Optional Description
cartId string No

Cart Id for which the line items are to be retrieved.

lineType "Product/Service" | "Option" | "Misc" Yes

Type of cart line item to be retrieved.

Returns : Observable<Array<CartItem>>

An observable containing the array of cart line items of a given line type, for a given cart.

getCartItemsForProduct
getCartItemsForProduct(product: Product, quantity: number, cart?: Cart, cartItems?: Array, productOptionComponent?: ProductOptionComponent, parentBundleNumber?: number, lineNumber?: number, lineStatus?: LineStatus)

Method gets the cart items for a given product. A bundle product with option groups populated must be passed in to retrieve related option cart items.

Parameters :
Name Type Optional Default value Description
product Product No

the product or bundle product record to generate the cart items for

quantity number No 1

the quantity to use for the cart item(s)

cart Cart Yes

the related cart that the cart items will be added to. Must be passed in or the line number that is used will start at 1

cartItems Array<CartItem> Yes

optional list of related cart items to determine the starting primary line number

productOptionComponent ProductOptionComponent Yes

The related ProductOptionComponent record for generating option line items

parentBundleNumber number Yes

the default parent bundle number to use

lineNumber number Yes

the default line number to use.

lineStatus LineStatus Yes
Returns : Observable<Array<CartItem>>
getEndDate
getEndDate(purchaseDate: Date, term: number, frequency: "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Half Yearly" | "Yearly" | "--None--")

This method returns the end date of a recurring product based on its start date and the selling frequency.

Parameters :
Name Type Optional Description
purchaseDate Date No

the day of purchase of the product.

term number No
frequency "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Half Yearly" | "Yearly" | "--None--" No

the selling frequency for the product. Selling frequency may take values like hourly, daily, weekly, monthly, quarterly, half yearly and yearly.

Returns : Date

a date value representing the day of end of service of the product.

getNextPrimaryLineNumber
getNextPrimaryLineNumber(cartItems: Array)
Parameters :
Name Type Optional
cartItems Array<CartItem> No
Returns : any
getReadableTerm
getReadableTerm(term: number, frequency: "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Half Yearly" | "Yearly" | "One Time" | "--None--")
Parameters :
Name Type Optional
term number No
frequency "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Half Yearly" | "Yearly" | "One Time" | "--None--" No
Returns : string
getTerm
getTerm(startDate: moment.Moment, endDate: moment.Moment, frequency: "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Half Yearly" | "Yearly" | "--None--")

This method is used to calculate selling term of the recurring product based on its start date, end date and the selling frequency.

Parameters :
Name Type Optional Description
startDate moment.Moment No

the day of purchase of the product.

endDate moment.Moment No

the day of end of service for the product.

frequency "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Half Yearly" | "Yearly" | "--None--" No

the selling frequency of the product.

Returns : number

number representing the selling term of the recurring product.

getOptionsForItem
getOptionsForItem(item: CartItem | AssetLineItem | QuoteLineItem | OrderLineItem, relatedTo?: Cart | Order | Quote)

Method takes a line item and returns the full list of line items related to it. Can be any line item within the bundle.

Parameters :
Name Type Optional Description
item CartItem | AssetLineItem | QuoteLineItem | OrderLineItem No

the primary line item to get the related cart items for

relatedTo Cart | Order | Quote Yes

An optional context object to avoid additional network callouts

Returns : Observable<Array<CartItem | AssetLineItem | QuoteLineItem | OrderLineItem>>
Static groupItems
groupItems(items: Array)
Parameters :
Name Type Optional
items Array<CartItem | AssetLineItem | QuoteLineItem | OrderLineItem> No
Returns : Array<ItemGroup>

Properties

Protected accountService
Type : AccountService
Default value : this.injector.get(AccountService)
frequencyMap
Type : object
Default value : { 'Hourly': 'hours', 'Monthly': 'months', 'Daily': 'days', 'Weekly': 'weeks', 'Quarterly': 'years', 'Half Yearly': 'years', 'Yearly': 'years', '--None--': '--None--' }
Protected priceListService
Type : PriceListService
Default value : this.injector.get(PriceListService)
Protected productAttributeValueService
Type : ProductAttributeValueService
Default value : this.injector.get(ProductAttributeValueService)
Protected storefrontService
Type : StorefrontService
Default value : this.injector.get(StorefrontService)
type
Default value : CartItem

result-matching ""

    No results matching ""