Skip to content

Instantly share code, notes, and snippets.

@veritstudio
Created May 24, 2019 19:34
Show Gist options
  • Save veritstudio/b02feb93cff3e54b6abbc89399f0ec1b to your computer and use it in GitHub Desktop.
Save veritstudio/b02feb93cff3e54b6abbc89399f0ec1b to your computer and use it in GitHub Desktop.
Automatically check billing address same as shipping in Magento 2
define([
'jquery',
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/model/quote'
],function ($, checkoutData, quote) {
'use strict';
return function (Component) {
return Component.extend({
initObservable: function () {
this._super()
.observe({
isAddressSameAsShipping: !(quote.billingAddress() === undefined || checkoutData.getSelectedBillingAddress() === 'new-customer-address')
});
return this;
}
});
};
});
var config = {
config: {
mixins: {
'Magento_Checkout/js/view/billing-address': {
'Magento_Checkout/js/view/billing-address-mixin': true
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment