Message Template Condition

5 months ago
Since the message template "if" logic does not support "else", how to write "does not contain"? I tried both methods below when testing the template but they do not display their results.


%if (!(%Shipment.TrackingNumber%).Contains("1Z"))
USPS
endif%

Or

%if ((%Shipment.TrackingNumber%).Contains("1Z")==false)
USPS
endif%

Regards
5 months ago
Try putting spaces around your operators.

https://www.nopcommerce.com/en/boards/topic/82336/complex-if-else-logic-in-message-template#287263
5 months ago
Nope. Does not work either.

I even tried all of this. OP says it worked when processing live and not from testing template. Could this be the case? Or is this a syntax problem. I have the opposite issue as this thread. Even using simple "contains" fails when in production but passes when tested. Very inconsistent behavior.

https://www.nopcommerce.com/en/boards/topic/94828/message-templates-contains-logic

Regards
5 months ago
It worked for me in both "live" (Add shipment to order / enter tracking number / selected "Shipped"), and with the "Test template" on the Edit page.  
(using 4.60.4 on my dev PC)

%if ((%Shipment.TrackingNumber%).Contains("1Z") == false)
USPS
endif%

%if ((%Shipment.TrackingNumber%).Contains("1Z") == true)
UPS
endif%

Check your System > Log to see if any error messages.