Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Bill Harper 1 post 21 karma points
    Apr 02, 2015 @ 20:08
    Bill Harper
    0

    Change an existing uCommerce site addToBasket addtoexistingline from true to false

    I have a wholesale uCommerce site that has recently gone live.  Now the customer is coming back to me and saying they want each addition to the cart to be on its own line.  I found AddToBasket in the Basket helper code.  In that script changed 

    TransactionLibrary.AddToBasket(quantity, variant.Sku, variant.VariantSku); 

    to

    TransactionLibrary.AddToBasket(quantity, variant.Sku, variant.VariantSku, false, false);

    Now when the product is added to the cart, the new orderline is added but throws this error:

    ____________________________________________________

    Exception Details: System.InvalidOperationException: Sequence contains more than one element

    Source Error: 

    Line 32:         var variant = uCommerce.Functions.Product.GetVariantFromPostData(product, "variation-");
    Line 33: @* View /App_Code/uCommerce/Functions/Basket.cshtml for this function *@
    Line 34:         itemAddedToCart = uCommerce.Functions.Basket.AddToBasket("add-to-basket", "quantity-to-add", variant);
    Line 35:         
    Line 36: 

    [InvalidOperationException: Sequence contains more than one element]
       System.Linq.Enumerable.Single(IEnumerable`1 source) +691
       ASP.uCommerce.Functions.Basket.AddToBasket(String addToBasketKey, String quantityKey, Product variant) +701
       ASP._Page_macroScripts_ProductPage_cshtml.Execute() in g:\websites\EyeQEyeware.com\MacroScripts\ProductPage.cshtml:34
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
       System.Web.WebPages.WebPage.ExecutePageHierarchy() +360
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
       umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) +603
       umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage) +376
       umbraco.macro.loadMacroScript(MacroModel macro) +295
       umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId) +6055
       umbraco.presentation.templateControls.Macro.CreateChildControls() +1849
       System.Web.UI.Control.EnsureChildControls() +189
       System.Web.UI.Control.InitRecursive(Control namingContainer) +186
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Control.InitRecursive(Control namingContainer) +291
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098

     

    I'm relatively new to C#, Umbraco, and uCommerce. I don't see how to finish inplementing this change. The only direction I've found online is to set addToExistingLine to false but nothing further.  Any help is greatly appreciated.  

  • Jesper Nielsen 141 posts 498 karma points
    Apr 14, 2015 @ 12:34
    Jesper Nielsen
    0

    Hello Bill,

    The exception is being thrown from inside your helper code. Not from inside uCommerce.

    So please look for a call to Single() after the call to TransactionLibrary.AddToBasket().

    There is a call to Single() somewhere. Maybe it assumes that there is only one OrderLine with a given Sku?

    Kind regards,
    Jesper

Please Sign in or register to post replies

Write your reply to:

Draft