WordPress.org

Ready to get started?Download WordPress

Forums

Business Hours Plugin
[resolved] Dynamic String update according to Time (9 posts)

  1. selsiusx
    Member
    Posted 1 year ago #

    Is it possible to display the closed string when it is past closing time? not only when the day is marked as a closing day, but say if opening times were form 12h till 23h and it's 16h it would display the "we are open" string and if it were after 23h it would display the "we are closed" string.

    This would be a great feature! If it already exist, how do I activate it because it is not working for me on 2.0...

    http://wordpress.org/extend/plugins/business-hours-plugin/

  2. Daniel Dvorkin (MZAWeb)
    Member
    Plugin Author

    Posted 1 year ago #

    It's not possible right now. I'll make a note to consider this for a future version, because I think it's a cool idea!

    Thanks!

  3. selsiusx
    Member
    Posted 1 year ago #

    hi, i did it myself.. quick& dirty offcourse in BussinenssHours.class.php

    $blogtime = current_time('timestamp');
    		$currenthour = date("g",$blogtime);
    		$openhour = date("g", $open);
    
    		if ( $is_open_today ) {
    			if ($openhour < $currenthour)
    			{
    			$content = str_replace( "{{TodayOpen}}", $open, $content );
    			$content = str_replace( "{{TodayClose}}", $close, $content );
    			}
    			else $content = $closed;
    		} else {
    			$content = $closed;
    		}
    		return $content;
  4. selsiusx
    Member
    Posted 1 year ago #

    Ignore previous, this one works ... :D

    $open          = esc_html( business_hours()->settings()->get_open_hour( $id ) );
    		$close         = esc_html( business_hours()->settings()->get_close_hour( $id ) );
    		$is_open_today = business_hours()->settings()->is_open( $id );
    		$blogtime = current_time('timestamp');
    		$currenthour = date("H:i",$blogtime); //convert to 24h notation
    		$openhour = date($open);
    		$closehour = date($close);
    		//echo $currenthour .'We are open from ' . $openhour . 'h till ' . $closehour;
    
    		if ( $is_open_today ) {
    			if (($openhour <= $currenthour) && ($closehour >= $currenthour))
    			{
    			$content = str_replace( "{{TodayOpen}}", $open, $content );
    			$content = str_replace( "{{TodayClose}}", $close, $content );
    			}
    			else $content = $closed;
    		} else {
    			$content = $closed;
    		}
    
    		return $content;
    	}
  5. Daniel Dvorkin (MZAWeb)
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks selsiusx!

  6. David
    Member
    Posted 1 year ago #

    I simply can not get this to work. Where exactly did you put the code? I understand you put it inside the BusinessHours.class.php.
    I'm not too PHP savvy.

  7. David
    Member
    Posted 1 year ago #

    Is this a dead plugin?

    I was hoping to use this plugin because it uses the exception list making it fully automatic. However, I can not get the above code to work at all. If anyone with some knowledge on this could help me out, I would greatly appreciate it.

    I want it to say closed when it's after business hours, and open when the business is open. I do not want it to say open for the entire day.

    Thank You!

  8. Daniel Dvorkin (MZAWeb)
    Member
    Plugin Author

    Posted 1 year ago #

    David, the plugin is not dead, and I'm working on a new version with some new features and a lot of bug fixes... but as I commented on my first message, the functionality you're looking for is not currently supported.

    There were a lot of requests for it, though, so I'm considering adding it to the next release.

  9. Daniel Dvorkin (MZAWeb)
    Member
    Plugin Author

    Posted 11 months ago #

    Just a comment about this. The open and close times are not actually times. Those are text fields that allow you to set whatever you want (by design). I know for a fact that some users, for instance, use the word "noon" instead of 12:00. So if I get to implement this, it needs to be optional.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic