We have 1.4.3.2 installed and have the requirement to create an order completely via .NET API.
We receive an XML file from an 3rd party which contains enough data to be able to create an order within TeaCommerce.
From the above post, it appeared that using TeaCommerce.Base.AddOrderLine(nodeID, quantity) should be sufficient to trigger the creation of a new order. Is this correct ?
If so, how do you then add orderline properties.
So far I have
foreach (XmlNode line in orderLines) { Node prodNode = Node.GetNodeByXpath("//Product[string(productNumber) = '" + line.SelectSingleNode("product_code").InnerText + "']"); // get node by using the product code in the 3rd party XML file TeaCommerce.Base.AddOrderLine(prodNode.Id, 2); //How do I add properties to the orderline here }
And then how do I get the newly created order and add properties to the order ?
The method TeaCommerce.Base.AddOrderLine(nodeID, quantity) will create an order, cache it and add it to the users session. From then on you can get the order from the session by calling:
TeaCommerce.Data.Order order = TeaCommerce.Razor.TeaCommerce.GetOrder();
Then you have the order and can do anything with it.
If you need to add multiple orders that will also be the way to do it, although not very practical.
In Tea Commerce 2.0 this process will be much simpler and more logical, but that won't help you much now :)
So far so good. The nodeId parameter that is sent to the AddOrderLine method should be the umbraco node id of the product you want to add. Tea Commerce will then find the node and copy information from it, to the order line. The following will be automatically added to the order line:
1. The properties listen in the Tea Commerce general settings "Order line property aliases" field. 2. The price of the product is taken from the appropriate field which is set on the currencies in the Tea Commerce section. Each currency have a property alias of the product property with the price value. 3. Note that all properties and prices can use the Tea Commerce master product concept to fetch information. Read more about this here: http://rune.gronkjaer.dk/en-US/2011/09/08/tea-commerce-master-product/
As for the IsOrder, TransactionOrderName etc. these values are automatically set by Tea Commerce when the order is finalized. You can call Finalize on the order yourself or use the Tea Commerce JavaScript method goToPayment to send the customers to the payment gateway selected by the payment method on the order.
If in doubt try installing the starter kit at check out the setup there.
Thanks for your ongoing assistance, however today things have changed...
I no longer need to create an order using .NET API (management decision) so your help has been useful in discovering more about your package, but will no longer be required.
Sorry to have wasted your time, but hope the information will help others who stumble across it.
Create Order via .NET API
Hi there
I found this - http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/21953-Creating-an-order-and-adding-product-lines-Net-API-Getting-started but being an older post am not sure it applies to the current version.
We have 1.4.3.2 installed and have the requirement to create an order completely via .NET API.
We receive an XML file from an 3rd party which contains enough data to be able to create an order within TeaCommerce.
From the above post, it appeared that using TeaCommerce.Base.AddOrderLine(nodeID, quantity) should be sufficient to trigger the creation of a new order. Is this correct ?
If so, how do you then add orderline properties.
So far I have
And then how do I get the newly created order and add properties to the order ?
I hope the above makes sense.
Thanks, Nigel
Hi Nigel,
The method TeaCommerce.Base.AddOrderLine(nodeID, quantity) will create an order, cache it and add it to the users session. From then on you can get the order from the session by calling:
TeaCommerce.Data.Order order = TeaCommerce.Razor.TeaCommerce.GetOrder();
Then you have the order and can do anything with it.
If you need to add multiple orders that will also be the way to do it, although not very practical.
In Tea Commerce 2.0 this process will be much simpler and more logical, but that won't help you much now :)
/Rune
Hi Rune
Thanks for the info - I am now getting an order created via the API.
I note the price doesn't get added to the orderLine using TeaCommerce.Base.AddOrderLine(prodNode.Id,2);
Also - I cannot figure out how to set the likes of the following:
I am setting some order values with, TeaCommerce.Base.SetShippingMethod(1), etc but cannot figure the above out.
As yet I have not attempted to calculate the order total either - is there a mothod that automatically does this ?
Cheers, Nigel
Hi Nigel,
So far so good. The nodeId parameter that is sent to the AddOrderLine method should be the umbraco node id of the product you want to add. Tea Commerce will then find the node and copy information from it, to the order line. The following will be automatically added to the order line:
1. The properties listen in the Tea Commerce general settings "Order line property aliases" field.
2. The price of the product is taken from the appropriate field which is set on the currencies in the Tea Commerce section. Each currency have a property alias of the product property with the price value.
3. Note that all properties and prices can use the Tea Commerce master product concept to fetch information. Read more about this here: http://rune.gronkjaer.dk/en-US/2011/09/08/tea-commerce-master-product/
As for the IsOrder, TransactionOrderName etc. these values are automatically set by Tea Commerce when the order is finalized. You can call Finalize on the order yourself or use the Tea Commerce JavaScript method goToPayment to send the customers to the payment gateway selected by the payment method on the order.
If in doubt try installing the starter kit at check out the setup there.
/Rune
Hi Rune
Thanks for your ongoing assistance, however today things have changed...
I no longer need to create an order using .NET API (management decision) so your help has been useful in discovering more about your package, but will no longer be required.
Sorry to have wasted your time, but hope the information will help others who stumble across it.
Cheers
Nigel
No problems. And yes, lets hope someone else can use the information then. :)
Feel free to write again if you run into other questions.
/Rune
is working on a reply...