Copied to clipboard

Flag this post as spam?

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


  • Tobbe 81 posts 387 karma points c-trib
    Sep 04, 2013 @ 10:27
    Tobbe
    0

    Cant add orderlines with JS - POST http://...../FormPost.aspx 500 (Internal Server Error)

    (tried to delete my first post, dont know if it worked. ignore that one..)

    Im new to tea commerce and trying to do very basic stuff. Im trying to add orderlines to an order with JS but it doesnt work. When I click my Add to cart button I get this error in chrome console "POST http://mydomain/FormPost.aspx 500 (Internal Server Error)". Ive added productName,productNumber,productPrice to "Product property aliases" in Products and they are filled out on every product.

    Here's my markup (razor):

    @foreach (var product in Model.Content.Children)
    {
        <div class="product">
            <h3>@product.Name</h3>
            <img src="@Umbraco.Media(@product.GetProperty("pic").Value).Url" alt="" />
            <a class="productAddToCart" id="@product.Id">köp</a>
            <span class="price">pris: @product.GetProperty("productPriceSwe").Value kr</span>
        </div>
    }
    

    and my JS:

    (function () {
    
    /* add product to cart */
    $(".productAddToCart").on("click", function (e) {
    
    var nodeId = $(this).attr('id');
    
    /* Add orderline is called using the Tea Commerce javascript API */
    TC.addOrUpdateOrderLine({
        productIdentifier: nodeId, quantity: 3,storeId:1,
    
        errorfn: function (e) {
            console.log(e);
        },
    
        successfn: function (e) {
            console.log(e);
        }
    });
    
    e.preventDefault();
    });
    
    })();
    

    Any ideas? im lost :(

  • Tobbe 81 posts 387 karma points c-trib
    Sep 04, 2013 @ 10:56
    Tobbe
    0

    omg.. after to many hours it just started to work?!? All i did was adding these razor lines (for testing), now everything suddenly works?! the i removed them and it still works

    Order order = TC.GetCurrentOrder(1);
    TC.AddOrUpdateOrderLine(1, "1157", 1);
    

    wtf..

  • Anders Burla 2560 posts 8256 karma points
    Sep 04, 2013 @ 21:50
    Anders Burla
    0

    Yeah that is pretty weird! Do you by chance add a store picker that wasen't there before? That can give you an error.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft