File

feature-libs/cart/quick-order/root/facade/quick-order.facade.ts

Index

Methods

Methods

Abstract addProduct
addProduct(product: Product, quantity?: number)

Add product to the quick order list

Parameters :
Name Type Optional
product Product No
quantity number Yes
Returns : void
Abstract addToCart
addToCart()

Adding to cart all products from the list

Returns : Observable<>
Abstract canAdd
canAdd(code?: string)

Get information about the possibility to add the next product

Parameters :
Name Type Optional
code string Yes
Returns : Observable<boolean>
Abstract clearDeletedEntries
clearDeletedEntries()

Clear all deleted entries and timeout subscriptions

Returns : void
Abstract clearList
clearList()

Clear a list of added entries

Returns : void
Abstract clearNonPurchasableProductError
clearNonPurchasableProductError()

Clear not purchasable product error

Returns : void
Abstract getEntries
getEntries()

Get entries

Returns : BehaviorSubject<OrderEntry[]>
Abstract getNonPurchasableProductError
getNonPurchasableProductError()

Return non purchasable product error

Returns : Observable<Product | null>
Abstract getProductAdded
getProductAdded()

Return product added subject

Returns : Subject<string>
Abstract getSoftDeletedEntries
getSoftDeletedEntries()

Return soft deleted entries

Returns : Observable<Record<string, OrderEntry>>
Abstract hardDeleteEntry
hardDeleteEntry(productCode: string)

Clear deleted entry from the list

Parameters :
Name Type Optional
productCode string No
Returns : void
Abstract loadEntries
loadEntries(entries: OrderEntry[])

Load a list of entries

Parameters :
Name Type Optional
entries OrderEntry[] No
Returns : void
Abstract removeEntry
since 4.2 - use softDeleteEntry instead
removeEntry(index: number)
Parameters :
Name Type Optional
index number No
Returns : void
Abstract restoreSoftDeletedEntry
restoreSoftDeletedEntry(productCode: string)

Restore soft deleted entry

Parameters :
Name Type Optional
productCode string No
Returns : void
Abstract search
since 4.2 - use searchProducts instead Search product using SKU
search(productCode: string)

Search product using SKU

Parameters :
Name Type Optional
productCode string No
Returns : Observable<Product>
Abstract searchProducts
searchProducts(query: string, maxProducts?: number)

Search products using query

Parameters :
Name Type Optional
query string No
maxProducts number Yes
Returns : Observable<Product[]>
Abstract setListLimit
setListLimit(limit: number)

Set quick order list limit property

Parameters :
Name Type Optional
limit number No
Returns : void
Abstract setNonPurchasableProductError
setNonPurchasableProductError(product: Product)

Set error that selected product is not purchasable

Parameters :
Name Type Optional
product Product No
Returns : void
Abstract setProductAdded
setProductAdded(productCode: string)

Set product added subject

Parameters :
Name Type Optional
productCode string No
Returns : void
Abstract softDeleteEntry
softDeleteEntry(index: number)

Delete single entry from the list

Parameters :
Name Type Optional
index number No
Returns : void
Abstract updateEntryQuantity
updateEntryQuantity(entryIndex: number, quantity: number)

Load a list of entries

Parameters :
Name Type Optional
entryIndex number No
quantity number No
Returns : void
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { facadeFactory, OrderEntry, Product } from '@spartacus/core';
import { CART_QUICK_ORDER_CORE_FEATURE } from '../feature-name';
import { QuickOrderAddEntryEvent } from '../models/quick-order.model';

export function quickOrderFacadeFactory() {
  return facadeFactory({
    facade: QuickOrderFacade,
    feature: CART_QUICK_ORDER_CORE_FEATURE,
    methods: [
      'addProduct',
      'addToCart',
      'clearList',
      'canAdd',
      'setListLimit',
      'getEntries',
      'getProductAdded',
      'loadEntries',
      'softDeleteEntry',
      'search',
      'searchProducts',
      'setProductAdded',
      'updateEntryQuantity',
      'getSoftDeletedEntries',
      'restoreSoftDeletedEntry',
      'hardDeleteEntry',
      'clearDeletedEntries',
      'getNonPurchasableProductError',
      'setNonPurchasableProductError',
      'clearNonPurchasableProductError',
    ],
  });
}

@Injectable({
  providedIn: 'root',
  useFactory: quickOrderFacadeFactory,
})
export abstract class QuickOrderFacade {
  /**
   * Get entries
   */
  abstract getEntries(): BehaviorSubject<OrderEntry[]>;

  /**
   * @deprecated since 4.2 - use searchProducts instead
   * Search product using SKU
   */
  abstract search(productCode: string): Observable<Product>;

  /**
   * Search products using query
   */
  abstract searchProducts(
    query: string,
    maxProducts?: number
  ): Observable<Product[]>;

  /**
   * Clear a list of added entries
   */
  abstract clearList(): void;

  /**
   * Get information about the possibility to add the next product
   */
  abstract canAdd(code?: string): Observable<boolean>;

  /**
   * Set quick order list limit property
   */
  abstract setListLimit(limit: number): void;

  /**
   * Load a list of entries
   */
  abstract loadEntries(entries: OrderEntry[]): void;

  /**
   * Load a list of entries
   */
  abstract updateEntryQuantity(entryIndex: number, quantity: number): void;

  /**
   * Delete single entry from the list
   */
  abstract softDeleteEntry(index: number): void;

  /**
   * @deprecated since 4.2 - use softDeleteEntry instead
   */
  abstract removeEntry(index: number): void;

  /**
   * Add product to the quick order list
   */
  abstract addProduct(product: Product, quantity?: number): void;

  /**
   * Return product added subject
   */
  abstract getProductAdded(): Subject<string>;

  /**
   * Set product added subject
   */
  abstract setProductAdded(productCode: string): void;

  /**
   * Adding to cart all products from the list
   */
  abstract addToCart(): Observable<[OrderEntry[], QuickOrderAddEntryEvent[]]>;

  /**
   * Return soft deleted entries
   */
  abstract getSoftDeletedEntries(): Observable<Record<string, OrderEntry>>;

  /**
   * Restore soft deleted entry
   */
  abstract restoreSoftDeletedEntry(productCode: string): void;

  /**
   * Clear deleted entry from the list
   */
  abstract hardDeleteEntry(productCode: string): void;

  /**
   * Clear all deleted entries and timeout subscriptions
   */
  abstract clearDeletedEntries(): void;

  /**
   *  Return non purchasable product error
   */
  abstract getNonPurchasableProductError(): Observable<Product | null>;

  /**
   * Set error that selected product is not purchasable
   */
  abstract setNonPurchasableProductError(product: Product): void;

  /**
   * Clear not purchasable product error
   */
  abstract clearNonPurchasableProductError(): void;
}

result-matching ""

    No results matching ""