5

in backend there is module-sales/view/adminhtml/web/order/create/scripts.js, and inside that js there is a function like this :

loadShippingRates : function(){
            this.isShippingMethodReseted = false;
            this.loadArea(['shipping_method', 'totals'], true, {collect_shipping_rates: 1});
        }

i want to change the function, so it will send another data to loadArea function like this:

loadShippingRates : function(){
            this.isShippingMethodReseted = false; 
            var yeezy= jQuery('#order-billing_address_yeezy').val();
            this.loadArea(['shipping_method', 'totals'], true, {collect_shipping_rates: 1, yeezy_is_ready_yoo: yeezy});
        }

when i change from pub/static my custom function works fine, but i don't know how to override this function from custom extension

1

1 Answer 1

5

You can override core js file using below way,

app/code/Namespace/Modulename/view/adminhtml/web/js/order/create/script.js

Keep requirejs-config.js file at below location for override core js file, app/code/Namespace/Modulename/view/adminhtml/requirejs-config.js

 var config = {
        map: {
            '*': {
                "Magento_Sales/js/order/create/script": 'Namespace_Modulename/js/order/create/script',
            }
        }
    };
7
  • should i write all the code or just the function i want to rewrite?
    – simple guy
    Commented Feb 20, 2017 at 5:28
  • 1
    you can write all code. Commented Feb 20, 2017 at 5:29
  • can i just write the function that i want to override?
    – simple guy
    Commented Feb 20, 2017 at 5:34
  • i havent try with only function, May be you can done it with only function. jsut try with that and check. Commented Feb 20, 2017 at 5:35
  • have you check using only function? Commented Feb 20, 2017 at 6:55

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