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 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..
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 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.
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);
}
});
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
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
Hi Bjarne.
I'm not sure where to look for this.
could it be somwting with class and div?
Palle
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&Height=60&Constrain=true&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
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
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.####" )" />
<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
It's only updated when I refresh the page
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.
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
First make sure the script is included in the template have called after jQuery:
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); } });As I can tell, all the scripts is called: Can you see anything:
This is my developer url: http://geilsk.attcloud.dk/ ;
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');You just need to add e.g. <div id="cart"> inside you <div id="content">, which wraps the cart content..
That should do it..
Hi Bjarne.
That did the trick.
Thanks for your help.
/Palle
I'm glad I could help :) ..
/Bjarne
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.