Skip to content

Commit

Permalink
Merge pull request #123 from lsimeonov/fix/extend-extension-attributes
Browse files Browse the repository at this point in the history
Keep existing extension attributes when extending shipping payload request
  • Loading branch information
klaviyojad authored Jul 1, 2021
2 parents 5c1ab2f + 4f7ff2c commit a552b0f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 73 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### [Unreleased]

### [3.0.6] - 2021-07-01

#### Added
- Add an ability to pass the Store ID during track event

#### Fixed
- Keep existing extension attributes when extending shipping payload request

### [3.0.5] - 2021-06-08

#### Added
Expand Down Expand Up @@ -104,7 +109,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- CSP now uses report-only mode


[Unreleased]: https://github.com/klaviyo/magento2-klaviyo/compare/3.0.5...HEAD
[Unreleased]: https://github.com/klaviyo/magento2-klaviyo/compare/3.0.6...HEAD
[3.0.6]: https://github.com/klaviyo/magento2-klaviyo/compare/3.0.5...3.0.6
[3.0.5]: https://github.com/klaviyo/magento2-klaviyo/compare/3.0.4...3.0.5
[3.0.4]: https://github.com/klaviyo/magento2-klaviyo/compare/3.0.3...3.0.4
[3.0.3]: https://github.com/klaviyo/magento2-klaviyo/compare/3.0.2...3.0.3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "klaviyo/magento2-extension",
"description": "Klaviyo extension for Magento 2. Allows pushing newsletters to Klaviyo's platform and more.",
"type": "magento2-module",
"version": "3.0.5",
"version": "3.0.6",
"autoload": {
"files": [
"registration.php"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Klaviyo_Reclaim" setup_version="3.0.5" schema_version="3.0.5">
<module name="Klaviyo_Reclaim" setup_version="3.0.6" schema_version="3.0.6">
<sequence>
<module name="Magento_Customer"/>
<module name="Magento_Checkout"/>
Expand Down
8 changes: 7 additions & 1 deletion view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ var config = {
map: {
'*': {
KlaviyoCustomerData: 'Klaviyo_Reclaim/js/customer',
'Magento_Checkout/js/model/shipping-save-processor/default': 'Klaviyo_Reclaim/js/model/shipping-save-processor/default'
}
},
config: {
mixins: {
'Magento_Checkout/js/model/shipping-save-processor/payload-extender': {
'Klaviyo_Reclaim/js/mixin/shipping-payload-extender-mixin': true
},
}
}
};
22 changes: 22 additions & 0 deletions view/frontend/web/js/mixin/shipping-payload-extender-mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
define([
'mage/utils/wrapper',
'Klaviyo_Reclaim/js/model/shipping-payload/assigner'
], function (wrapper, assignData) {
'use strict';

/**
* This file works on Magento >= 2.2.2 only.
*
* @param {Object} target
* @return {Object}
*/
return function (target) {
return wrapper.wrap(target, function (parentFunction, payload) {
parentFunction(payload);

assignData(payload.addressInformation);

return payload;
});
};
});
19 changes: 19 additions & 0 deletions view/frontend/web/js/model/shipping-payload/assigner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define([
'jquery',
'underscore',
], function ($,_, registry) {
'use strict';

return function (container) {
var kl_sms_consent = $('[name="custom_attributes[kl_sms_consent]"]').is(':checked');
var kl_email_consent = $('[name="custom_attributes[kl_email_consent]"]').is(':checked');

container.extension_attributes = _.extend(
container.extension_attributes || {},
{
kl_sms_consent: kl_sms_consent,
kl_email_consent: kl_email_consent
}
);
};
});
69 changes: 0 additions & 69 deletions view/frontend/web/js/model/shipping-save-processor/default.js

This file was deleted.

0 comments on commit a552b0f

Please sign in to comment.