File

projects/apttus/ecommerce/src/lib/modules/promotion/services/promotion.service.ts

Description

Promotion Service defines a way to add/remove promotions to/from the cart.

Extends

AObjectService

Index

Properties
Methods

Methods

applyPromotions
applyPromotions(promocode: string)

Method applies promotion to the current cart based on the promo code passed.

Example:

import { PromotionService } from '@apttus/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
    constructor(private promotionService: PromotionService){}

    applyPromotions(promocode: string){
          this.promotionService.applyPromotions(promocode).subscribe({...});
    }
}
Parameters :
Name Type Optional Description
promocode string No

a string value representing the promotion code to be applied to the cart.

Returns : Observable<boolean>

a void observable when the operation has completed.

getAppliedPromotionForCart
getAppliedPromotionForCart(incentiveCode?: string)

Method returns an observable containing an array of adjustment line items for the current cart.

Example:

  import { PromotionService } from '@apttus/ecommerce';
  import { AdjustmentItem } from '@apttus/ecommerce';
  import { Observable } from 'rxjs/Observable';

  export class MyComponent implements OnInit{
      adjustmentLineItems$: Observable<Array<AdjustmentLineItem>>;
      adjustmentLineItems; Array<AdjustmentLineItem>;
      constructor(private promotionService: PromotionService){}

      getAppliedPromotionForCart(){
            this.promotionService.getAppliedPromotionForCart().subscribe(res => this.adjustmentLineItems = res);
            or
            this.adjustmentLineItems$ = this.promotionService.getAppliedPromotionForCart();
      }
  }
Parameters :
Name Type Optional
incentiveCode string Yes

an observable containing an array of adjustment line items for the current cart.

onInit
onInit()
Returns : void
removeAppliedPromotion
removeAppliedPromotion(incentive: Incentive)

Method removes the promotion from the current cart if it is already applied.

Example:

import { PromotionService } from '@apttus/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
      constructor(private promotionService: PromotionService){}

      removeAppliedPromotion(promocode: string, msg: string = 'valid', incentiveName?: string){
          this.promotionService.removeAppliedPromotion(promocode).subscribe({...});
      }
}
Parameters :
Name Type Optional
incentive Incentive No
Returns : Observable<boolean>

a void observable when the operation has completed.

Properties

invalidPromotion
Type : EventEmitter<string>
Default value : new EventEmitter<string>()
onRemovePromotion
Type : EventEmitter<string>
Default value : new EventEmitter<string>()
promocode
Type : string
type
Default value : AdjustmentItem

result-matching ""

    No results matching ""