Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jon Ivar Nielsen 24 posts 96 karma points
    Apr 01, 2012 @ 01:51
    Jon Ivar Nielsen
    0

    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

  • Rune Grønkjær 1372 posts 3103 karma points
    Apr 01, 2012 @ 10:51
    Rune Grønkjær
    0

    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

  • Jon Ivar Nielsen 24 posts 96 karma points
    Apr 01, 2012 @ 11:09
    Jon Ivar Nielsen
    0

    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

  • Rune Grønkjær 1372 posts 3103 karma points
    Apr 01, 2012 @ 12:47
    Rune Grønkjær
    0

    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

  • Jon Ivar Nielsen 24 posts 96 karma points
    Apr 01, 2012 @ 15:37
    Jon Ivar Nielsen
    0

    OK. If you could show me just how I load the XML in the UC, I can take it from there.

    :o)
    Jon Ivar

  • Anders Burla 2560 posts 8256 karma points
    Apr 02, 2012 @ 09:15
    Anders Burla
    0

    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

  • Jon Ivar Nielsen 24 posts 96 karma points
    Apr 03, 2012 @ 02:33
    Jon Ivar Nielsen
    0

    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

  • Anders Burla 2560 posts 8256 karma points
    Apr 03, 2012 @ 09:26
    Anders Burla
    0

    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

  • Rune Grønkjær 1372 posts 3103 karma points
    Apr 03, 2012 @ 11:05
    Rune Grønkjær
    0

    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

  • Jon Ivar Nielsen 24 posts 96 karma points
    Apr 03, 2012 @ 11:22
    Jon Ivar Nielsen
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft