I add custom field to admin order form and I want it to be updated with ajax when admin add products to order, like other areas - shipping, billing and totals. I inspected file \vendor\magento\module-sales\view\adminhtml\web\order\create\scripts.js. There is a function

productGridAddSelected : function(){
        if(this.productGridShowButton) Element.show(this.productGridShowButton);
        var area = ['search', 'items', 'shipping_method', 'totals', 'giftmessage','billing_method'];

When I add my custom area name to it, like this, it works!

var area = ['custom_area', 'search', 'items', 'shipping_method','totals', 'giftmessage','billing_method'];....

But this is core file, so I need to do this somehow in my module. Any ideas how can I do this?

1 Answer 1


I ended up adding this js script to my html block template

if (typeof(order) != 'undefined') {
   order.prepareArea = function(area) {
        if (this.giftMessageDataChanged) {
            return area.without('giftmessage');
        if(order.getAreaId('store_credit')) area.push("store_credit");
        return area;

So basically I rewrite prepareArea function from AdminOrder class and add here my area. That's it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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