Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[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.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
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
Link to comment
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

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

  • 1 month later...

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

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

  • 2 weeks later...

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

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

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

  • 5 months later...

@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.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
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)?????

Link to comment
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

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
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

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
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.

 

Link to comment
Share on other sites

  • 5 months later...

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

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
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.  

Link to comment
Share on other sites

  • 1 year later...

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
Link to comment
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"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...