电子商务添加结帐步骤

ECommerce Add Checkout Step

我正在尝试 add a step to the Kentico 9 e-Commerce Checkout process。 我转到页面 > 特殊页面 > 结帐,然后添加了一个新的结帐页面。我向 Kentico 添加了一个名为 EntityUse Code 的新 Web 部件。

当我添加步骤时,出现此错误:

Message: Unable to cast object of type 'ASP.cmsmodules_ecommerce_controls_shoppingcart_shoppingcartnonprofit_ascx' to type '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;
    }
}
}

您似乎没有继承正确的基础class。 ShoppingCartStep 用于旧购物车模型中的结帐步骤。您需要使用 Web 部件库 class。我建议尝试使用 CMSCheckoutWebPart 代替。您可以使用一些基本的结帐 web 部件作为蓝图。您可以在 ~CMS\CMSWebParts\Ecommerce\Checkout 下找到它们。