Copied to clipboard

Flag this post as spam?

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


  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 14:50
    Palle Hansen
    0

    Cart won't update Subtotal, Vat and Total price

    Hi,
    I'm using TC vers. 2.1.3 and umbraco 6.1.3.
    My problem is, that in the checkout - cart/view-order-line-overview.cshtml, my Subtotal,Vat and Total price won't update when I change the quantity on the orderline.

    And this cart/step-cart-content.cshtml is also not updating
    I've got not script error.

    The minicart is updateing and orderline is updating.

    I can't seem to find where it goes wrong.

    Best regards
    Palle

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 15:11
    Bjarne Fyrstenborg
    0

    Hi Palle

    I have a webshop running with Tea Commerce v. 2.1.3 and Umbraco 6.1.6 without problem on updating the cart..

    It was developed in a previous version and I have upgraded it some times.. in v. 2.2.0 I had to change some of the methods as some have been removed HasCurrentOrder and HasCurrentFinalizedOrder..

    How does your code looks like in these files?

    /Bjarne

  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 15:57
    Palle Hansen
    0

    Hi Bjarne.

    I'm not sure where to look for this.
    could it be somwting with class and div?

    Palle 

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 16:10
    Bjarne Fyrstenborg
    0

    I think it should be in cart/view-order-line-overview.cshtml

    Try to compare with this file I have to see if you have something different?

    @using TeaCommerce.Umbraco.Web
    @using TeaCommerce.Api.Models
    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
    
      //Store id
      long storeId = long.Parse( Model._Store );
    
      //Cart template
      //1198 = Cart content
      //1201 = Accept
      //1203 = Confirmation
      int cartTemplate = Model.template;
    
      Order order = TC.GetCurrentOrder( storeId );
      decimal totalQuantity = 0;
    
      if ( cartTemplate != 1203 ) {
        if ( order != null ) {
          order = TC.GetCurrentOrder( storeId );
        }
    
      } else {
        if ( TC.GetCurrentFinalizedOrder( storeId ) != null ) {
          order = TC.GetCurrentFinalizedOrder( storeId );
        }
      }
    
      if ( order != null ) {
        totalQuantity = order.OrderLines.Sum( o => o.Quantity );
      }
    
    
    
    }
    @if ( order != null && totalQuantity > 0 ) {
      int count = 1;
    
      //Shipping
      ShippingMethod currentShippingMethod = order.ShipmentInformation.ShippingMethodId != null ? TC.GetShippingMethod( storeId, order.ShipmentInformation.ShippingMethodId.Value ) : TC.GetCurrentShippingMethod( storeId );
    
      //Pament
      PaymentMethod currentPaymentMethod = order.PaymentInformation.PaymentMethodId != null ? TC.GetPaymentMethod( storeId, order.PaymentInformation.PaymentMethodId.Value ) : TC.GetCurrentPaymentMethod( storeId );
    
      //View settings
      //We use the id's of the templates to identify which information to show or hide from the view
      bool showQuantityForms = cartTemplate == 1198,
           showDeleteForm = showQuantityForms,
           showShippingAndPayment = cartTemplate != 1198,
           showTransactionFee = cartTemplate == 1203;
    
      string cssClass = "cartContent";
      cssClass += showQuantityForms ? " showQuantityForms" : "";
      cssClass += showDeleteForm ? " showDeleteForm" : "";
      cssClass += showShippingAndPayment ? " showShippingAndPayment" : "";
      cssClass += showTransactionFee ? " showTransactionFee" : "";
    
      //Cart content
      <div class="@cssClass">
        <table class="table">
          <tr>
            <th class="col1">
              @Dictionary[ "Image" ]
            </th>
            <th class="col2">
              @Dictionary[ "Name" ]
            </th>
            <th class="col3 center">
              @Dictionary[ "Quantity" ]
            </th>
            <th class="col4 right">
              @Dictionary[ "UnitPrice" ]
            </th>
            <th class="col5 right">
              @Dictionary[ "TotalPrice" ]
            </th>
            @if ( showDeleteForm ) {
              <th class="col6 center">
                @Dictionary[ "Delete" ]
              </th>
            }
          </tr>
          @foreach ( OrderLine orderLine in order.OrderLines ) {
    
            //Product
            DynamicNode product = Model.NodeById( orderLine.ProductIdentifier.ToString() );
    
            //Image
            string imageStr = TC.GetPropertyValue( storeId, orderLine.ProductIdentifier, "image" );
            string[] imageIds = imageStr.Split( new char[] { ',' } );
            string image = imageIds.Length > 0 ? Model.MediaById( imageIds[ 0 ] ).umbracoFile : "";
    
            //Css Class
            string orderLineCssClass = "item item" + count;
            if ( count == 1 ) { orderLineCssClass += " firstitem"; }
            if ( count == order.OrderLines.Count ) { orderLineCssClass += " lastitem"; }
    
            //Id
            string id = "orderLine" + orderLine.Id;
    
            <tr id="@id" class="@orderLineCssClass" orderLineId="@orderLine.Id" nodeId="@product.Id">
              <td class="col1">
                <a href="@product.Url">
                  <img alt="" src="/ImageGen.ashx?Width=60&amp;Height=60&amp;Constrain=true&amp;Image=@image" />
                </a>
              </td>
              <td class="col2">
                <a href="@product.Url">
                  @orderLine.Name
                </a>
              </td>
              <td class="col3 center">
                @if ( showQuantityForms ) {
                  <div class="input-append">
                    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
                    <input name="storeId" type="hidden" value="@storeId" />
                    <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity" />
                    <input name="orderLineId" type="hidden" value="@orderLine.Id" />
                    <input name="quantity" type="hidden" value="1" />
                    <input type="submit" value="+" class="plus btn first-child" />
                    </form>
                    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
                    <input name="storeId" type="hidden" value="@storeId" />
                    <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity, overwriteQuantity : overwriteQuantity" />
                    <input name="overwriteQuantity" type="hidden" value="true" />
                    <input name="orderLineId" type="hidden" value="@orderLine.Id" />
                    <input type="text" name="quantity" class="quantity middle-child" value="@orderLine.Quantity.ToString( "0.####" )" />
                    </form>
                    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
                    <input name="storeId" type="hidden" value="@storeId" />
                    <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity" />
                    <input name="orderLineId" type="hidden" value="@orderLine.Id" />
                    <input name="quantity" type="hidden" value="-1" />
                    <input type="submit" value="-" class="minus btn" />
                    </form>
                  </div>
                } else {
                  @orderLine.Quantity.ToString( "0.####" )
                }
              </td>
              <td class="col4 right unitPrice">
                @orderLine.UnitPrice
              </td>
              <td class="col5 right totalPrice">
                @orderLine.TotalPrice
              </td>
              @if ( showDeleteForm ) {
                <td class="col6 right">
                  <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
                  <input name="RemoveOrderLine" type="hidden" value="orderLineId : orderLineId" />
                  <input name="storeId" type="hidden" value="@storeId" />
                  <input name="orderLineId" type="hidden" value="@orderLine.Id" />
                  <button type="submit" class="delete" title="@Dictionary[ "RemoveThisItem" ]"><i class="icon-trash icon-large"></i></button>
                  @*<input type="image" src="/css/gfx/cart-delete.png" class="delete" />*@
                  </form>
                </td>
              }
            </tr>
    
              count++;
          }
          <tr class="orderTotal">
            <td colspan="4" class="right">
              @Dictionary[ "Subtotal" ]
            </td>
            <td @if(showDeleteForm){@Html.Raw("colspan=2")} class="money right" id="subtotalPrice">
              @order.SubtotalPrice
            </td>
          </tr>
          @if ( showShippingAndPayment ) {
            if ( currentShippingMethod != null ) {
            <tr class="orderTotal">
              <td colspan="4" class="right">
                @Dictionary[ "Shipping" ] (@Dictionary[ currentShippingMethod.Alias ])
              </td>
              <td @if(showDeleteForm){@Html.Raw("colspan=2")} class="money right" id="shipmentInformationTotalPrice">
                @order.ShipmentInformation.TotalPrice
              </td>
            </tr>
            }
            if ( currentPaymentMethod != null ) {
            <tr class="orderTotal">
              <td colspan="4" class="right">
                @Dictionary[ "Payment" ] (@Dictionary[ currentPaymentMethod.Alias ])
              </td>
              <td @if(showDeleteForm){@Html.Raw("colspan=2")} class="money right" id="paymentInformationTotalPrice">
                @order.PaymentInformation.TotalPrice
              </td>
            </tr>
            }
            if ( showTransactionFee && order.TransactionInformation.TransactionFee.Value > 0 ) { 
            <tr class="orderTotal">
              <td colspan="4" class="right">
                @Dictionary[ "TransactionFee" ]
              </td>
              <td @if(showDeleteForm){@Html.Raw("colspan=2")} class="money right" id="transactionInformationTransactionFee">
                @order.TransactionInformation.TransactionFee
              </td>
            </tr>
            }
          }
          <tr class="orderTotal">
            <td colspan="4" class="right">
              @Dictionary[ "VAT" ]
            </td>
            <td @if(showDeleteForm){@Html.Raw("colspan=2")} class="money right" id="totalVat">
              @if ( showShippingAndPayment ) {
                @order.TotalPrice.VatFormatted
              } else { 
                @order.SubtotalPrice.VatFormatted
              }
            </td>
          </tr>
          <tr class="orderTotal">
            <td colspan="4" class="right">
              @Dictionary[ "Total" ]
            </td>
            <td @if(showDeleteForm){@Html.Raw("colspan=2")} class="money right" id="totalPrice">
              @if ( showShippingAndPayment ) {
                @order.TotalPrice
              } else { 
                @order.SubtotalPrice
              }
            </td>
          </tr>
        </table>
      </div>
    
    }

    /Bjarne

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 16:18
    Bjarne Fyrstenborg
    0

    ecommerce.js has the following ids, so make sure they exists in your code..

    cart.find('#cartTotalQuantity').text(getOrderTotalQuantity(order));
    
        cart.find('#subtotalPrice').text(order.subtotalPrice.withVatFormatted);
        cart.find('#shipmentInformationTotalPrice').text(order.shipmentInformation.totalPrice.withVatFormatted);
        cart.find('#paymentInformationTotalPrice').text(order.paymentInformation.totalPrice.withVatFormatted);
        cart.find('#transactionInformationTransactionFee').text(order.transactionInformation.transactionFee.withVatFormatted);
    
        if (showShippingAndPayment) {
          cart.find('#totalVat').text(order.totalPrice.vatFormatted);
          cart.find('#totalPrice').text(order.totalPrice.withVatFormatted);
        } else {
          cart.find('#totalVat').text(order.subtotalPrice.vatFormatted);
          cart.find('#totalPrice').text(order.subtotalPrice.withVatFormatted);
        }

    /Bjarne

  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 16:29
    Palle Hansen
    0

    I've checked the code and the only place where it's a bit different is this below.
    I'm not using - and + to update quantity. I'm using an update to click.

    I have the ids in the code. 

    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
    <input name="storeId" type="hidden" value="@storeId" />
    <input name="AddOrUpdateOrderLine" type="hidden" value="orderLineId : orderLineId, quantity : quantity, overwriteQuantity : overwriteQuantity" />
    <input name="overwriteQuantity" type="hidden" value="true" />
    <input name="orderLineId" type="hidden" value="@orderLine.Id" />
    <input type="number" name="quantity" class="quantity middle-child overview" value="@orderLine.Quantity.ToString( "0.####" )" />&nbsp;
    <input type="image" src="./images/update.png" alt="Opdater" />
    </form>

    <form action="/base/TC/FormPost.aspx" method="post" class="ajaxForm">
    <input name="RemoveOrderLine" type="hidden" value="orderLineId : orderLineId" />
    <input name="storeId" type="hidden" value="@storeId" />
    <input name="orderLineId" type="hidden" value="@orderLine.Id" />
    <input type="image" src="/catalog/view/theme/journal/images/remove.png" class="delete" />
    </form>

     Palle

  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 16:38
    Palle Hansen
    0

    It's only updated when I refresh the page

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 16:50
    Bjarne Fyrstenborg
    0

    I think it might be something in javascript where it fails.. have you tried to use the debugger in ecommerce.js to see what happens when you e.g. increase the quantity.. here I have a product with price 2.895,00 DKK and after click "+"-button the javascript subtotal with VAT in javascript is 5.790,00 DKK.

  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 17:07
    Palle Hansen
    0

    Well it seems that the script doens't do anything, when I click on the update image.
    Is it because the script can't find the id?

     

    Palle 

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 17:17
    Bjarne Fyrstenborg
    0

    First make sure the script is included in the template have called after jQuery:

    <script type="text/javascript" src="/scripts/ecommerce.js"></script>

    Next you can stop the debugger after around lin 134: var cart = jQuery('#cart'); so if you set the marker in line 136 the cart shouldn't be undefined..

    Also make sure updateCart function is called here:

    TC.bind('afterCartUpdated', function (data, jQForm) {
      //Set elements in updating mode
      resetUpdatingElements(jQForm, function () {
      if(data.order != null){
          updateMiniCart(data.order);
          updateCart(data.order, true);
      }
      });
    
    });

    and here:

    TC.bind('afterAddOrUpdateOrderLine', function (orderLine, data, jQForm) {
      var updatingElement = jQForm.closest('.updating');
    
      if (updatingElement.hasClass('item')) {
        if (orderLine.quantity <= 0) {
          var deleteElement = jQuery('#orderLine' + orderLine.id);
          deleteElement.remove();
        } else {
          updateCartOrderLine(orderLine);
        }
        updateCart(data.order);
      }
    ... 

    and here:

    TC.bind('afterRemoveOrderLine', function (orderLine, data, jQForm) {
      var updatingElement = jQForm.closest('.updating');
    
      if (updatingElement.hasClass('item')) {
        //We are updating an order line in the cart
    
        var deleteElement = jQuery('#orderLine' + orderLine.id + ', #orderLine' + orderLine.copiedFromOrderLineId);
        deleteElement.remove();
    
        updateCart(data.order);
      }
    
    });

     

  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 18:11
    Palle Hansen
    0

    As I can tell, all the scripts is called: Can you see anything:
    This is my developer url: http://geilsk.attcloud.dk/ ;

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 19:26
    Bjarne Fyrstenborg
    0

    Yes, it seems that you are missing the wrapper with id="cart" e.g. a div container..

    For that reason these variables will become undefined:

    var cartContent = cart.find('.cartContent'),
            showQuantityForms = cartContent.hasClass('showQuantityForms'),
        cartItemInfo = cart.find('#cartItemInfo'),
            showDeleteForm = cartContent.hasClass('showDeleteForm'),
            showShippingAndPayment = cartContent.hasClass('showShippingAndPayment'),
            showTransactionFee = cartContent.hasClass('showTransactionFee');

    jQuery('#cart'); doesn't return an element.. and the variable cart therefore doesn't contain the element from DOM.

    var cart = jQuery('#cart');
  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 19:41
    Bjarne Fyrstenborg
    0

    You just need to add e.g. <div id="cart"> inside you <div id="content">, which wraps the cart content..
    That should do it..

  • Palle Hansen 143 posts 396 karma points
    Jan 26, 2014 @ 19:43
    Palle Hansen
    100

    Hi Bjarne.

    That did the trick. 
    Thanks for your help.

    /Palle 

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Jan 26, 2014 @ 19:52
    Bjarne Fyrstenborg
    0

    I'm glad I could help :) ..

    /Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft