Tea Commerce: Get all orders in C# where custom property is matched
Hi,
I've built a promo code facility into Tea Commerce 2. One of the requirements is to allow customers to only use each promo code once.
The promo code only works with registered members, and the value of the promo code is stored as a text string on the order object, as a property called 'promo'.
I have some logic which finds all orders by the current member when they try to apply a promo code to their order. It looks like this:
This works - I can do 'orders.Count()' to tell whether the member has placed an order previously, but I also want to tell if they've used the promo code before. I've tried the following but it doesn't work:
You can just use TC.GetAllFinalizedOrdersForCustomer() to get all orders for the member. Then normal linq will do the rest. It will return a list of order objects instead of a XElement.
Tea Commerce: Get all orders in C# where custom property is matched
Hi,
I've built a promo code facility into Tea Commerce 2. One of the requirements is to allow customers to only use each promo code once.
The promo code only works with registered members, and the value of the promo code is stored as a text string on the order object, as a property called 'promo'.
I have some logic which finds all orders by the current member when they try to apply a promo code to their order. It looks like this:
This works - I can do 'orders.Count()' to tell whether the member has placed an order previously, but I also want to tell if they've used the promo code before. I've tried the following but it doesn't work:
Can anyone suggest how to get only orders which match the member and the promo code?
Many thanks!
Hi Dan,
You can just use TC.GetAllFinalizedOrdersForCustomer() to get all orders for the member. Then normal linq will do the rest. It will return a list of order objects instead of a XElement.
/Rune
And if you want to use xml - then you should know that the xml structure for order properties is order/properties/promo
Kind regards
Anders
Great, thanks chaps. The final solution, which counts how many times a member has used the promo code, was like this:
is working on a reply...