File

projects/congarevenuecloud/ecommerce/src/lib/modules/order/services/order.service.ts

Description

The order represents purchase of products. The orders are generally converted from the cart.

Usage

Example :
import { OrderService } from '@congarevenuecloud/ecommerce';

constructor(private orderService: OrderService) {}

// or

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

Extends

AObjectService

Index

Properties
Methods

Methods

acceptOrder
acceptOrder(orderId: string)

This method confirms the order based on the order id passed.

Parameters :
Name Type Optional Description
orderId string No

string identifier of the order record.

Returns : Observable<Order>

observable containing the confirmed order.

convertCartToOrder
convertCartToOrder(order: Order, primaryContact?: Contact, fieldList?: Array)

Method converts the current cart into a order instance.

Example:

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

export class MyComponent implements OnInit{
order: Order;

constructor(private orderService: OrderService){}

ngOnInit(){
const q = new Order();
q.Name = 'Sample Order';
this.orderService.convertCartToOrder(q).subscribe(
q => this.order = q,
err => {...}
);
}
}
Parameters :
Name Type Optional Default value Description
order Order No new Order()

order instance to specify predefined parameters on the order that gets created.

primaryContact Contact Yes

contact instance to specify primary contact deatils on the order that gets created.

fieldList Array<Field> Yes

optional parameter specifying the fields to be passed in the order payload.

Returns : Observable<Order>

an observable of the order instance that was created from the cart.

convertOrderToCart
convertOrderToCart(order: Order)

Method creates new cart and clones the finalized cart linked to the order, and sets the new cart as active.

Example:

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

export class MyComponent implements OnInit{
Order: Order;

constructor(private OrderService: OrderService){}

convertOrderToCart(Order: Order) {
this.OrderService.convertOrderToCart(Order).subscribe(
c => c,
err => {...}
);
}
}
}
Parameters :
Name Type Optional Description
order Order No

an order instance to specify predefined parameters on the order that gets created.

Returns : Observable<Cart>

an observable of the cart instance.

getAllOrders
getAllOrders(accountId: string, days?: number, filters?: Array<FieldFilter>, relatedRecords: string, limit: number, pageNumber: number, orderBy: string, orderDirection: "ASC" | "DESC", showErrorToaster: boolean)

The method fetches the list of orders based on the parameters passed.

Example:

Example :
import { OrderService, Order } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Array<Order>
result$: Observable<Array<Order>>;
constructor(private orderService: OrderService){}

