SuiteCommerce 高级从扩展调用核心代码的方法



在suitecommerce核心代码中有一个视图OrderWizard模块视图。它有类似于下面的方法(不是确切的代码,不是针对专有问题粘贴(。 我已经创建了扩展并从扩展调用 OrderWizard 的方法。

**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();
}
};
});**

调用 renderExt 方法时, 无法读取未定义的属性"isActiveVal"类型错误:无法读取未定义的属性"isActiveVal"。即使 isActiveVal 在 OrderWizard 视图中可用。

调用设置地址分机时 我得到"这是未定义的"。

有人可以帮助我在这里做错什么吗?从扩展调用suitecommerce核心代码方法的最佳方法是什么。我想我没有传递订单向导视图的实际上下文(.apply(this(。

想出了解决方案。基本上,两个独立的视图必须相互通信并显示值。 付款视图和帐单视图是两个不同的视图。根据所选的付款方式,需要选择默认帐单地址。使用 Backbone 的事件队列聚合器方法来解决此问题。选择付款方式后,发布者会向订阅者发送消息。如果付款方式为"发票",则发布者会将消息发布给订阅者,这会触发选择默认帐单邮寄地址的方法。 要从扩展添加新方法,请使用 javascript 原型并将代码添加到现有方法中,使用了下划线的包装方法

最新更新