Developer forum

Forum » Templates » && (AND) statement in if sentences

&& (AND) statement in if sentences

Thomas Nielsen
Reply

Hi,

 

Can anyone explain to me why the below is not working?

I bsically want to output a different text, bases on the value in the shopping cart.

 

I found this article that explains how to use && (and) and || (or) statements in Dynamicweb:

http://devierkoeden.com/articles/dynamicwebs-best-kept-secrets-part-2-else-statements-and-support-for-and-and-or.aspx

 

                        <!--@If(Ecom:Order.Price.PriceWithoutVAT>5000 && Ecom:Order.Price.PriceWithoutVAT<10000)-->
                            10000 - Price: <!--@Ecom:Order.Price.PriceWithoutVAT--><br />
                        <!--@EndIf-->
                       
                        <!--@If(Ecom:Order.Price.PriceWithoutVAT>0 && Ecom:Order.Price.PriceWithoutVAT<5000)-->
                            5000 - Price: <!--@Ecom:Order.Price.PriceWithoutVAT--><br />
                        <!--@EndIf-->
 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Thomas,

 

Can you define "does not work"? Do you get an error? Or an unexpected result? In both cases, more details would help.

 

Cheers,

 

Imar

 

 
Thomas Nielsen
Reply

Hi Imar,

 

Yep, sorry for the lacking explanation.

 

Problem is that i can not get the && statement to work, one check in each if works.

No errors or anything.

 

Even if the sentence was true, it would not go into the if (so it failed) but it would also not display anything from a related else.

I suspect it has to do with the value of PriceWithoutVAT, beeing something like 8.360,00, maybe not beeing considered a number?

I solved it with javascript (a hack) and when i wanted to compare the value in JS i had to cast to a number before it worked.

 

Thank you for sharing this on your blog - wondering why this stuff is not in the Dynamicweb doc, in even more detail??

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Thomas,

 

In which template and on what version of Dynamicweb are you testing this? I added your code to a Cart V2 step and it displays 5000 for a product with a price of 110 which seems to be OK. I accidentally tried it in a Product template first where it doesn't work because the Order: template tags don't exist. The comparison tags don't work well with undefined tags.

 

Also, make sure you use a recent version of Dynamicweb as this feature was only added recently.

 

>> wondering why this stuff is not in the Dynamicweb doc, in even more detail??

 

I think documentation / samples are in the works; this is a brand new feature.

 

Cheers,

 

Imar

 
Nicolai Høeg Pedersen
Reply

As Imar points out, this feature require 8.2.1 to work.

 
Thomas Nielsen
Reply

I was not running the required version and it seems to work now.

 

Thanks for helping out, this feature helps alot in writing templates - now for the if else sentences Nicolai ;-)

 
Nicolai Høeg Pedersen
Reply

They are also in that realease...


<!--@If(DwPageID=1)-->
Page ID is 1
<!--@Else-->

Page ID is something else than 1
<!--@EndIf-->

 

Nesting not allowed.

 

Also check out the Tech Crunch from last week: http://engage.dynamicweb-cms.com/Video-Library-1337.aspx

 
Marco Johannesen
Reply

Is it just me.... or do !--@Else-- not work on "If Not" evals? ;-(

 
Nicolai Høeg Pedersen
Reply

Shoul work. But provide example and/or link to the issue and we will check it out.

 

BR Nicolai

 

You must be logged in to post in the forum