Jump to content
BrockleyJohn

[Addon] Store Times BS

Recommended Posts

A rewrite of the Store Open/Closed addon. The closing of pages is an option so it could be used in a store that's open all the time , e.g. to display whether the customer service phone line is operating.

 

Written for osc 2.3.4 BS Gold and upwards.

 

Set store opening times and open and close checkout:
- Set opening & closing time for each weekday – or set the day to closed
- Define dates and ranges for holidays in the current year; choose to use European or US date format in admin settings
- Set time zone of store to allow for server and store in different zones
- Format for date displays in catalogue and admin are taken from language files to support multi-language/international stores
- Option to close store checkout (or any other pages) by diverting to the Store Times page during closed hours
- Store Times page displays shop hours and holidays
- Header message displays store status
- Dashboard module shows current status and allows admin to override it
- On installation, picks up opening times and holidays from addon 8044 Store Open/Closed if available

 

Download and github links to follow shortly.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi John,

 

Thank you very much for this rewrite. I look forward to adding it to my store.

 

I have come across a few error messages in my admin and I was wondering if you could help me correct the errors. I have using the 2.3.4 BS version.

 

When I try to install the header tags I am unable to install it and the following warning messages is on the header tag page of my admin area.

 

Warning: includes/languages/english/modules/header_tags/store_times.php): failed to open stream: No such file or directory in public_html/admin/modules.php on line 141

Warning: include(): Failed opening 'public_html/includes/languages/english/modules/header_tags/store_times.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in public_html/admin/modules.php on line 141

Fatal error: require(): Cannot redeclare class logger in public_html/admin/includes/application_top.php on line 78

 

 

Any help or input would be greatly appreciated. Thank you in advance.

 

Cheers.

Share this post


Link to post
Share on other sites

@@sunshynecraftsbeads

 

You haven't uploaded all the files correctly. Do so and your errors will disappear.


Let's make things easier for new osCommerce users http://forums.oscommerce.com/topic/402638-discussion-about-hard-coded-database-tables/?p=1718900  Getting there with osCommerce 2.4! :thumbsup:

Share this post


Link to post
Share on other sites

Thanks @@frankl  for the feedback.

 

New day. New Beginnings. And Fresh Eyes 

 

Re Installed and works perfectly. :thumbsup:

 

My next task, changing the box color from orange to match my site. I'll figure it out soon enough.  :D

 

Again thank you Frank for taking the time to help me.

 

Have a great day !

Edited by sunshynecraftsbeads

Share this post


Link to post
Share on other sites

My next task, changing the box color from orange to match my site. I'll figure it out soon enough.  :D

 

The colour of the box is the same as other alert messages on your site. When the store is open, you get the success colour; when closed, warning colour.

 

You can change these with rules in user css that acts on classes .alert-success and .alert-warning respectively.

 

If you want to change the store open/closed box colour without changing the message colours, you'd need to edit the first line of the template in catalog\includes\modules\content\header\templates\store_times.php to something like

<div class="col-sm-12"><div class="text-center alert storebox-<?php echo $type; ?>">

then your css rules would need to address classes .storebox-success and .storebox-warning


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Bugfix release v1.2: I spotted that the feature that diverts pages when the store is closed was ignoring the admin override (to open early or stay open later).

When I get access to the addons area again I will upload a new release. In the meantime, I attach a fixed version of

includes/modules/header_tags/ht_store_times.php

ht_store_times.php


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

v1.2 now available in the new look addons/apps area:

