Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Set `totals` in products in cart always in reactive way - @psmyrek (#4079)
- Fix sync cart between tabs - @Michal-Dziedzinski (#3838)
- Add currentRoute to url module and return cached requests - @gibkigonzo (pr#4077, issue#4066)
- Fix gtm order placement event when user was guest - @Michal-Dziedzinski (#4064)

## [1.11.1] - 2020.02.05

Expand Down
2 changes: 1 addition & 1 deletion core/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const serial = async promises => {
return results
}

// helper to calcuate the hash of the shopping cart
// helper to calculate the hash of the shopping cart
export const calcItemsHmac = (items, token) => {
return sha3_224(JSON.stringify({ items, token: token }))
}
Expand Down
2 changes: 1 addition & 1 deletion core/modules/user/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const actions: ActionTree<UserState, RootState> = {
*/
async getOrdersHistory ({ dispatch, getters }, { refresh = true, useCache = true, pageSize = 20, currentPage = 1 }) {
if (!getters.getToken) {
Logger.debug('No User token, user unathorized', 'user')()
Logger.debug('No User token, user unauthorized', 'user')()
return Promise.resolve(null)
}
let resolvedFromCache = false
Expand Down
34 changes: 16 additions & 18 deletions src/modules/google-tag-manager/hooks/afterRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,30 @@ export function afterRegistration (config, store: Store<any>) {
}

// Measuring Purchases
if (type === 'order/order/LAST_ORDER_CONFIRMATION') {
if (type === 'order/orders/LAST_ORDER_CONFIRMATION') {
const orderId = payload.confirmation.backendOrderId
const products = payload.order.products.map(product => getProduct(product))
store.dispatch(
'user/getOrdersHistory',
{ refresh: true, useCache: false }
).then(() => {
const orderHistory = state.user.orders_history
const order = orderHistory.items.find((order) => order['entity_id'].toString() === orderId)
if (order) {
GTM.trackEvent({
'ecommerce': {
'purchase': {
'actionField': {
'id': orderId,
'affiliation': order.store_name,
'revenue': order.total_due,
'tax': order.tax_amount,
'shipping': order.shipping_amount,
'coupon': ''
},
'products': products
}
const order = state.user.orders_history ? orderHistory.items.find((order) => order['entity_id'].toString() === orderId) : null
GTM.trackEvent({
'ecommerce': {
'purchase': {
'actionField': {
'id': orderId,
'affiliation': order ? order.store_name : '',
'revenue': order ? order.total_due : state.cart.platformTotals && state.cart.platformTotals.base_grand_total ? state.cart.platformTotals.base_grand_total : '',
'tax': order ? order.total_due : state.cart.platformTotals && state.cart.platformTotals.base_shipping_amount ? state.cart.platformTotals.base_shipping_amount : '',
'shipping': order ? order.total_due : state.cart.platformTotals && state.cart.platformTotals.base_tax_amount ? state.cart.platformTotals.base_tax_amount : '',
'coupon': ''
},
'products': products
}
})
}
}
})
})
}
})
Expand Down