Skip to content

Commit

Permalink
Use selectedItem
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoleone committed Apr 8, 2024
1 parent eb382f4 commit 4559c3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions react/modules/gaEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,11 @@ export function addToWishlist(eventData: AddToWishlistData) {
productReference,
} = product

const variant = sku ? sku.itemId : product.items[0].itemId
console.log("EVENT:", eventData)

const seller = getSeller(sku ? sku.sellers : product.items[0].sellers)
const variant = sku ? sku.itemId : items.selectedItem.itemId

const seller = getSeller(sku ? sku.sellers : items.selectedItem.sellers)
const value = getPrice(seller)
const categoriesHierarchy = getCategoriesWithHierarchy(categories)
const discount = getDiscount(seller)
Expand All @@ -366,8 +368,8 @@ export function addToWishlist(eventData: AddToWishlistData) {
...categoriesHierarchy,
...customDimensions({
productReference,
skuReference: sku ? sku.referenceId.Value : product.items[0].referenceId?.Value,
skuName: sku ? sku.name : product.items[0].name,
skuReference: sku ? sku.referenceId.Value : items.selectedItem.referenceId,
skuName: sku ? sku.name : items.selectedItem.name,
quantity,
}),
}
Expand Down
2 changes: 2 additions & 0 deletions react/typings/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export interface AddToWishlistData extends EventData {
eventType: 'vtex:addToWishlist'
eventName: 'vtex:addToWishlist'
items: {
selectedItem: any
product: ProductSummary
}
list: string
Expand Down Expand Up @@ -485,6 +486,7 @@ export interface ProductSummary {
productId: string
productName: string
productReference: string
selectedItem: any
sku: ItemSummary
}

Expand Down

0 comments on commit 4559c3b

Please sign in to comment.