Copied to clipboard

Flag this post as spam?

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


  • phil 58 posts 78 karma points
    Mar 20, 2012 @ 15:19
    phil
    0

    delete orderline in cart

    I have have written the following code for my shopping cart to display the item name quantity unit price total price for each orderline with functionality to add more or less to to quantity which woks perfect but I have also added a option to delete the orderline but when i click the button it adds 1 to the quantity and can't work out why.

    @foreach (OrderLine orderline in TeaCommerce.GetOrder().OrderLines{
            <tr id="@orderline.NodeId" class="orderLine" orderLineId="@orderline.Id" nodeId="@orderline.NodeId">
              <td>
                @orderline.Properties.Single(=p.Alias.Equals("nodeName"&p.UmbracoLanguageId == order.UmbracoLanguageId).Value
              </td>
              <td>
                <form action="/tcbase/teacommerce/SubmitForm.aspx" method="post">
                  <input name="AddOrderLine" type="hidden" value="nodeId,quantity" />
                  <input name="nodeId" type="hidden" value="@orderline.NodeId" />
                  <input name="quantity" type="hidden" value="1" />
                  <input type="submit" value="+" class="plus" />
                </form>                                                                 
                <input type="text" class="productQuantity" value="@orderline.Quantity" lastvalue="@orderline.Quantity" size="2" />                                                               
                <form action="/tcbase/teacommerce/SubmitForm.aspx" method="post">
                  <input name="AddOrderLine" type="hidden" value="nodeId,quantity" />
                  <input name="nodeId" type="hidden" value="@orderline.NodeId" />
                  <input name="quantity" type="hidden" value="-1" />
                  <input type="submit" value="-" class="minus" />
                </form>                                                               
              </td>
              <td>@orderline.UnitPriceFormatted</td>
              <td>@orderline.TotalPriceFormatted</td>
              <td>
               <form action="/tcbase/teacommerce/SubmitForm.aspx" method="post">
                  <input name="AddOrderLine" type="hidden" value="nodeId,quantity">
                  <input name="nodeId" type="hidden" value="@orderline.NodeId">
                  <input type="submit" value="Delete" class="remove">
                </form>
              </td>
            </tr>
                                                                               
          }
  • Anders Burla 2560 posts 8256 karma points
    Mar 20, 2012 @ 16:20
    Anders Burla
    0

    Hi Phil

    There was an error in the starter kit. Your last form should have these two lines as the first ones

    <input name="RemoveOrderLine" type="hidden" value="nodeId" />
    <input name="nodeId" type="hidden" value="{@nodeId}" />

    Try that and see if that works. If not - then maybe your javascript has an error.

    Kind regards
    Anders

  • phil 58 posts 78 karma points
    Mar 20, 2012 @ 16:26
    phil
    0

    Thanks that has solved the problem works a treat

  • Anders Burla 2560 posts 8256 karma points
    Mar 20, 2012 @ 16:30
    Anders Burla
    0

    Cool - could you mark the answer as the solution then? :)

Please Sign in or register to post replies

Write your reply to:

Draft