Skip to content

Commit

Permalink
Merge pull request #3195 from cnviradiya/bugfix/google-tag-manager-issue
Browse files Browse the repository at this point in the history
Fixed error for the orderhistory null
  • Loading branch information
patzick committed Jul 9, 2019
2 parents 6161f63 + 0f338a9 commit cfdc483
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Resolve problem with getting CMS block from cache - @qiqqq (#2499)
- Make image proxy url work with relative base url - @cewald (#3158)
- Fixed memory leak with enabled dynamicConfigReload - @dimasch (#3075)
- Fixed error for the orderhistory null for google-tag-manager extension - @cnviradiya (#3195)

### Changed / Improved
- Shipping address is saved as default when not logged in user chooses to create account during checkout - @iwonapiotrowska (#2636)
Expand Down
34 changes: 18 additions & 16 deletions src/modules/google-tag-manager/hooks/afterRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,25 @@ export function afterRegistration (Vue, config, store, isServer) {
{ refresh: true, useCache: false }
).then(() => {
const orderHistory = state.user.orders_history
const order = orderHistory.items.find((order) => order['entity_id'].toString() === orderId)
if (order) {
Vue.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
if (orderHistory) {
const order = orderHistory.items.find((order) => order['entity_id'].toString() === orderId)
if (order) {
Vue.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
}
}
}
})
})
}
}
})
}
Expand Down

0 comments on commit cfdc483

Please sign in to comment.