Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Dmitrij Jazel 86 posts 179 karma points
    Jan 26, 2013 @ 21:01
    Dmitrij Jazel
    0

    Product add to cart question

    Hi guys,

    Sorry for yet another noobie question...

    But I would really appreciate your help on this one here...

    I am playing arround with uCommerce razor store, and I am trying to build up template by myself here... now I am in the cart, and I am trying to find a way how to change ammount of products currently in the cart (basically change ammount of order line)...

    Razor store makes some kind of Ajax call, I was woundering if I could do the same? Could someone please explain what is actually happening (or in this case must happen) in order to change order line ammount?

     

    Much appreciated for help! :-)

     

    //Dmitrij

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jan 27, 2013 @ 09:47
    Nickolaj Lundgreen
    100

    Hi Dmitrij

     

    What you want to do is call a webservice with the orderline Id of the orderline you want to change, and the new quantity.

     

    The webservice will then use this method:

    UCommerce.Api.TransactionLibrary.UpdateLineItem();

    To change the quantity of that line.

    I hope this helps.

  • Dmitrij Jazel 86 posts 179 karma points
    Jan 27, 2013 @ 14:17
    Dmitrij Jazel
    0

    Hej Nicolaj,

    That's exactly what I needed :-)

    Thanks again ;-)

    //Dmitrij

  • Dmitrij Jazel 86 posts 179 karma points
    Jan 29, 2013 @ 20:18
    Dmitrij Jazel
    0

    Hej Nicolaj,

    Sorry for raising the issue again, but now I have another question,

    I have an iteration script that runs through all orderlines and shows products ammount in a input field...

    But I have still the same issue,

     

    @foreach (var lineItem in basket.OrderLines)
    {
        var product = @CatalogLibrary.GetProduct(lineItem.Sku);
        var itemPrice = new Money(lineItem.Price, currency);
        var itemTax = new Money(lineItem.VAT, currency);
        var lineTotal = new Money(lineItem.Total.Value, currency);
    
        <tr class="order-line">
            <td><a href="@CatalogLibrary.GetNiceUrlForProduct(product)">@lineItem.ProductName</a> </td>
            <td class="money">
                @if (lineItem.UnitDiscount.HasValue && lineItem.UnitDiscount > 0)
                {
                    var nowPrice = new Money((lineItem.Price - lineItem.UnitDiscount.Value), currency);
    
                    <span style="text-decoration: line-through">
                        @itemPrice
                    </span>
                    @nowPrice
                }
                else
                {
                    @itemPrice
                }
            </td>
            <td class="money">
                @itemTax
            </td>
            <td>
                <input type="text" id="[email protected]" name="[email protected]" data-orderlineid="@lineItem.OrderLineId" value="@lineItem.Quantity" class="qty" />                            
            </td>
            <td class="money line-total">
                @lineTotal
            </td>
            <td>
                <button type="submit" class="line-remove" name="basket-remove-item" value="@lineItem.OrderLineId">×</button></td>
        </tr>
    }

     

    So my question again is what do I need to do in order to set new product ammount in the textbox after I make post, or change the value and simply hit enter?

    Any ideas how to do that?

    This is from uCommerce standard razor shop by the way...

    Getting a bit confused here, cause can't actually use your code snippet in this layout...

     

    //Dmitrij

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jan 29, 2013 @ 21:00
    Nickolaj Lundgreen
    0

    I haven't taken the time to take a closer look at the uCommerce standard razor shop yet, so i dont know if there is a built in way to update the cart content.

     

    However:

    I would hookup a jquery event to the value in the textbox (quantity), so when it changes it calls the webservice who then updates the quantity based on the new value, and get the orderlineid from data-orderlineid attribute.

     

    The last part is reloading the cart content, or the old fashion way - reload the page.

    Do you need some code snippets (and for what part of it)?

     

     

  • Dmitrij Jazel 86 posts 179 karma points
    Jan 30, 2013 @ 13:42
    Dmitrij Jazel
    0

    Hej Nicolaj,

    Well I really appreciated your help :-) and I will try doing the thing you are suggesting here,

    but I think if you have a snippet that could help me here, And if it will not give you too much headache 

    It would be really helpfull to have an additional code snippet :-) Not just for me but also if someone else is surfing arround for same problem solution...

     

    Thanks alot for help :-)

    Dmitrij

     

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jan 30, 2013 @ 14:02
    Nickolaj Lundgreen
    0

    I couldn't find a simple example, but i wrote a quick demo (there might be some minor error but I hope you can get some inspiration).

    $('#some_id').on('change', function() {
      var self = this;
      var newValue = self.value; //Get the new value
      var orderlineId = self.data('orderlineid'); 
    //Fetch the orderline attribute - in this case its on the quantity field itself - you properly want it on the <tr> element 
    $.ajax({ type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/webshop/ChangeOrderLineQuantity/"+newValue+"/"+orderlineid,
    dataType: "json",
    success: function (data) { alert(":)");
    }
    });
    });

     

    The input field would look something like this:

    <input type="text" value="123" data-orderlineid="1">
  • Dmitrij Jazel 86 posts 179 karma points
    Jan 30, 2013 @ 14:04
    Dmitrij Jazel
    0

    Ahh.. that's ok,

    I will try work something out from here, and will let you know if there will be any other issues,

    Thanks for so far :-)

  • Dmitrij Jazel 86 posts 179 karma points
    Feb 03, 2013 @ 20:13
    Dmitrij Jazel
    0

    Hej Nickolaj,

    Thanks for the last time :-)

    Just have a short question,

    Apperently I am getting an error here,

    Javascript console says:

    POST http://[mywebshop].dk/webshop/ChangeOrderLineQuantity/10/180 404 (Not Found)

    send jquery.min.js:2 p.extend.ajax jquery.min.js:2 (anonymous function) cart.aspx:359 p.event.dispatch jquery.min.js:2 g.handle.h jquery.min.js:2

    I am using (in my JS code) exact Ajax post you provided here as an example.

    url:"/webshop/ChangeOrderLineQuantity/"+newValue+"/"+orderlineid,

    Any suggestions? :-)

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Feb 03, 2013 @ 22:33
    Nickolaj Lundgreen
    0

    Have you added the /webshop/ path to UmbracoReservedUrls?

  • Dmitrij Jazel 86 posts 179 karma points
    Feb 04, 2013 @ 10:49
    Dmitrij Jazel
    0

    Hej Nickolaj,

    No, I actually haven't.

    Could you tell me where it is located and what I need to add? :-)

    Thanks again,

    Dmitrij

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Feb 04, 2013 @ 14:52
    Nickolaj Lundgreen
    0

    Hi Dmitrij :)

    In the webconfig:

    <add key="umbracoReservedUrls" value=""/>

    The keys value contains URLs that is  restricted from  umbraco's URL engine.

    You will have  to add

    ~/webshop

    To the list (use "," as a seperator)

  • Dmitrij Jazel 86 posts 179 karma points
    Feb 04, 2013 @ 22:06
    Dmitrij Jazel
    0

    Hej Nickolaj,

    Sorry for bothering again :) Was hoping to hit the "home run" but yet got the same 404 again :-/

    I checked Web.Config in the project root, and under <appSettings> found "umbracoReservedUrls" key.

    It already had some reserverd paths from umbraco

    I carefully added into the end

     <add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,~/webshop" />
    

    But still getting http-404 :( I am sure there are no blank spaces, or anything of that sort that could cause error in web.config key.

    Any other suggestions what else can be wrong? :-(

  • Dmitrij Jazel 86 posts 179 karma points
    Feb 04, 2013 @ 23:11
    Dmitrij Jazel
    0

    Hej Nickolaj :)

    I actually did find a work arround, I used some of the scripts that are included along with Razorstore.

    In my case, I missed <umbraco:macro runat="server" alias="ucActionsCart" /> macro.

    Was a bit confused, not sure why didn't I included it earlyer :-)

    But now I got it working (not 100% in the way I wanted it) but I will make it work exactly as I need it.

    If you still have a suggestion to the approach you suggested in your previous post, I would love to hear what could go wrong or what other conditions must be met in order for your solution to work, cause I really like that Ajax post you suggested to use :-)

    Thanks so far, and have a great day!

    Kind regards,

    Dmitrij 

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Feb 04, 2013 @ 23:37
    Nickolaj Lundgreen
    0

    Is it the webservice you have problem getting to work, in that case, what type of webservice are you making?

     

    If you post a description with some code, i could take a look at your current solution and make some improvement idears (if any needed).

Please Sign in or register to post replies

Write your reply to:

Draft