https://apps.oscommerce.com/Apps&8iAPs&store-times-bs


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@BrockleyJohn just looking at this addon out to fix my server time issue (I'm in America/Toronto however my server is in America/Chicago)

However, I don't require the opening a closing configs.

Is there a simple config to have the store open 24/7?

 

Share this post


Link to post
Share on other sites

@greasemonkey Scott, what server time issue do you want to fix? I gather there's a time difference between your server and your store but this addon isn't going to change the time on your orders etc. I think you should be able to sort that out by setting the correct time zone - the 'proper' way is in your php.ini Even if you are on shared hosting you can usually have your own version of php.ini somehow but in this case you'd probably need to get support to help you set it up - and if you want to change php version you'd need to redo it.

That's the only option I can think of if you want to avoid changing any core code but if you're not being anal about that an easier option is to set it in the code - probably in your two application_top files. Your statement should be:

date_default_timezone_set('America/Toronto');

preferably before anything much else happens.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@BrockleyJohn thanks so much for your quick answer.... I'll try not to get your support thread too off topic then.

Yes, I have my php.ini file set to date.timezone = "America/Toronto"

And when I navigate to admin/server_info it does show correctly... including on admin/whos_online....

However the date for orders in the DB is 1 hour ahead.

Example an order placed at EST 15:21:30 (my time.... as stamped by the CC processing API) landed in the orders table as 2017-11-15 16:21:30?

Thinking about this.... that wouldn't be the server time (the server is on CST which would be 14:21:30)?????

Share this post


Link to post
Share on other sites

Hmm, maybe your mysql time zone is out of step. If I remember correctly mysql stores everything as UTC and converts it on the way in and out. It also has two time zones, a global one and one for each session.

SELECT @@global.time_zone, @@session.time_zone;

will find out what they are set to (if it's SYSTEM, it's the system timezone)

SET time_zone = timezone;

will set it but in my (admittedly limited) experience the timezone table isn't often set up, so you probably can't use 'America/Toronto' and will have instead to express it as '-5:00' (your time relative to me as I live 5 miles due south of the Greenwich observatory!)

If you go down this route it'll need a bit of research into daylight saving, I don't know if mysql adjusts for it or not if you do this - your setting code might need to.

Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@BrockleyJohn yes it would seem to be an issue with MySQL. It is currently set at -4 GMT and America/Toronto is currently -5 GMT (we are -4 GMT in daylight savings time.... which ended 11/5).

Researching quickly it seem like a timezone table could/should be set up...

Share this post


Link to post
Share on other sites

@greasemonkey look what I found: A neat way to change PHP / MySQL timezones at the script level

In a nutshell, if php is using the right timezone and handling daylight savings, just use the format of php date that expresses the offset from UTC to set the MySQL timezone:

"SET `time_zone` = '".date('P')."'"

Since MySQL always stores datetimes in UTC, your existing data will be magically corrected.

So there are two statements for a complete solution

date_default_timezone_set('America/Toronto');
tep_db_query("SET `time_zone` = '".date('P')."'");
Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@BrockleyJohn thanks again for your help. I spoke to my host about it last night and it turned out to be a simple fix - just a restart of mysqld....I presume it glitched out with the time change last week.

Here was their reply for those interested:

Quote

MySQL will by default simply inherit current time zone from the server, and that's what set on your server currently:

mysql> show global variables like 'time%';
+---------------+----------+
| Variable_name | Value    |
+---------------+----------+
| time_format   | %H:%i:%s |
| time_zone     | SYSTEM   |
| timed_mutexes | OFF      |
+---------------+----------+
3 rows in set (0.00 sec)


Current time and timezone on your server is correct for EST:

root@host [1678 19:19:15 ~]# date
Wed Nov 15 19:19:16 EST 2017


But I do see what you describe specific to MySQL:

mysql> SELECT NOW();
+---------------------+
| NOW()               |
+---------------------+
| 2017-11-15 20:19:13 |
+---------------------+
1 row in set (0.00 sec)


Time according to MySQL is 1 hour ahead of actual, which would be consistent with GMT -0400.

It may be that mysqld itself simply needs to be restarted to reflect the proper time, its current uptime is 50 days+, which would encompass the point in time DST changed to EST.  I can go ahead and try to restart MySQL to see if that produces consistent time within MySQL reflective of system / actual time.

 

Share this post


Link to post
Share on other sites

 

Hello everyone

is there a possibility to enter the opening times in two stages?

Monday 12:00 - 14:00 / 17:00 - 23:00

Edited by Yepi

Share this post


Link to post
Share on other sites

@Yepi hi Peter, this version does not support siesta or closing time after midnight.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
2 hours ago, Yepi said:

Too bad but thanks anyway is a great contrib

There is one and only one that supports multiple open/close per day. 
It is a commercial module, made by me, for the Community Bootstrap Version.
If of interest, PM me.  


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest Responsive osCommerce CE (community edition) here

Share this post


Link to post
Share on other sites

small bugfix for "stort times" replace the following code in header tags to disable forwarding when the module is deactivated

catalog/includes/modules/header_tags/ht_store_times.php

osCommerce 2.3.4-1 EDGE

find:

      if (defined('MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES') && MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES == 'True') {
        if (tep_not_null(MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES)) {
          $pages_array = array();

          foreach (explode(';', MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES) as $page) {
            $page = trim($page);

            if (!empty($page)) {
              $pages_array[] = $page;
            }
          }
        
          if (in_array(basename($PHP_SELF), $pages_array)) {
		        $store_status = sew_is_store_open();
            if ($store_status <> 'open' && $store_status <> 'open-override') tep_redirect('store_times.php');
          }
        }
      }
		}

