1

There is a view OrderWizard module view in suitecommerce core code.It has methods similar to below(not the exact code, not pasting for proprietary issues). I have created the extension and calling OrderWizard's method from the extension.

    **setAddr: function(xxx, xxxx) {
        this.model.setAddress(xxx, xxxx, xxxx);
        
        return this;
    }
  renderView: function() {
        
        if (!this.isActiveVal()) {
            return this;
        }
    }**



Extension class:

**define(
    'TEST.PaymentValidation.PaymentValidation'
,   [
       'OrderWizard.xxxxx.xxxxx'
    ]
,   function (
       OrderWizardAddress
    )
{
    'use strict';
    return  {
        mountToApp: function mountToApp (container)
        {
            _.extend(OrderWizardAddress.prototype,
                {
                    setAddressExt: function setAddressExt() {
                        {
                            OrderWizardAddress.prototype.setAddr.apply(this, arguments);
                        }
                    }
                });
            _.extend(OrderWizardAddress.prototype,
                {
                    renderExt: function renderExt() {
                        {
                            OrderWizardAddress.prototype.renderView.apply(this, arguments);
                        }
                    }
                }); 
                
            OrderWizardAddress.prototype.setAddressExt();
            OrderWizardAddress.prototype.renderExt();
        }
    };
});**

when calling the renderExt method, Cannot read property 'isActiveVal' of undefined TypeError: Cannot read property 'isActiveVal' of undefined. Eventhough isActiveVal is available in OrderWizard view.

When calling the setAddressExt I'm getting 'this is undefined'.

Can someone help me what I'm doing wrong here. What is the best way to call the suitecommerce core codes method from the extension.I guess I'm not passing the actual context(.apply(this) of the OrderWizard view.

igu
  • 11
  • 2

1 Answers1

0

Figured out the solution.Basically two independent views have to communicate among each other and display the value. Payment view and Billing view are two different views. Based on the payment method selected, default billing address needs to selected.Used Backbone's event queue aggregator approach to solve this problem. when the payment method is selected, a publisher sends a message to subscriber. If the payments method is Invoice, publisher publishes the message to subscriber which triggers a method to select the default Billing address. To add new method from the extension, used the javascript prototype and to add codes to the existing method, used the underscore's wrap method

igu
  • 11
  • 2