Now experiencing an error when selecting a product variant whereby the price should update like in the starter kit.
<error><![CDATA[MESSAGE: Exception has been thrown by the target of an invocation. STACKTRACE: at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at TeaCommerce.Presentation.TeaCommerceBase.RequestModule.invokeMethod(restExtension myExtension, Object[] paras)
INNEREXCEPTION: System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="Product">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\Users\Sean Dooley\documents\visual studio 2010\Projects\UnionMarket\UnionMarket\xslt\product.xslt:line 33 at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double ) at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\Users\Sean Dooley\documents\visual studio 2010\Projects\UnionMarket\UnionMarket\xslt\product.xslt:line 21 at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double ) at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at TeaCommerce.Data.Tools.XSLTHelper.InvokeXSLT(String xsltFile, Nullable`1 nodeId, Nullable`1 umbracoLanguageId, Dictionary`2 parameters, Boolean checkSecurity) at TeaCommerce.Base.InvokeXSLT(String xsltFile, Int32 nodeId, String umbracoLanguageId)]]></error>
Looks like its an int value again that isnt sent to the server or some html that is missing again - could you try and shorten your output down until it works again - and then maybe we could narrow the problem down into a single line of code - instead og 20 :)
Looking through the code, the issue occurs with the javascript invoking an xslt file. If I am looking to use Razor, are there any recommendations you can provide to resolve this issue?
Yes - you would have to do a little more work than else - you will have to remove the xslt invoke call and do the update of the ui in javascript instead. But I dont have examples as I think you are one of the first to go full Razor with Tea Commerce.
How can i implement this query in xslt in razor script
select="current()/descendant::Product[string(umbracoNaviHide)='0' and local-name(./parent::*)!='Product' and (teacommerce:GetStock(@id) ='' or teacommerce:GetStock(@id) >0)]"
Thanks for your question - im not that god with Razor - but hope that Sean can help me out here - else try and post it in a razor post in the forum - I know its Tea Commerce data - but think the questions is more of technical details of Razor than about Tea Commerce. But please Sean - help me :)
thanks for the reply. the main issue is how to call this teacomerce stock filter methods right in query, on order to calculate items which are in stock.
Could you change TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) == null to TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) != null so the code reads as follows
dynamic nodes = item.Descendants("Product").Where("TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) != null or TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) >= 0";
Error 3 Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
xslt to razor assistance
How could the following script be written in Razor?
Tricky :)
OK, this is just a guess and probably won't work, but I'm thinking something like this:
Thanks for your response Dan. Have implemented the following work around to fit my needs
Now experiencing an error when selecting a product variant whereby the price should update like in the starter kit.
<error><![CDATA[MESSAGE:
Exception has been thrown by the target of an invocation.
STACKTRACE:
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at TeaCommerce.Presentation.TeaCommerceBase.RequestModule.invokeMethod(restExtension myExtension, Object[] paras)
INNEREXCEPTION:
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="Product">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\Users\Sean Dooley\documents\visual studio 2010\Projects\UnionMarket\UnionMarket\xslt\product.xslt:line 33
at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double )
at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\Users\Sean Dooley\documents\visual studio 2010\Projects\UnionMarket\UnionMarket\xslt\product.xslt:line 21
at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double )
at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at TeaCommerce.Data.Tools.XSLTHelper.InvokeXSLT(String xsltFile, Nullable`1 nodeId, Nullable`1 umbracoLanguageId, Dictionary`2 parameters, Boolean checkSecurity)
at TeaCommerce.Base.InvokeXSLT(String xsltFile, Int32 nodeId, String umbracoLanguageId)]]></error>
Below is the Razor script
@using TeaCommerce.Razor
@using TeaCommerce.Data
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var products = @Model.Children.Where("!umbracoNaviHide");
var currentCurrency = TeaCommerce.GetCurrentCurrency();
var priceProperty = @Library.Concatenate("productPrice", @currentCurrency.ISOCode);
}
<ul>
@foreach(var item in products)
{
var variants = @item.Children;
var variant = variants.Count () > 0 ? variants[0] : @item;
decimal price = Decimal.Parse(@variant.GetProperty(@priceProperty).Value);
var priceCss = String.Format(" class=\"currency{0}\"", @variant.Id);
<li class="product" productid="@item.Id">
<form action="/tcbase/teacommerce/SubmitForm.aspx" method="post" name="testformName" id="testformID">
<input name="ReturnUrl" type="hidden" value="" />
<input name="AddOrderLine" type="hidden" value="nodeId,quantity" />
<fieldset>
@RenderPage("RenderMedia.cshtml", @item.ProductImage, "productImage")
<div class="description">
<a href="@item.Url">@item.Name</a>
@item.ProductShortDescription
<p class="productPrice">
Price: <[email protected](priceCss)>@TeaCommerce.FormatPriceWithSpecificCulture(@price, @currentCurrency.CultureName)</span>
</p>
@if(variants.Count() > 0) {
<p class="productVariants">
<select name="nodeId">
@foreach(var v in variants) {
var selected = @variant.Id == @v.Id ? "selected" : "";
<option value="@v.Id" @Html.Raw(selected)>@v.Name</option>
}
</select>
</p>
} else {
<input name="nodeId" type="hidden" value="@item.Id" />
}
@if( (@TeaCommerce.GetStock(@item.Id) > 0) || (@TeaCommerce.GetStock(@item.Id) == null) ) {
<p class="productAddToCartWrap">
Quantity: <input type="text" name="quantity" value="1" />
<input type="submit" value="Add to cart" class="productAddToCart" />
</p>
}
</div>
<fieldset>
</form>
</li>
}
</ul>
Looks like its an int value again that isnt sent to the server or some html that is missing again - could you try and shorten your output down until it works again - and then maybe we could narrow the problem down into a single line of code - instead og 20 :)
Looking through the code, the issue occurs with the javascript invoking an xslt file. If I am looking to use Razor, are there any recommendations you can provide to resolve this issue?
Yes - you would have to do a little more work than else - you will have to remove the xslt invoke call and do the update of the ui in javascript instead. But I dont have examples as I think you are one of the first to go full Razor with Tea Commerce.
Good Evening
How can i implement this query in xslt in razor script
select="current()/descendant::Product[string(umbracoNaviHide)='0' and local-name(./parent::*)!='Product' and (teacommerce:GetStock(@id) ='' or teacommerce:GetStock(@id) >0)]"
Tried like this but no use
dynamic nodes = item.Descendants("Product").Where("Visible").Where("Parent.NodeTypeAlias != \"Product\"");
IEnumerable query = nodes.Where(node => TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) == null or TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) >= 0)"); //
Hi Kouzzmitch
Thanks for your question - im not that god with Razor - but hope that Sean can help me out here - else try and post it in a razor post in the forum - I know its Tea Commerce data - but think the questions is more of technical details of Razor than about Tea Commerce. But please Sean - help me :)
Hi Kouzzmitch
Apologies for not replying sooner as I have busy with work commitments/deadlines. Couple of questions
What site structure have you got?
Does the below line return anything?
dynamic nodes = item.Descendants("Product").Where("Visible").Where("Parent.NodeTypeAlias != \"Product\"");
Hi Sean,
thanks for the reply. the main issue is how to call this teacomerce stock filter methods right in query, on order to calculate items which are in stock.
this query does return items
dynamic nodes = item.Descendants("Product").Where("Visible").Where("Parent.NodeTypeAlias != \"Product\"");
This don't works and I think I'm not doing it right
dynamic nodes = item.Descendants("Product").Where("TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) == null or TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) >= 0");
Could you change TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) == null to TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) != null so the code reads as follows
dynamic nodes = item.Descendants("Product").Where("TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) != null or TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) >= 0";
Does that make any difference?
Hi Kouzzmitch
Have you had any luck resolving the problem?
Sorry for not replying for a long and sorry from initially not describing the error completely
Im sure it's not an Teacommerce problem at all but i hoped that you know the answer
The matter is that when I create script
@foreach (dynamic variant in product.Descendants("Product").Where("TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) == null or TeaCommerce.Razor.TeaCommerce.GetStock(node.Id) >= 0"))
i get an error
No applicable method 'GetStock' exists in type 'String'
Hi Kouzzmitch
Try something like the following
foreach (dynamic variant in product.ChildrenAsList.Where(x => TeaCommerce.GetStock(x.Id) != null || TeaCommerce.GetStock(x.Id) >= 0))
Let us know how you get on
Or the following might work better
foreach (dynamic variant in currentNode.Descendants("Product").Items.Where(x => TeaCommerce.GetStock(x.Id) != null || TeaCommerce.GetStock(x.Id) >= 0))
Hope this helps
It keeps telling an error
dynamic nodes = item.Descendants("Product").Items.Where(x => TeaCommerce.Razor.TeaCommerce.GetStock(x.Id) == null || TeaCommerce.Razor.TeaCommerce.GetStock(x.Id) >= 0));
Error 3 Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
I was casting currentNode as DynamicNode.
Could you cast item as a umbraco.MacroEngines.DynamicNode? If not, uQuery (uComponents) GetChildNodes() might be what you are looking for.
Yes it helped but the resulting object type is Enumerator but i'll find How to count items in it
is working on a reply...