File

projects/congarevenuecloud/ecommerce/src/lib/modules/cart/services/user-view.service.ts

Description

User view service returns the configurable view of cart item fields to be displayed for a user on cart page.

Usage

import { UserViewService, AObjectService} from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {}

// or

export class MyService extends AObjectService {
private userViewService: UserViewService = this.injector.get(UserViewService);
}

Extends

AObjectService

Index

Properties
Methods

Methods

createUserView
createUserView(views: Array<CartColumnView>, flowName: string)

This method creates the CartColumnView for a given user. Set the created view as default by setting 'IsDefault' flag in the payload to true.

Example:

import { UserViewService } from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {
const views = new Array(CartColumnView);
this.subscriptions.push(this.userViewService.createUserView(views).subscribe(res => {....}));
}
Parameters :
Name Type Optional Default value Description
views Array<CartColumnView> No

instance of CartColumnView specifying the cart column view to be created for the active user.

flowName string No 'system'

string identifier, an optional parameter representing the flow name associated with storefront. Defaulted to 'system'.

an observable list of CartColumnView records created.

deleteView
deleteView(viewName: string, flowName: string)

This method deletes the view name for a given flow in the system. Deleting the default flow is not allowed.

Example:

import { UserViewService } from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {
this.subscriptions.push(this.userViewService.deleteView(viewName).subscribe(res => {....}));
}
Parameters :
Name Type Optional Default value Description
viewName string No

string identifier, specifying the name of cart column view to be deleted.

flowName string No 'system'

string identifier, an optional parameter representing the flow name associated with storefront. Defaulted to 'system'.

Returns : Observable<boolean>

an observable instance of a boolean indicating sucess upon completion of delete operation.

getAllViews
getAllViews(flowName: string)
Decorators :
@MemoizeWithHash()

This method retrieves the list of display columns associated with cart item fields, for a given flow. To optimize performance, it uses MemoizeWithHash decorator and caches the response in memory. See MemoizeWithHash for more details on the decorator.

Example:

import { UserViewService } from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {
this.subscriptions.push(this.userViewService.getAllViews().subscribe(res => {....}));
}
Parameters :
Name Type Optional Default value Description
flowName string No 'system'

string identifier, an optional parameter representing the flow name associated with storefront. Defaulted to 'system'.

an observable instance representing the list of CartColumnView.

getCartItemDisplayColumns
getCartItemDisplayColumns(flowName: string)

This method retrieves the list of display columns for cart line items, configured for a given flow. Returns the displays configured with DisplayType as 'Cart Line Item'.

Example:

import { UserViewService } from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {
this.subscriptions.push(this.userViewService.getCartItemDisplayColumns(viewName).subscribe(res => {....}));
}
Parameters :
Name Type Optional Default value Description
flowName string No 'system'

string identifier, an optional parameter representing the flow name associated with storefront. Defaulted to 'system'.

an observable list of ConfigCustomDisplayColumns.

getDefaultView
getDefaultView(flowName: string)

This method retrieves the display columns associated with cart item fields, matching the default user view. If default user view is not specified, it matches the default public view corresponding to the flowName provided.

Example:

import { UserViewService, CartColumnView } from '@congarevenuecloud/ecommerce';
view$: Observable<CartColumnView>;
view: CartColumnView;
constructor(private userViewService: UserViewService) {
getDefaultView() {
this.userViewService.getDefaultView().subscribe(c => this.view = c);
// or
this.view$ = this.userViewService.getDefaultView();
}
}
Parameters :
Name Type Optional Default value Description
flowName string No 'system'

optional paramater specifying the flowName associated to storefront. Defaulted to 'system'.

an observable instance of CartColumnView.

getMyView
getMyView(flowName: string)

This method retrieves the display columns associated with cart item fields, matching the default user view. If default user view is not specified, it matches the default public view corresponding to the flowName provided.

Example:

import { UserViewService, CartColumnView } from '@congarevenuecloud/ecommerce';
view$: Observable<CartColumnView>;
view: CartColumnView;
constructor(private userViewService: UserViewService) {
getMyView() {
this.userViewService.getMyView().subscribe(c => this.view = c);
// or
this.view$ = this.userViewService.getMyView();
}
}
Parameters :
Name Type Optional Default value Description
flowName string No 'system'

optional paramater specifying the flowName associated to storefront. Defaulted to 'system'.

an observable instance of CartColumnView.

getViewByName
getViewByName(viewName: string, flowName: string)

This method retrieves the display columns associated with cart item fields, matching the view name passed for a given flow.

Example:

import { UserViewService } from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {
this.subscriptions.push(this.userViewService.getViewByName(viewName).subscribe(res => {....}));
}
Parameters :
Name Type Optional Default value Description
viewName string No

string identifier, specifying the name of cart column view to be fetched.

flowName string No 'system'

string identifier, an optional parameter representing the flow name associated with storefront. Defaulted to 'system'.

an observable instance of CartColumnView.

onInit
onInit()
Returns : void
updateUserView
updateUserView(views: Array<CartColumnView>, flowName: string)

This method updates the existing CartColumnView for a given user.

Example:

import { UserViewService } from '@congarevenuecloud/ecommerce';

constructor(private userViewService: UserViewService) {
const views = new Array(CartColumnView);
this.subscriptions.push(this.userViewService.updateUserView(views).subscribe(res => {....}));
}
Parameters :
Name Type Optional Default value Description
views Array<CartColumnView> No

instance of CartColumnView specifying the cart column view to be updated for the active user.

flowName string No 'system'

string identifier, an optional parameter representing the flow name associated with storefront. Defaulted to 'system'.

an observable list of CartColumnView records updated.

Properties

apiService
Type : ApiService
Default value : this.injector.get(ApiService)
cartColumnViews
Type : Array<CartColumnView>
displayColumns
Type : Array<ConfigCustomDisplayColumns>
Default value : null
storefrontService
Type : StorefrontService
Default value : this.injector.get(StorefrontService)
type
Default value : CartColumnView
views$
Type : BehaviorSubject<Array<CartColumnView>>
Default value : new BehaviorSubject<Array<CartColumnView>>(null)

results matching ""

    No results matching ""