I'm trying to make a Razor order list (finalized) for all orders connected to a member. I have a working xslt version that uses GetFinalizedOrdersXmlForMember to get the order collection but I can't find the Razor equivalent. Anyone?
That is because there are none. We have not been able to find an optimized way of getting all orders in razor. it just dosn't fit into the way the rest of Tea Commerce works which is highly cached. GetFinalizedOrdersXmlForMember is the only way to do it, sorry.
OK. What if I use a .Net (C#) user control? Any fancy LINQ (or SP/Sql) that can read data directly from the database? I need to get the members orders (and products) to check if the member has access to the current page.
You have - TeaCommerce.Library.GetFinalizedOrderXmlForMember( int memberId ) - returning an XPathNodeIterator
Or - TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements( "./order [@memberId=1]") - returns Xlements for all orders belonging to member with id 1.
Now that I have the list of products from the orders, I just need to access a custom product property (subscriptionPeriod) in order to do my final access validation. Any tips?
If you have already set up Tea Commerce to add the product property to the order line, under the Tea Commerce general settings, the information is ready for you on the order. Just use <xsl:copy-of select="$order" /> to see the xml and find out what to do.
If not start with adding the property in general setting "Order line property aliases".
If the information is NOT supposed to be available on the orderline for some reason (usually because it need to be kept a secret) then you must get it from the product node. Each order line contains the nodeId of the product they came from. Just use that to GetXmlNodeById and then you have access to all information about the product. Just remember that this approach is vulnerable to products being deleted or changed later on.
hmm. That's a lot of if's. Maybe I should have done a switch case instead!? ;-)
It makes great sense to copy the new property to the order line as this property should be "locked" at order time. Now that the new property is available in the order XML I have all I need.
Razor version of member_orders.xslt
I'm trying to make a Razor order list (finalized) for all orders connected to a member. I have a working xslt version that uses GetFinalizedOrdersXmlForMember to get the order collection but I can't find the Razor equivalent. Anyone?
:o)
Jon Ivar
Hi Jon,
That is because there are none. We have not been able to find an optimized way of getting all orders in razor. it just dosn't fit into the way the rest of Tea Commerce works which is highly cached. GetFinalizedOrdersXmlForMember is the only way to do it, sorry.
/Rune
Thanks Rune
OK. What if I use a .Net (C#) user control? Any fancy LINQ (or SP/Sql) that can read data directly from the database? I need to get the members orders (and products) to check if the member has access to the current page.
:o)
Jon Ivar
You can allways load the xml and traverse that in C#. It's pretty easy when you get the hang of it. Not perfect, but it will work and be fast enough.
/Rune
OK. If you could show me just how I load the XML in the UC, I can take it from there.
:o)
Jon Ivar
Hi Jon
There are multiple ways to do this :)
You have - TeaCommerce.Library.GetFinalizedOrderXmlForMember( int memberId ) - returning an XPathNodeIterator
Or - TeaCommerce.Data.Order.OrdersXmlCache.Root.XPathSelectElements( "./order [@memberId=1]") - returns Xlements for all orders belonging to member with id 1.
Kind regards
Anders
Thanks.
Now that I have the list of products from the orders, I just need to access a custom product property (subscriptionPeriod) in order to do my final access validation. Any tips?
:o)
Jon Ivar
Hi Jon
Have you copied the product property to the order line or is it only present at the umbraco product node?
Kind regards
Anders
If you have already set up Tea Commerce to add the product property to the order line, under the Tea Commerce general settings, the information is ready for you on the order. Just use <xsl:copy-of select="$order" /> to see the xml and find out what to do.
If not start with adding the property in general setting "Order line property aliases".
If the information is NOT supposed to be available on the orderline for some reason (usually because it need to be kept a secret) then you must get it from the product node. Each order line contains the nodeId of the product they came from. Just use that to GetXmlNodeById and then you have access to all information about the product. Just remember that this approach is vulnerable to products being deleted or changed later on.
hmm. That's a lot of if's. Maybe I should have done a switch case instead!? ;-)
/Rune
Thanks Anders and Rune
It makes great sense to copy the new property to the order line as this property should be "locked" at order time. Now that the new property is available in the order XML I have all I need.
Thanks again for great support.
:o)
Jon Ivar
is working on a reply...