I need to overwrite a javascript file from a custom module at:
vendor\amasty\module-single-step-checkout\view\frontend\web\js\model\one-step-layout.js
because I need to replace a code line in it to replace a template with my own module:
// Checkout layout options model
define([
'ko',
'uiRegistry',
'Amasty_Checkout/js/view/utils'
], function (ko, registry, viewUtils) {
'use strict';
const MAPPING_BLOCK_NAME = {
...
},
CLASS_NAMES = {
classic: {
...
},
modern: {
...
}
},
BLOCK_ATTRS = {
...
};
return {
containerClassNames: ko.observable(''),
selectedLayout: [],
checkoutDesign: '',
checkoutLayout: '',
checkoutBlocks: {},
mainAdditionalClasses: '',
/**
* Getting checkout block by name
* @param {String} blockName
* @returns {observable}
*/
getCheckoutBlock: function (blockName) {
var requestComponent = this.checkoutBlocks[blockName]
|| this.requestComponent(MAPPING_BLOCK_NAME[blockName]);
switch (blockName) {
case 'shipping_address':
if (requestComponent()) {
requestComponent().template = 'Amasty_Checkout/onepage/shipping/address';
}
break;
case 'shipping_method':
if (requestComponent()) {
// ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
// I need to replace this line with `Company_Shipping/onepage/shipping/methods`
requestComponent().template = 'Amasty_Checkout/onepage/shipping/methods';
}
break;
default: break;
}
return requestComponent;
},
...
How can I override that line from my own template?
I created this file app/code/Company/Shipping/view/frontend/requirejs-config.js file:
var config = {
config: {
mixins: {
'Amasty_Checkout/js/model/one-step-layout': {
'Company_Shipping/js/model/one-step-layout': true
}
}
}
};
Then I copied the file one-step-layout.js to app\code\Company\Shipping\view\frontend\web\js\model\one-step-layout.js.
This should mixin my script to the original script.
What code is required in my one-step-layout.js file to replace the template to load my own template?