我正在尝试add a step to the Kentico 9 e-Commerce Checkout process。 我去了网页>特殊页面>结帐,我添加了一个新的结帐页面。我向Kentico添加了一个名为EntityUse Code的新Web部件。
当我添加该步骤时,我收到此错误:
消息:无法转换类型' ASP.cmsmodules_ecommerce_controls_shoppingcart_shoppingcartnonprofit_ascx'输入' CMS.PortalControls.CMSAbstractWebPart'。
这是我的代码:
public partial class CMSModules_Ecommerce_Controls_ShoppingCart_ShoppingCartNonProfit : ShoppingCartStep
{
#region "ViewState Constants"
private const string SHIPPING_OPTION_ID = "OrderShippingOptionID";
private const string PAYMENT_OPTION_ID = "OrderPaymenOptionID";
private const string FEDERAL_TAX_ID = "FederalTaxID";
#endregion
/// <summary>
/// On page load.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">Event arguments.</param>
protected void Page_Load(object sender, EventArgs e)
{
lblTitle.Text = "Tax Exempt Order?";
var fedTaxId = this.ShoppingCart.ShoppingCartCustomData.GetValue("federaltaxid");
var entityUse = this.ShoppingCart.ShoppingCartCustomData.GetValue("entityusecode");
if (fedTaxId != null)
{
tbTaxID.Text = fedTaxId.ToString();
}
if (entityUse != null)
{
tbEntityUseCode.Text = entityUse.ToString();
}
}
/// <summary>
/// Back button actions
/// </summary>
public override void ButtonBackClickAction()
{
// Save the values to ShoppingCart ViewState
// this.ShoppingCartControl.SetTempValue(SHIPPING_OPTION_ID, this.drpShipping.SelectedValue);
//this.ShoppingCartControl.SetTempValue(PAYMENT_OPTION_ID, this.drpPayment.SelectedValue);
this.ShoppingCartControl.SetTempValue(FEDERAL_TAX_ID, tbTaxID.Text);
base.ButtonBackClickAction();
}
public override bool ProcessStep()
{
try
{
this.ShoppingCart.ShoppingCartCustomData.SetValue("federaltaxid", tbTaxID.Text);
this.ShoppingCart.ShoppingCartCustomData.SetValue("entityusecode", tbEntityUseCode.Text);
// Update changes in database only when on the live site
if (!ShoppingCartControl.IsInternalOrder)
{
ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
}
return true;
}
catch (Exception ex)
{
lblError.Visible = true;
lblError.Text = ex.Message;
return false;
}
}
}
答案 0 :(得分:2)
好像你没有继承正确的基类。 ShoppingCartStep
用于旧购物车模型中的结帐步骤。您需要使用Web部件基类。我建议尝试使用CMSCheckoutWebPart
代替。您可以使用一些基本的结帐Web部件作为蓝图。您可以在~CMS \ CMSWebParts \ Ecommerce \ Checkout下找到它们。