Tea Commerce: How to tell if member has ordered before
Hi,
I think I'm right in saying that TeaCommerce will save an order to a member if the member is logged-in at the time of placing an order? If so, how is this stored and how would I tell (for example in the logic for calculating a discount on an order) whether the member has placed an order before?
So I'd loop through all orders and return those with a particular CustomerId or would there be a more efficient way? Is there something that does 'Get orders where property X = 1'?
In theory this sounds great but in practice I'm already wondering how to actually do it.
This has nothing to do with showing properties. It is about selecting finalized orders. Maybe you need to create a new forum topic or am I getting your question all wrong?
Dan you can also use TC.GetAllFinalizedOrdersForCustomer( storeId, customerId )
Use the TC.GetAllFinalizedOrdersForCustomer( storeId, customerId ) which returns a list of Order objects. Then you have the normal API to work with instead of xml.
If you get the error loading macroengine script there is happening an error in your code. Try and debug using Visual Studio to see what is going wrong. Maybe the xml structure/elements isnt just the right way you select them.
Tea Commerce: How to tell if member has ordered before
Hi,
I think I'm right in saying that TeaCommerce will save an order to a member if the member is logged-in at the time of placing an order? If so, how is this stored and how would I tell (for example in the logic for calculating a discount on an order) whether the member has placed an order before?
Thanks, and sorry for all the questions lately!
All orders have a CustomerId property which contains the member id if a member was logged in while creating the order. Simple as that :)
/Rune
So I'd loop through all orders and return those with a particular CustomerId or would there be a more efficient way? Is there something that does 'Get orders where property X = 1'?
In theory this sounds great but in practice I'm already wondering how to actually do it.
Thanks
No. You just get all finalized orders as xml and then select them in the XElement you get back.
You can do something like this:
And then loop through them and do whatever. Or just select the ones for a specific member.
/Rune
If your not in a web context then you can use the OrderService.Instance.GetAllFinalizedAsXml( storeId )
Kind regards
Anders
Hi Rune, you can make an example of foreach where you show properties as a first name, city, phone, etc.?
Thanks!
Hi Pavel
This has nothing to do with showing properties. It is about selecting finalized orders. Maybe you need to create a new forum topic or am I getting your question all wrong?
Dan you can also use TC.GetAllFinalizedOrdersForCustomer( storeId, customerId )
Kind regards
Anders
Hi Anders,
yes but each order has properties? How will you show them to the user ? from here:
I tried:
but getting error (Error loading MacroEngine script)
this is my question, which I think belongs to the topic where Rune describing the method.
Thank you
Use the TC.GetAllFinalizedOrdersForCustomer( storeId, customerId ) which returns a list of Order objects. Then you have the normal API to work with instead of xml.
If you get the error loading macroengine script there is happening an error in your code. Try and debug using Visual Studio to see what is going wrong. Maybe the xml structure/elements isnt just the right way you select them.
Kind regards
Anders
is working on a reply...