.Net API and getting the price of a product for the current currency
I've looked at the documentation page and can see that the Javascript and Razor APIs documented but have not seen the same for the .Net API.
I'm wondering which assemblies I should be referencing and what methods are available.
My current issue is that I have used the nodeFactory to get the node of a particular product within my .Net control and now I want to output the correctly formatted price according to the current currency.
I've looked through those examples and browsed the TeaCommerce.Data class for its methods but I'm unable to find anything that will give me the price of a product in the current currency.
I haven't actually added any order lines or anything, all I have is the node data for the product I am interested in.
What I'm struggling to do is figure out how to do the same using the TeaCommerce.Data library because the methods do not seem to exist or do I really have to use TeaCommerce.Library methods and all the XPATH stuff within my .Net control?
Ah, I think I need to step back a bit. How to I get the price to pass into one of those methods?
Effectively what I'm trying to do is something as simple as this:
//Get product node umbraco.NodeFactory.Node currentNode = new umbraco.NodeFactory.Node(1172); //Get price of that node String price = <some TeaCommerce method to get current price of the product node>;
.Net API and getting the price of a product for the current currency
I've looked at the documentation page and can see that the Javascript and Razor APIs documented but have not seen the same for the .Net API.
I'm wondering which assemblies I should be referencing and what methods are available.
My current issue is that I have used the nodeFactory to get the node of a particular product within my .Net control and now I want to output the correctly formatted price according to the current currency.
Thanks,
Matt
Hi Matt,
All you need is you can find in the TeaCommerce.Data.dll.
For examples on how to use the API you might want to read these blogposts:
How to make a License webshop
Tea Commerce dynamic VAT
Tea Commerce. NET API electronic product example
How to use the Tea Commerce events
Hope that will help you. There's not much you cannot accomplish with the API, and if you find something you can't, feel free to write a new post here.
/Rune
Thanks Rune,
I've looked through those examples and browsed the TeaCommerce.Data class for its methods but I'm unable to find anything that will give me the price of a product in the current currency.
I haven't actually added any order lines or anything, all I have is the node data for the product I am interested in.
Maybe I'm just being thick.
Thanks, Matt
Ah, sorry about that. In here:
TeaCommerce.Data.Tools.PriceHelper
Theres a couple of very usefull methods there for price formatting. They are all public.
If you need to do it in your xslt's theres a method for it in the Tea Commerce xslt library which is located here:
TeaCommerce.Library
The Tools namespace holds a few other very usefull classes. One of them is the XSLTHelper class which e.g. . have the InvokeXSLT functionality.
/Rune
Ah, I see how the price of a pruduct is come by using the XSLT libary from this example in the product.xslt example package.
<xsl:variable name="price" select="teacommerce:GetProperty($variant, concat('productPrice', $currentCurrency/@ISOCode))" />
What I'm struggling to do is figure out how to do the same using the TeaCommerce.Data library because the methods do not seem to exist or do I really have to use TeaCommerce.Library methods and all the XPATH stuff within my .Net control?
The XSLT library only wraps around methods in the TeaCommerce.Data classes. Prices formatted with the methods in the PriceHelper class
You can provide a culture or just use the current. They in turn wrap the methods in:
TeaCommerce.Data.Tools.FormatHelper
/Rune
Ah, I think I need to step back a bit. How to I get the price to pass into one of those methods?
Effectively what I'm trying to do is something as simple as this:
//Get product node
umbraco.NodeFactory.Node currentNode = new umbraco.NodeFactory.Node(1172);
//Get price of that node
String price = <some TeaCommerce method to get current price of the product node>;
Ok.
Thanks for your help Rune.
Got there in the end with a mishmash of libraries so not as neat as I'd hoped but here's the code if helps someone else.
Cheers,
Matt
Actually you could do it with the Razor library only
That would use the currentCurrency automatically.
Sorry about that. First thought of it now. Better late than never :)
/Rune
Cool, now that's the kind of thing I was looking for. :)
Cheers,
Matt
is working on a reply...