replace with:

if (MODULE_CONTENT_HEADER_STORE_TIMES_STATUS == 'True') {
      if (defined('MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES') && MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES == 'True') {
        if (tep_not_null(MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES)) {
          $pages_array = array();

          foreach (explode(';', MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES) as $page) {
            $page = trim($page);

            if (!empty($page)) {
              $pages_array[] = $page;
            }
          }
        
          if (in_array(basename($PHP_SELF), $pages_array)) {
		        $store_status = sew_is_store_open();
            if ($store_status <> 'open' && $store_status <> 'open-override') tep_redirect('store_times.php');
          }
        }
      }
		}
}

Thus, the header_tag module does not need to be turned off

Edited by YePix

Share this post


Link to post
Share on other sites

Nothing better on the net:
https://freek.dev/595-managing-opening-hours-with-php

Requires composer: https://github.com/spatie/opening-hours ( based on above link)


- ICECAT specialist.
(Icecat: open feed with product information, data-sheets for oscommerce.)
- CSV IMPORT specialist.
(manage your suppliers via supplier manager)
Contact me via PM.

Share this post


Link to post
Share on other sites
1 hour ago, YePix said:

small bugfix for "stort times" replace the following code in header tags to disable forwarding when the module is deactivated

catalog/includes/modules/header_tags/ht_store_times.php

osCommerce 2.3.4-1 EDGE

find:


      if (defined('MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES') && MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES == 'True') {
        if (tep_not_null(MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES)) {
          $pages_array = array();

          foreach (explode(';', MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES) as $page) {
            $page = trim($page);

            if (!empty($page)) {
              $pages_array[] = $page;
            }
          }
        
          if (in_array(basename($PHP_SELF), $pages_array)) {
		        $store_status = sew_is_store_open();
            if ($store_status <> 'open' && $store_status <> 'open-override') tep_redirect('store_times.php');
          }
        }
      }
		}

replace with:


if (MODULE_CONTENT_HEADER_STORE_TIMES_STATUS == 'True') {
      if (defined('MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES') && MOD_CON_HDR_STORE_TIMES_DIVERT_PAGES == 'True') {
        if (tep_not_null(MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES)) {
          $pages_array = array();

          foreach (explode(';', MOD_CON_HDR_STORE_TIMES_CLOSE_PAGES) as $page) {
            $page = trim($page);

            if (!empty($page)) {
              $pages_array[] = $page;
            }
          }
        
          if (in_array(basename($PHP_SELF), $pages_array)) {
		        $store_status = sew_is_store_open();
            if ($store_status <> 'open' && $store_status <> 'open-override') tep_redirect('store_times.php');
          }
        }
      }
		}
}

Thus, the header_tag module does not need to be turned off

you could have just say what is wrong.
I cannot see with a "look for" and "replace" with........... what is the actual bug?
I prefer to see compare A with B and highlight the difference.
I not learn anything from "replace with"


- ICECAT specialist.
(Icecat: open feed with product information, data-sheets for oscommerce.)
- CSV IMPORT specialist.
(manage your suppliers via supplier manager)
Contact me via PM.

Share this post


Link to post
Share on other sites

Found it:
 

if (MODULE_CONTENT_HEADER_STORE_TIMES_STATUS == 'True') {
	#put what i told to look for in here

}

Now we know what you did, and can be traced in some way.

Edited by fridgebox

- ICECAT specialist.
(Icecat: open feed with product information, data-sheets for oscommerce.)
- CSV IMPORT specialist.
(manage your suppliers via supplier manager)
Contact me via PM.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×