Can't use a php IF test in UniversalEMail?
Hello,
For almost a week I've been working on this simple problem and can't figure it out ...
On this website that I'm building (done with eCart and other WA extentions), customers buy classes. It may be a one day class or a multi-day class. In the email confirmation receipt it is important for the customer to see the dates of the class they just bought so they know when to show up :-)
It's easy enough to print both dates:
<?php //echo $eCart1->DisplayInfo("Date"); . " - " . $eCart1->DisplayInfo("Through"); ?>
( FYI $eCart1->DisplayInfo("Through") is a cart attribute that I created and it does work, perfectly, everywhere else on the site )
I can also assign those dates to variables and format them nicely:
$bdate = $eCart1->DisplayInfo("Date");
$edate = $eCart1->DisplayInfo("Through");
print date('l F jS, Y', strtotime($bdate));
And all of that works great both on the site pages and in the confirmation email. The email is a UE4 object, but I believe it was created as part of the eCart checkout wizard.
With these functions I can get a nice looking date such as:
Thursday December 21st, 2023
through —
Fri., Dec. 22nd
The breakdown occurs on one-day classes. I don't want to print 2 dates on the one day classes, it looks bad and confuses the customers.
On the php web pages this is is to do, I simply put the "through -" and the second date inside an if statement and only display them if the start date and end dates don't match:
<?php //echo $eCart1->DisplayInfo("Date"); . " - " . <?php echo $eCart1->DisplayInfo("Through"); ?>
<?php
$bdate = $eCart1->DisplayInfo("Date");
$edate = $eCart1->DisplayInfo("Through");
print date('l F jS, Y', strtotime($bdate));
//echo $eCart1->DisplayInfo("Date");
if ($bdate != $edate) { // Show if date doens't match
print "<br /><em> through —</em><br />" . date('D., M. jS', strtotime($edate));
//print " - to - " . date('D., M. jS', strtotime($edate));
} // Show if date doens't match
?>
However, not matter what I try, I cannot get an if statement to work correctly in an email.
I've tried all kinds of things, my last try was:
<?php if ($bdate != $edate) { echo "does not match"; }?>
<?php if ($bdate == $edate) { echo "does match"; }?>
<?php if ($bdate != $edate) { print "does not match"; }?>
<?php if ($bdate == $edate) { print "does match"; }?>
<!--Show if date doens't match-->
<?php if ($eCart1->DisplayInfo("Date") != $eCart1->DisplayInfo("Through")) { "<br /><em> through —</em><br />" . date('D., M. jS', strtotime($edate)); }?>
<?php // alternate print line:// print " - to - " . date('D., M. jS', strtotime($edate)); ?>
<!--Show if date doens't match-->
Does anyone know how to do this in an email?
Thanks