Developer forum

Forum » Development » Check cart

Reply

Hi!

How do I check if there are some items in the shopping cart? If there are no items in the cart I want to display the number zero or just "Empty"

I've tried this

<!--@If Defined(Ecom:Order)-->
<!--@Ecom:Order.OrderLines.Total.Price-->
<!--@Else-->
0
<!--@EndIf(Ecom:Order)-->

But when used this code, nothing at all was displayed.

Best regards,

P


Replies

 
Nicolai Høeg Pedersen
Reply

Your  If defined is wrong. Take a look at this:
http://templates.dynamicweb.dk/TemplateTags/Dynamicweb-template-tags/General-tags/If/else-tags.aspx

And you need to check using the tag Ecom:Order.IsEmpty
http://templates.dynamicweb.dk/eCommerce/Dynamicweb-eCommerce-template-tags/Shopping-Cart-V2/Order/Cart/EcomOrder.IsEmpty.aspx

So it should look like this:
<!--@If Not Defined(Ecom:Order.IsEmpty)-->
<!--@Ecom:Order.OrderLines.Total.Price-->
<!--@EndIf(Ecom:Order.IsEmpty)-->

<!--@If Defined(Ecom:Order.IsEmpty)-->
0
<!--@EndIf(Ecom:Order.IsEmpty)-->

 

You must be logged in to post in the forum