WordPress.org

Support

Support » Plugins and Hacks » Business Hours Plugin » [Resolved] Dynamic String update according to Time

[Resolved] Dynamic String update according to Time

  • 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/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Daniel Dvorkin

    @mzaweb

    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!

    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;

    Ignore previous, this one works … 😀

    $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;
    	}
    Plugin Author Daniel Dvorkin

    @mzaweb

    Thanks selsiusx!

    David

    @vdrumsrolandchartertnnet

    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.

    David

    @vdrumsrolandchartertnnet

    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!

    Plugin Author Daniel Dvorkin

    @mzaweb

    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.

    Plugin Author Daniel Dvorkin

    @mzaweb

    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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Dynamic String update according to Time’ is closed to new replies.
Skip to toolbar