Developer forum

Forum » Ecommerce - Standard features » Total amount of products in a context cart

Total amount of products in a context cart

Harald Brouwers
Reply

Hallo,

I have a question. I'm using a context cart in my project. To get the total amount of products in the cart, I use: "Ecom:Order.OrderLines.TotalProductQuantity". This works fine in the checkout page(s) of the Cart V2 module.

The problem is that I have a counter in a header of my page, which is always visible and shows the user the amount of products in his cart. When I use "Ecom:Order.OrderLines.TotalProductQuantity" there, I get the amount of the "wrong" cart. A cart with no context.

How do I tell the TotalProductQuantity to look for a specific context cart and give me the total amount of products?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Harald

You have a loop called OrderContexts in the layout template - loop that to find the right context and find the total amount in there.

You can also access the eCommerce.Orders.OrderContext.GetOrderContexts() using Linq to find the right context and get the amount from that.

BR Nicolai

 
Harald Brouwers
Reply

Hi Nicolay,

Thank you for your answer.

Using the OrderContexts loop I cant get the right contect (OrderContext.ID). The problem I have here is that my ordercontext contains:

OrderContext.ID AtWork
OrderContext.Name AtWork Cart
OrderContext.IsCurrent False
...
Loops  

The problem I have here is that I cant seem to get the TotalProductQuantity for this cart with the AtWork order context.

So how do I tell "Ecom:Order.OrderLines.TotalProductQuantity" to look in this AtWork context cart?

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Wrong loop - use the OrderContextCarts loop and you have the carts there...

Votes for this answer: 2
 
Harald Brouwers
Reply

Thanx, that solved it!

 

You must be logged in to post in the forum