Skip to content

Commit 87def64

Browse files
authored
Order Confirmation bug fixes (#6)
* removed conditional blocking order confirmations from being sent * Order Confirmation bug fixes * Removed status check until strategy is specced * Rebased & updated changelog * Rebased & updated changelog * Added status check back in for safety
1 parent 01281fb commit 87def64

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bumped for multiple releases during one month.
99
### [Unreleased]
1010
##### Fixed
1111
- Order Confirmation event will now correctly fire for orders with coupons.
12+
- Order Confirmation will now correctly fire if product has no primary category.
1213
##### Updated
1314
- Rename sendEmail function to trackEvent
1415
- Fix grammar/typos in comments and docstrings

cartridges/int_klaviyo_core/cartridge/scripts/utils/klaviyo/emailUtils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ function prepareOrderPayload(order, isFutureOrder, mailType) {
105105
}
106106

107107
items.push(productLineItem.productID);
108-
109108
itemCount += productLineItem.quantity.value;
110109
var allCategories;
111110
if (productDetail.variant) {
112-
itemPrimaryCategories.push(productDetail.masterProduct.getPrimaryCategory().displayName);
111+
if (productDetail.masterProduct.getPrimaryCategory()) {
112+
itemPrimaryCategories.push(productDetail.masterProduct.getPrimaryCategory().displayName);
113+
}
113114
allCategories = productDetail.masterProduct.getAllCategories();
114115
} else {
115-
itemPrimaryCategories.push(productDetail.getPrimaryCategory().displayName);
116+
if (productDetail.getPrimaryCategory()) {
117+
itemPrimaryCategories.push(productDetail.getPrimaryCategory().displayName);
118+
}
116119
allCategories = productDetail.getAllCategories();
117120
}
118121

cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/klaviyoDataLayer.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var Logger = require('dw/system/Logger');
66
var productMgr = require('dw/catalog/ProductMgr');
77
var orderMgr = require('dw/order/OrderMgr');
88
var basketMgr = require('dw/order/BasketMgr');
9+
var Logger = require('dw/system/Logger');
910

1011
var buildDataLayer = function () {
1112
var logger = Logger.getLogger('Klaviyo', 'SFRA klaviyoDataLayer - buildDataLayer()');
@@ -49,18 +50,16 @@ var buildDataLayer = function () {
4950
}
5051

5152
// Order Confirmation Event
52-
if (pageContext == 'orderconfirmation' && orderID) {
53+
if (orderID && !empty(orderID.rawValue)) {
5354
logger.info('Building dataLayer for "Order Confirmation" event.');
5455
KlaviyoUtils = require('*/cartridge/scripts/utils/klaviyo/klaviyoUtils');
55-
56-
if (!dw.system.Site.getCurrent().getCustomPreferenceValue('klaviyo_order_transactional_enabled')) {
57-
return;
58-
}
5956
currentOrder = orderMgr.getOrder(orderID);
60-
KlaviyoUtils.prepareOrderConfirmationEventForKlaviyo(currentOrder);
57+
// check to see if the status is new or created
58+
if (currentOrder.status == 3 || currentOrder.status == 4) {
59+
KlaviyoUtils.prepareOrderConfirmationEventForKlaviyo(currentOrder);
60+
}
6161
}
6262

63-
6463
// Viewed Product event
6564
if (!empty(pageProductID.rawValue)) {
6665
logger.info('Building dataLayer for "Viewed Product" event.');

0 commit comments

Comments
 (0)