Skip to content

Commit

Permalink
[PPI-976] update cart, track order
Browse files Browse the repository at this point in the history
  • Loading branch information
lysy-vlc committed Dec 11, 2023
1 parent be29dc0 commit 20352f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/constants/track-event.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export enum TRACK_EVENT {
REMOVE_ECOMMERCE_ITEM = 'ecommerceAddToCart',
CLEAR_ECOMMERCE_CART = 'clearEcommerceCart',
SET_ECOMMERCE_VIEW = 'setEcommerceView',
UPDATE_ECOMMERCE_CART = 'trackEcommerceCartUpdate',
ORDER_ECOMMERCE = 'trackEcommerceOrder',
UPDATE_ECOMMERCE_CART = 'ecommerceCartUpdate',
ORDER_ECOMMERCE = 'ecommerceOrder',
SET_CUSTOM_VARIABLE = 'setCustomVariable',
DELETE_CUSTOM_VARIABLE = 'deleteCustomVariable',
STORE_CUSTOM_VARIABLES_IN_COOKIE = 'storeCustomVariablesInCookie',
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/payment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type PaymentInformation = {
orderId: string;
grandTotal: number | string;
subTotal?: number | string;
tax?: number | string;
shipping?: number | string;
discount?: number | string;
};
23 changes: 7 additions & 16 deletions src/services/e-commerce/e-commerce.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TRACK_EVENT } from '../../constants/track-event.constant';
import { PaqService } from '../paqService/paq.service';
import { Product } from '../../interfaces/product'
import { PaymentInformation } from '../../interfaces/payment'

export function addEcommerceItem(product: Product) {
PaqService.push([
Expand Down Expand Up @@ -38,29 +39,19 @@ export function getEcommerceItems(): Promise<object> {
});
}

export function trackEcommerceOrder(
orderId: string,
orderGrandTotal: number,
orderSubTotal?: number,
orderTax?: number,
orderShipping?: number,
orderDiscount?: number
) {
export function ecommerceOrder(products: Product[], paymentInformation: PaymentInformation) {
PaqService.push([
TRACK_EVENT.ORDER_ECOMMERCE,
orderId,
orderGrandTotal,
orderSubTotal,
orderTax,
orderShipping,
orderDiscount,
products,
paymentInformation,
]);
}

export function trackEcommerceCartUpdate(cartAmount: number) {
export function updateEcommerceCart(products: Product[], grandTotal: number | string) {
PaqService.push([
TRACK_EVENT.UPDATE_ECOMMERCE_CART,
cartAmount
products,
grandTotal,
]);
}

Expand Down

0 comments on commit 20352f2

Please sign in to comment.