November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
As I have not received an answer, I changed my approach and transform AddToCart method like this:
public static string AddToCart(Product p) { OrderForm orderForm; LineItem lineItem; //If GetCart can't find the cart, it will create it for you Cart defaultCart = OrderContext.Current.GetCart(Cart.DefaultName, EPiServer.Security.PrincipalInfo.CurrentPrincipal.GetContactId()); //manually create an orderform and add a lineitem to it orderForm = new OrderForm(); lineItem = new LineItem(); lineItem.Quantity = 1; lineItem.Code = p.Code; lineItem.DisplayName = p.DisplayName; orderForm.LineItems.Add(lineItem); //add the orderform to the cart defaultCart.OrderForms.Add(orderForm); //now save the changes to the database defaultCart.AcceptChanges(); return String.Empty; // only for test. }
Now in my ProductList View I have:
<ul> @foreach (var p in StartPageController.GetProducts()) { <li> @p.Title </li> } </ul>
and all products in cart are listed properly.
The problem is that in Commerce Manager ->Carts->MyCart-> Order Summary is shown only 1 line
Here a screenshot.
Any idea?
By creating a new orderform when you add a product to your cart, and adding it to your cart, every add to cart creates a new orderform. If that's what you mean by 1 line.
You could use something like this in your add to cart method, you have the code available in your product.
Entry entry = CatalogContext.Current.GetCatalogEntry(code); cartHelper.AddEntry(entry, quantity, false); .....
Thank you Jeroen, bu CatalogContext.Current.GetCatalogEntry(p.code) return nullMediachase.Commerce.Catalog.Objects.Entry.
In debug I see that p.code is not null and it is set to "p02_1" that is my product code.
Also CatalogContext.Current in debug is not null.
What'is wrong?
Is your "Product" is based on VariationContent? If so, you should be able to get your variation by it's code.
btw, it may be that naming your class "product" could create a problem, not sure though, but it is also the ClassTypeId for ProductContent.
Have you looked at Quicksilver?
Quicksilver starter kit is a good idea if you don't want to re-implement all shopping workflow.
I'm trying to start with Quicksilver. I rebuild the solution and try to install the database but when I run Setup\SetupDatabases.cmd to install the DB this error is shown:
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
My Sql Server work fine and MSSQL$SQLEXPRESS Services is running.
Maybe you will have to change the connectionstring to fit your version of sql(express)?
Hi,
I've created Model, Controller and View for my specific Products.
Each product has some properties like description, partecipants, etc.
In a StartPage View I list all my products.
Now I need to add a simple "Add to chart" link for each product but, as I can see here http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-Commerce/75/Orders/EPiServerCommerceSample-guideline/
AddToCart method need an Entry type in input.
How can I add my products (of type Product) into the Cart?
Thanks