I have setup my site to allow members to login to my site using the members functionality in umbraco and the .net member wizard. I am now trying to show all the finialised orders for the logged in member i have the following code but getting an error "CS0103: The name 'GetFinalizedOrdersXmlForMember' does not exist in the current context" am i calling the wrong method or have i missed something / wrong syntax
@using TeaCommerce.Razor @using TeaCommerce.Data @using umbraco.cms.businesslogic.member @{ var member = Member.GetCurrentMember(); foreach (Order order in GetFinalizedOrdersXmlForMember(@member.Id)) { } }
You are missing TeaCommerce - as the GetFinalizedOrdersXmlForMember is in the Library class. So it should be:
@using TeaCommerce
XPathNodeIterator itr = Library.GetFinalizedOrdersXmlForMember(memberId) - this gives you a xpath node iterator and not an order object. So you will have to use xpath C# code to get the data.
You can also use the TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements( "./order [@memberId=" + memberId + "]" ) to get it as XElements and use that.
Thanks I am using TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements("./order [@memberId=" + member.Id + "]") to get the order details which i am axtracting fine but I want to get the order Id so I can then use TeaCommerce.Data.Order.GetOrder(orderId) when a user selects an order for more details I am using string id = order.Attribute("id").Value; to extract the id which gives me an int with a 3 digit number id but the TeaCommerce.Data.Order.GetOrder(orderId) is asking for a type long how can I get this
Is the 3 digit number the correct Id to use to get the order details I keep getting Object reference not set to an instance of an object with the following code and all I can think of is that its not finding the order or have I missed something
var orders = TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements("./order [@memberId=" + member.Id + "]");
foreach (var order in orders)
{
string id = order.Attribute("id").Value;
string name = order.Attribute("name").Value;
HtmlAnchor htmlanchor = new HtmlAnchor();
htmlanchor.HRef = "~/member-area?order=" + id;
htmlanchor.InnerText = name;
this.Controls.Add(htmlanchor);
}
string selectedOrder = Request.QueryString["order"];
if (selectedOrder != "")
{
var sOrder = TeaCommerce.Data.Order.GetOrder(long.Parse(selectedOrder));
selectedOrderPanel.Visible = true;
selectedOrderTitle.Text = sOrder.Name;
totalPrice.Text = sOrder.TotalPriceFormatted;
}
Try and make a test - find a order id in the DB and try call TeaCommerce.Data.Order.GetOrder( yourDBOrderId ) and see if that works.If it does - then something else must be wrong.
Thanks realised the list of orders I has included all the orders I have made under that user even tho some had been deleted from the database as I had reached my 20 limit so was looking for an order that didn't exist in the database I have it all working now using but it lists thm out from oldest to newest is there a way I can list them out newest to oldest
TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements("./order [@memberId=" +member.Id +]");
foreach(var order in orders)
{
...
}
show Members Orders
I have setup my site to allow members to login to my site using the members functionality in umbraco and the .net member wizard. I am now trying to show all the finialised orders for the logged in member i have the following code but getting an error "CS0103: The name 'GetFinalizedOrdersXmlForMember' does not exist in the current context" am i calling the wrong method or have i missed something / wrong syntax
Hi Phil
You are missing TeaCommerce - as the GetFinalizedOrdersXmlForMember is in the Library class. So it should be:
@using TeaCommerce
XPathNodeIterator itr = Library.GetFinalizedOrdersXmlForMember(memberId) - this gives you a xpath node iterator and not an order object. So you will have to use xpath C# code to get the data.
You can also use the TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements( "./order [@memberId=" + memberId + "]" ) to get it as XElements and use that.
Hope this helps
Kind regards
Anders
Thanks I am using TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements("./order [@memberId=" + member.Id + "]") to get the order details which i am axtracting fine but I want to get the order Id so I can then use TeaCommerce.Data.Order.GetOrder(orderId) when a user selects an order for more details I am using string id = order.Attribute("id").Value; to extract the id which gives me an int with a 3 digit number id but the TeaCommerce.Data.Order.GetOrder(orderId) is asking for a type long how can I get this
When you have the id as a string you can just use the long.Parse method to parse it to a long value.
Kind regards
Anders
Is the 3 digit number the correct Id to use to get the order details I keep getting Object reference not set to an instance of an object with the following code and all I can think of is that its not finding the order or have I missed something
Hi Phil
Try and make a test - find a order id in the DB and try call TeaCommerce.Data.Order.GetOrder( yourDBOrderId ) and see if that works.If it does - then something else must be wrong.
Kind regards
Anders
Thanks realised the list of orders I has included all the orders I have made under that user even tho some had been deleted from the database as I had reached my 20 limit so was looking for an order that didn't exist in the database I have it all working now using but it lists thm out from oldest to newest is there a way I can list them out newest to oldest
Hi phil
This post should help you: http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/81e3183b-1bee-4495-993d-549ded91e59d/
Kind regards
Anders
Anyone got an XSLT example of this?
Many thanks
<xsl:variable name="test" select="teacommerce:GetFinalizedOrdersXmlForMember(umbraco.library:GetCurrentMember()/@id)/order" />
That should give your all orders for the logged in member
Kind regards
Anders
is working on a reply...