Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 11, 2017

Will you also need to accommodate schedule exceptions? Holidays, unexpected closures?

Hi, 

No, I'm thinking of something that will override the standard message when they enter some text manually for that day...

1. Setup a Single Record Editor

2. Add fields for mon,tue,wed,thu,fri,sat,sun

3. Add your hours

4. connect your webpage to this new editor

4. Use this code where you want the message to appear

   <?php if (date("N")==1): ?>
      <?php if($hoursRecord['mon']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['mon']) ?>
      <?php endif; ?>
   <?php endif; ?>
   <?php if (date("N")==2): ?>
      <?php if($hoursRecord['tue']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['tue']) ?>
      <?php endif; ?>
   <?php endif; ?>
   <?php if (date("N")==3): ?>
      <?php if($hoursRecord['wed']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['wed']) ?>
      <?php endif; ?>
   <?php endif; ?>
   <?php if (date("N")==4): ?>
      <?php if($hoursRecord['thu']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['thu']) ?>
      <?php endif; ?>
   <?php endif; ?>
   <?php if (date("N")==5): ?>
      <?php if($hoursRecord['fri']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['fri']) ?>
      <?php endif; ?>
   <?php endif; ?>
   <?php if (date("N")==6): ?>
      <?php if($hoursRecord['sat']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['sat']) ?>
      <?php endif; ?>
   <?php endif; ?>
   <?php if (date("N")==7): ?>
      <?php if($hoursRecord['sun']=="Closed"): ?>
         Sorry, we are closed today.
      <?php else: ?>
         Today we are open from <?php echo htmlencode($hoursRecord['sun']) ?>
      <?php endif; ?>
   <?php endif; ?>

Thx, tried it and works very well !!