5

This question already has an answer here:

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

marked as duplicate by Siarhey Uchukhlebau, Murtuza Zabuawala, Keyul Shah, Amit Bera, Raphael at Digital Pianism Feb 20 '17 at 8:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

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',
            }
        }
    };
  • should i write all the code or just the function i want to rewrite? – simple guy Feb 20 '17 at 5:28
  • 1
    you can write all code. – Rakesh Jesadiya Feb 20 '17 at 5:29
  • can i just write the function that i want to override? – simple guy Feb 20 '17 at 5:34
  • i havent try with only function, May be you can done it with only function. jsut try with that and check. – Rakesh Jesadiya Feb 20 '17 at 5:35
  • have you check using only function? – Rakesh Jesadiya Feb 20 '17 at 6:55

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