2016-07-25 78 views
-2

我想要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; 
    } 
} 
} 

回答

2

好像你是不是繼承了正確的基類。 ShoppingCartStep用於舊購物車模型中的結帳步驟。您需要使用Web部件基類。我建議您嘗試使用CMSCheckoutWebPart。您可以使用一些基本的結帳Web部件作爲藍圖。您可以在〜CMS \ CMSWebParts \ Ecommerce \ Checkout下找到它們。

+0

謝謝!我做了這個KB:http://support.cloudcartconnector.com/hc/en-us/articles/212229983-Kentico-Avalara-Entity-Use-Codes –