• Resolved rtenvoorde

    (@rtenvoorde)


    Hey there!
    I’m trying to set this up where our website will show whether they’re open or close at the time and each day has a differing schedule. So, for each day there is a shortcode like this:

    [time-restrict-repeat type=”weekly” onday=”Saturday” offday=”Saturday” ontime=”10:00:00″ offtime=”23:00:00″ else=”Work sucks, drink beer.”]
    It’s the weekend baby!
    [/time-restrict-repeat]

    [time-restrict-repeat type=”weekly” onday=”Sunday” offday=”Sunday” ontime=”11:00:00″ offtime=”19:00:00″ else=”Work sucks, drink beer.”]
    It’s the weekend baby!
    [/time-restrict-repeat]

    ETC….
    With this setup, it will always output the “else” content, in this case it will repeat the “Work sucks, drink beer.” statement 6 times (one for each day it is not).

    Since the “OFF” statement is the same, is there a way only run one “OFF” statement? Or a conditional like so:

    IF it’s Saturday AND between X and Y
    OR
    it’s Sunday between x and y
    OR
    it’s Monday between x and y
    DO THIS
    ELSE
    DO THIS INSTEAD

    This way it would only produce one ELSE content.
    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Dave Clements

    (@thewanderingbrit)

    There is a way to do this, but you need to not use the else paramter, because as you say, it will always display the else content. You need to add a second shortcode for each shortcode that you currently have, which basically accounts for the time between the previous offtime and the next ontime. So, from your example:

    [time-restrict-repeat type="weekly" onday="Saturday" offday="Saturday" ontime="10:00:00" offtime="23:00:00"]
    It’s the weekend baby!
    [/time-restrict-repeat]
    
    [time-restrict-repeat type="weekly" onday="Saturday" offday="Sunday" ontime="23:00:00" offtime="11:00:00"]
    Work sucks, drink beer.
    [/time-restrict-repeat]
    
    [time-restrict-repeat type="weekly" onday="Sunday" offday="Sunday" ontime="11:00:00" offtime="19:00:00"]
    It’s the weekend baby!
    [/time-restrict-repeat]
Viewing 1 replies (of 1 total)
  • The topic ‘A way to add AND or OR conditionals?’ is closed to new replies.