getAllOrders(accountId: string = null, days?: number, filters?: Array<FieldFilter>, relatedRecords: string = '', limit: number = 10, pageNumber: number = 1, orderBy: string = 'CreatedDate', orderDirection: 'ASC' | 'DESC' = 'DESC'): Observable<Array<Order>> {
this.orderService.getAllOrders(accountId, 7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items').subscribe(r => this.result = r);
// or
results$ = this.orderService.getAllOrders(accountId, 7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items');
}
}
Parameters :
Name Type Optional Default value Description
accountId string No null

string identifier of the account (Sold to) to filter the orders with.

days number Yes

optional parameter to filter the orders created for the last 'x' number of days.

filters Array<FieldFilter> Yes

list of order field filters to filter the order records.

relatedRecords string No ''

related records(order line items, prices etc.) to be fetched for the order(s). Takes in order related fields as comma separated string.

limit number No 10

number representing the number of order records to be fetched.

pageNumber number No 1

number representing the pagination.

orderBy string No 'CreatedDate'

string representing the sort field on the order.

orderDirection "ASC" | "DESC" No 'DESC'

string representing the sort direction. Posible values are 'ASC' or 'DESC'.

showErrorToaster boolean No true

boolean indicates whether the underlying API exceptions should be shown as a toaster message in UI. Defaulted to true.

An observable containing the list of orders matching the criteria with total order count.

getMyOrder
getMyOrder()
Returns : Observable<Order>

A hot observable containing the single order instance

getMyOrders
getMyOrders(accountId: string, days?: number, filters?: Array<FieldFilter>, relatedRecords: string, limit: number, pageNumber: number, orderBy: string, orderDirection: "ASC" | "DESC", showErrorToaster: boolean)

This method is work in progress, currently returning all orders. The method fetches the list of orders based on the parameters passed.

Example:

Example :
import { OrderService, Order } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Array<Order>
result$: Observable<Array<Order>>;
constructor(private orderService: OrderService){}

getMyOrders(accountId: string = null, days?: number, filters?: Array<FieldFilter>, relatedRecords: string = '', limit: number = 10, pageNumber: number = 1, orderBy: string = 'CreatedDate', orderDirection: 'ASC' | 'DESC' = 'DESC'): Observable<Array<Order>> {
this.orderService.getMyOrders(accountId, 7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items').subscribe(r => this.result = r);
// or
results$ = this.orderService.getMyOrders(accountId, 7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items');
}
}
Parameters :
Name Type Optional Default value Description
accountId string No null

string identifier of the account (Sold to) to filter the orders with.

days number Yes

optional parameter to filter the orders created for the last 'x' number of days.

filters Array<FieldFilter> Yes

list of order field filters to filter the order records.

relatedRecords string No ''

related records(order line items, prices etc.) to be fetched for the order(s). Takes in order related fields as comma separated string.

limit number No 10

number representing the number of order records to be fetched.

pageNumber number No 1

number representing the pagination.

orderBy string No 'CreatedDate'

string representing the sort field on the order.

orderDirection "ASC" | "DESC" No 'DESC'

string representing the sort direction. Posible values are 'ASC' or 'DESC'.

showErrorToaster boolean No true

boolean indicates whether the underlying API exceptions should be shown as a toaster message in UI. Defaulted to true.

An observable containing the list of orders matching the criteria with total order count.

getOrder
getOrder(Id: string)

The method fetches the order based on given order Id in parameter.

Example:

Example :
import { OrderService, Order } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Order
result$: Observable<Order>;
constructor(private orderService: OrderService){}

getOrder(orderId: string){
this.orderService.getOrder(orderId).subscribe(r => this.result = r);
// or
results$ = this.orderService.getOrder(orderId);
}
}
Parameters :
Name Type Optional Description
Id string No

string identifier representing order to fetch the details for.

Returns : Observable<Order>

An observable instance of order with details.

getOrderAggregatesByStatus
getOrderAggregatesByStatus(account?: string | Account, aggregateFields?: Array<AggregateFields>, queryFields: Array, groupByFields: Array, filterList: Array<FieldFilter>)

This method returns an aggregate result based on order aggregate criteria.

Parameters :
Name Type Optional Default value Description
account string | Account Yes

instance of account object or a string identifier of the account.

aggregateFields Array<AggregateFields> Yes

used in query.

queryFields Array<string> No []

list of aobject fields to be part of the query response.

groupByFields Array<string> No []

list of aobject fields to be part of the group by clauses.

filterList Array<FieldFilter> No []

A list of FieldFilter objects representing the filters to be applied.

observable containing aggregate response.

getOrderByName
getOrderByName(orderName: string)

The method fetches the order details based on the order name passed.

Parameters :
Name Type Optional Description
orderName string No

string representing name of the order record.

Returns : Observable<Order>

observable of the order object matching the order name.

getOrderByQuote
getOrderByQuote(quoteId: string)

The method fetches the order details based on the associated quote.

Parameters :
Name Type Optional Description
quoteId string No

string identifier of the quote.

Returns : Observable<Order>

observable of the order object associated with the quote.

Public publish
publish(order: Order)

The method is used to emit the state of the order.

Parameters :
Name Type Optional Description
order Order No

instance of order.

Returns : void
updateOrder
updateOrder(orderId: string, payload: Order)

This method updates the order object based on the payload passed.

Parameters :
Name Type Optional Description
orderId string No

string identifier of the order record.

payload Order No

order data to be updated.

Returns : Observable<Order>

observable containing the updated order.

Properties

Protected accountService
Default value : this.injector.get(AccountService)
cartItemService
Default value : this.injector.get(CartItemService)
Protected cartService
Default value : this.injector.get(CartService)
Protected ngZone
Type : NgZone
Default value : this.injector.get(NgZone)
Protected priceListService
Default value : this.injector.get(PriceListService)
type
Default value : Order
Protected userService
Default value : this.injector.get(UserService)

results matching ""

    No results matching ""