Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sean Dooley 289 posts 528 karma points
    Oct 14, 2011 @ 16:13
    Sean Dooley
    0

    Razor script add to cart issue

    Trying to implement add to cart functionality with Razor but getting the following error when clicking add to cart

    Cart Error: 
    <error><![CDATA[MESSAGE:
    Input string was not in a correct format.
    STACKTRACE:
       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
       at TeaCommerce.Presentation.TeaCommerceBase.RequestModule.invokeMethod(restExtension myExtension, Object[] paras)
    INNEREXCEPTION:
    ]]></error>

    Here is the Razor script

    @using TeaCommerce.Razor
    @using TeaCommerce.Data
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
    var products = @Model.Children.Where("!umbracoNaviHide");
    var currentCurrency = TeaCommerce.GetCurrentCurrency();
    <ul>
    @foreach(var item in products)
    {
    var variants = @item.Children;
    <li>
    <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>
    <a href="@item.Url">@item.Name</a>
    @item.ProductShortDescription

    <p>
    Price: @TeaCommerce.FormatPriceWithSpecificCulture(@item.productPriceGBP, @currentCurrency.CultureName)
    </p>
    @if(variants.Count() > 0)
    {
    <p>
    <select name="@item.Id">
    @foreach(var variant in variants)
    {
    <option value="@variant.Id">
    @variant.Name
    </option>
    }
    </select>
    </p>
    }
    else
    {
    <input name="nodeId" type="hidden" value="@item.Id" />
    }
    <p>
    Quantity: <input type="text" name="quantity" value="1" />
    <input type="submit" value="Add to cart" class="productAddToCart" />
    <img src="/css/gfx/ajax-loader.gif" title="Loading Cart" alt="Loading Cart" />
    </p>
    <fieldset>
    </form>
    </li>
    }
    </ul>
    }

    Any ideas?

  • Anders Burla 2560 posts 8256 karma points
    Oct 14, 2011 @ 16:16
    Anders Burla
    0

    Using IE9?

  • Sean Dooley 289 posts 528 karma points
    Oct 14, 2011 @ 16:16
    Sean Dooley
    0

    Using Google Chrome and Firefox, will check IE now - same with IE. In case it helps, currently running Umbraco locally

  • Anders Burla 2560 posts 8256 karma points
    Oct 14, 2011 @ 16:22
    Anders Burla
    0

    Earlier today we found a bug in the starter kit that in IE9 it didnt select the variant in the dropdown list - that bug has been fixed - was both a thing in an xslt and in the javascript of the starter kit. Could you try and not use variants and see if that helps?

  • Sean Dooley 289 posts 528 karma points
    Oct 14, 2011 @ 16:28
    Sean Dooley
    0

    I removed the variant code but still experiencing the same issue.

    Noticed in the starter kit product.xslt, product price is stored with the following line

    <xsl:variable name="price" select="teacommerce:GetProperty($variant, concat('productPrice', $currentCurrency/@ISOCode))" />

    Does this make a difference? If so, how can that be converted into Razor script?

  • Anders Burla 2560 posts 8256 karma points
    Oct 14, 2011 @ 16:36
    Anders Burla
    0

    Could it be that the nodeId input field isnt outputtet?

    else
                                                    {
                                                            <input name="nodeId" type="hidden" value="@item.Id" />
                                                    }
  • Sean Dooley 289 posts 528 karma points
    Oct 14, 2011 @ 16:42
    Sean Dooley
    0

    Found the reason - product.xslt has this code <div class="product" productId="{@id}"> - which I didn't have

    So added the following to the Razor code - <li class="product" productid="@item.Id"> - problem solved.

    Thanks for your assistance Anders - helped point me in the right direction.

Please Sign in or register to post replies

Write your reply to:

Draft