Very generalised - I want to be able to add user comments to an order line when adding it to the basket.
I haven't really got started on the basket code yet, but I understand that Tea Commerce uses an Umbraco node as a product (or properties from it). I can see how to get / add the Product ID, but how do I add the free text comments, entered by the customer, onto the order line as well?
In fact I have to do this with a large number of customer chosen options, but once I can do one item I should be able to do them all!?
Umm - I can't edit my original post, so I shall post a follow-up:
I should add that I have a C# / .Net UserControl which deals with presenting the user options. I believe there is a .Net API? (I am investigating at the moment...)
Sorry - I probably haven't explained my situation very well!!
I have a .Net UserControl which is where a customer will "prepare" what they want to order (enter text, choose font, colour and other stuff). The UserControl has a "Buy" button which needs to add the product to the basket ... but I also need to save the customer entered information.
There is not "need" to do it via JavaScript as the UserControl does a "call back" anyway - so, I guess I could use either the JavaScript or .Net API ... preference would probably be the .Net API.
The key question is how do I save the customer entered info to the order line?
The .NET API will be quite enough to do what you are aiming for.
You will be posting your information to the server with standard ASP.NET. When on the server you will then get the order (Cart/basket) using the Tea Commerce Razor API like this TeaCommerce.Razor.TeaCommerce.GetOrder()
Now you have the order and you will have to either create a new orderline, or update an existing one:
To update an existing property, just get it from the orderLine object and then update it.
NOTE: Always remember to save the order after changing the order, orderlines or anything else on the order. Otherwise your data will not be persisted to the database.
Yes, you should still enter the "Order line property aliases" that you wish Tea Commerce to automatically add to the order line. Product name, number and so on.
Yes, TeaCommerce.Razor.TeaCommerce.GetOrder() will create an order if none exists. It will be placed in the users session and from then on the same order will be returned.
Sorry about the almost pseudo code above. I'll try and expand.
Get orderline can be made lige this:
privatestaticOrderLine GetOrderLine( Order order, int? nodeId, long? orderLineId, bool isUnique ) {
if ( !isUnique )
return order.OrderLines.SingleOrDefault( o => o.NodeId == nodeId && !o.IsUnique );
elsereturn order.OrderLines.SingleOrDefault( o => o.Id == orderLineId && o.IsUnique );
}
The order line id will have to come from your own code. If you want to create a NEW orderline, orderLineId will be null. If you want to update an existing order line you can either find it by the products "nodeId" or the "orderLineId". The last one is mostly needed if you are creating unique orderlines. Unique orderlines are explained in this javascript documentation, but is escentially the same in .NET.
Customer comments on order item
Very generalised - I want to be able to add user comments to an order line when adding it to the basket.
I haven't really got started on the basket code yet, but I understand that Tea Commerce uses an Umbraco node as a product (or properties from it). I can see how to get / add the Product ID, but how do I add the free text comments, entered by the customer, onto the order line as well?
In fact I have to do this with a large number of customer chosen options, but once I can do one item I should be able to do them all!?
Umm - I can't edit my original post, so I shall post a follow-up:
I should add that I have a C# / .Net UserControl which deals with presenting the user options. I believe there is a .Net API? (I am investigating at the moment...)
Hi Gordon,
Are you using the .NET API to add/edit the orderlines or do you use the javascript API?
/Rune
Sorry - I probably haven't explained my situation very well!!
I have a .Net UserControl which is where a customer will "prepare" what they want to order (enter text, choose font, colour and other stuff). The UserControl has a "Buy" button which needs to add the product to the basket ... but I also need to save the customer entered information.
There is not "need" to do it via JavaScript as the UserControl does a "call back" anyway - so, I guess I could use either the JavaScript or .Net API ... preference would probably be the .Net API.
The key question is how do I save the customer entered info to the order line?
Hi Gordon,
The .NET API will be quite enough to do what you are aiming for.
You will be posting your information to the server with standard ASP.NET. When on the server you will then get the order (Cart/basket) using the Tea Commerce Razor API like this TeaCommerce.Razor.TeaCommerce.GetOrder()
Now you have the order and you will have to either create a new orderline, or update an existing one:
That's the basic stuff. Now you will add the userspecific information/properties to the orderline. you can add as many as you want like this:
That should do the trick.
To update an existing property, just get it from the orderLine object and then update it.
NOTE: Always remember to save the order after changing the order, orderlines or anything else on the order. Otherwise your data will not be persisted to the database.
/Rune
Thanks Rune ... that seems easy enough (adding extra properties anyway).
I assume I still need to enter some property names in the "Order line property aliases" box in "General Settings"?
Does "TeaCommerce.Razor.TeaCommerce.GetOrder()" create an order if one does not yet exist?
Yes, you should still enter the "Order line property aliases" that you wish Tea Commerce to automatically add to the order line. Product name, number and so on.
Yes, TeaCommerce.Razor.TeaCommerce.GetOrder() will create an order if none exists. It will be placed in the users session and from then on the same order will be returned.
/Rune
I was rather hoping to find documentation for the .Net API ... but I can't? How do I know what is available?
I don't fully understand the code you have given above - where does orderLineId come from? Where does GetOrderLine come from?
Maybe it's now a bit too late to be working on this!!?
Hi Gordon,
All documentation can be found here: http://www.teacommerce.dk/en/documentation.aspx
Sorry about the almost pseudo code above. I'll try and expand.
Get orderline can be made lige this:
The order line id will have to come from your own code. If you want to create a NEW orderline, orderLineId will be null. If you want to update an existing order line you can either find it by the products "nodeId" or the "orderLineId". The last one is mostly needed if you are creating unique orderlines. Unique orderlines are explained in this javascript documentation, but is escentially the same in .NET.
Feel free to ask if you need any more info.
/Rune
Phew, getting somewhere now! I now have items (order lines) adding to the order and I am displaying the total (items & cost).
Next job ... full details basket page :-)
That's fantastic. Could you mark the correct answer, so others can easily find it later on.
I hope your basket will come along nicely. You might want to use the razor API for that part. It should have all the functionality you need.
You could also take a look at our starter kit for Tea Commerce and steal the html and css from that. Might save you some time.
/Rune
I am looking for the answer as well ... but could you tell me how I access properties on an order line that I have added using:
The is a fixed set of properties being added, I need to read / use them on the order summary in Umbraco and probably during the checkout process.
Doh - got it!!
Getting the property value in XSLT is easy (as above) ... but how do I do the same in C# ?
Something like: orderLine.Properties.Select(p => p.Alias == "propAlias")
/Rune
I tried this:
but it is trying to return a Boolean value rather than a string (the value of the property) ... I've tried a few things but can't get it to work :-(
This is return a value added with "orderLine.AddProperty"
Aha! This works:
That is great, and that will ofcause work on the orders own properties as well.
/Rune
is working on a reply...