-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mageworx/update_comp
Update compatibility: add support of new version of the main module
- Loading branch information
Showing
7 changed files
with
60 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*jshint browser:true jquery:true*/ | ||
/*global alert*/ | ||
define([ | ||
'mage/utils/wrapper', | ||
'uiRegistry', | ||
'underscore' | ||
], function (wrapper, registry, _) { | ||
'use strict'; | ||
|
||
return function (originalPayloadExtender) { | ||
|
||
return wrapper.wrap(originalPayloadExtender, function (originalAction) { | ||
if (!_.isEmpty(mwDeliveryDateConfig) && mwDeliveryDateConfig.enabled) { | ||
let payload = originalAction(), | ||
shippingAddress = payload.addressInformation.shipping_address, | ||
deliveryDateSource = registry.get('deliveryDateProvider'), | ||
deliveryDateData = deliveryDateSource.delivery_date || {}; | ||
|
||
if (shippingAddress['extensionAttributes'] === undefined) { | ||
shippingAddress['extensionAttributes'] = {}; | ||
} | ||
|
||
shippingAddress['extensionAttributes']['delivery_comment'] = deliveryDateData['delivery_comment']; | ||
shippingAddress['extensionAttributes']['delivery_day'] = deliveryDateData['delivery_day']; | ||
shippingAddress['extensionAttributes']['delivery_option_id'] = deliveryDateData['delivery_option_id']; | ||
shippingAddress['extensionAttributes']['delivery_time'] = deliveryDateData['delivery_time']; | ||
|
||
// Validate custom attributes and | ||
// pass execution to original action ('Magento_Checkout/js/action/set-shipping-information') | ||
deliveryDateSource.set('params.invalid', false); | ||
deliveryDateSource.trigger('delivery_date.data.validate'); | ||
|
||
if (deliveryDateSource.get('params.invalid')) { | ||
console.log('DELIVERY DATE ERROR!!!'); | ||
} else { | ||
return payload; | ||
} | ||
} | ||
}); | ||
|
||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters