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
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:
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.
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:
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.
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
is working on a reply...