1

I want to override function setShippingMethod() to my module js vendor\magento\module-sales\view\adminhtml\web\order\create\scripts.js

here is a function

define([
    "jquery",
    'Magento_Ui/js/modal/confirm',
    'Magento_Ui/js/modal/alert',
    "mage/translate",
    "prototype",
    "Magento_Catalog/catalog/product/composite/configure",
    'Magento_Ui/js/lib/view/utils/async'
], function(jQuery, confirm, alert){

    window.AdminOrder = new Class.create();

    AdminOrder.prototype = {
        ...
        ...
        ...
        setShippingMethod : function(method){
            var data = {};
            data['order[shipping_method]'] = method;
            console.log(method);
            this.loadArea(['shipping_method', 'totals', 'billing_method'], true, data);
            /*if(method=='dpd_relay_common'){
                jQuery( "#click-me" ).trigger( "click" );

            }*/
        },
        ...
        ...
        ...
    };

});

1 Answer 1

0

To overide that things, you need to do this things.

  1. Vendor\Extension\view\adminhtml\requirejs-config.js add this:

    var config = {
      map: {
        '*': {
            'Magento_Sales/order/create/scripts':'Vendor_Extension/order/create/scripts'
        }
      }
    };
    
  2. Then create the file Vendor\Extension\view\adminhtml\web\order\create\scripts.js with your content.

2
  • I want to override only one function instead file, this function declared with some different syntax, that's why I'm asking Oct 14, 2019 at 4:53
  • single function is not possible, but in this way when you overide this one, you need to modify only that function, rest of the things you need to take as it is. Oct 14, 2019 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.