the "updateMiniCart()" is called and I get no errors in the console but the "totalQuantity' equals 0 every time.
this is the "updateMiniCart" function
function updateMiniCart() {
var order = TC.getCurrentOrder();
var miniCart = jQuery('#miniCart');
if (miniCart[0]) {
var totalQuantity = getOrderTotalQuantity(order);
//miniCart.find('#miniCartTotalPrice').text(order.subtotalPrice.withVatFormatted);
miniCart.find('#miniCartTotalQuantity').text(totalQuantity);
miniCart.attr('class', 'items' + totalQuantity);
}
}
Does those line have any effect on my issue? do I really need all these attributes in the div class? refreshwithtemplate, productid, itemprop, itemscope, itemtype
The div is just for styling, and if you have variants you can use the refreshwithtemplate attribute to change the content of the div, when changing the variant. To see how that works, you need to look at our starter kit.
Update mini cart javascript
My miniCart is not updating.
the "updateMiniCart()" is called and I get no errors in the console but the "totalQuantity' equals 0 every time.
this is the "updateMiniCart" function
and this is the order object
I am using umbraco version 6.1.6 and teaCommerce 2.2.2
Hi Moran,
Have you doublechecked that you have an element with id="miniCart" and an element inside that with the id="miniCartTotalQuantity"
Otherwise it won't work.
Maybe try using your browsers developer tools to debug the javascript and check the values and what happens.
/Rune
Hi rune
This is my html code
That looks fine. What is the value of totalQuantity?
/Rune
It always show "0" even if the parametr "order" has value like I attached to the post above.
AAAH. I see it now. Your order has no order lines: orderLines:Array[0]
That's why :)
/Rune
How do I add order lines? did I forgot to include a script or call some function?
Don't you have a product page, with some add to cart functionality?
/Rune
I only have a "featured products" widget in the home page, this is where I added the "add to cart" functionality.
Rune
I think I am missing this two lines:
Does those line have any effect on my issue? do I really need all these attributes in the div class? refreshwithtemplate, productid, itemprop, itemscope, itemtype
The line with the form tag is the most important line. That's the one that makes the add to cart possible. Heres a link to how that works:
http://documentation.teacommerce.net/html-api/order-line/addorupdateorderline/
If you want to do an add to cart with only javascript you can have a look at this page:
http://documentation.teacommerce.net/javascript-api/order-lines/addorupdateorderline/
The div is just for styling, and if you have variants you can use the refreshwithtemplate attribute to change the content of the div, when changing the variant. To see how that works, you need to look at our starter kit.
/Rune
Thanks
Will this work also with the MVC scheme? I had some issues with form tags before :)
Yes. That is just simple forms and javascript not bound to a server side tech. So no problems in that :)
/Rune
Ok thanks
I will take a look at that.
Thanks for the help :)
is working on a reply...