Forums / Bug Reports / Featured/Special Products Active From date cant be today

Featured/Special Products Active From date cant be today

Views: 974

Results 1 to 8 of 8
29 Oct 2023, 1:55 PM
#1
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Featured/Special Products Active From date cant be today

https://dev.pezcollectors.com/blank
ZC1.5.8
Only display logs plugin
PHP 8.1.24
MariaDB 10.6.15

When adding a new special or featured product, or editing an existing one, the active from aka featured_date_available does not take UNLESS it's a future date. If you select today or in the past, it uses the default of 0001-01-01

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

29 Oct 2023, 2:49 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: Featured/Special Products Active From date cant be today

gothstone:

https://dev.pezcollectors.com/blank
ZC1.5.8
Only display logs plugin
PHP 8.1.24
MariaDB 10.6.15

When adding a new special or featured product, or editing an existing one, the active from aka featured_date_available does not take UNLESS it's a future date. If you select today or in the past, it uses the default of 0001-01-01
That's expected behavior for dates in the past, but a featured/special product starting "today" *should *be accepted and recorded.

For the /admin/featured.php, find the statements (2 each) that currently read

      $featured_date_available = (date('Y-m-d') < $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';

      $expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';

and change to

      $featured_date_available = (date('Y-m-d') <[B]=[/B] $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';

      $expires_date = (date('Y-m-d') <[B]=[/B] $expires_date_raw) ? $expires_date_raw : '0001-01-01';

Similarly, for the /admin/specials.php, find the statements (2 each) that currently read

      $specials_date_available = (date('Y-m-d') < $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';

      $expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';

and change to

      $specials_date_available = (date('Y-m-d') <[B]=[/B] $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';

      $expires_date = (date('Y-m-d') <[B]=[/B] $expires_date_raw) ? $expires_date_raw : '0001-01-01';
29 Oct 2023, 2:57 PM
#3
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Re: Featured/Special Products Active From date cant be today

Thank you lat9!

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

29 Oct 2023, 3:47 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: Featured/Special Products Active From date cant be today

You're very welcome. See this GitHub PR for resolution: https://github.com/zencart/zencart/pull/6030

30 Oct 2023, 1:49 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Featured/Special Products Active From date cant be today

lat9:

That's expected behavior for dates in the past, but a featured/special product starting "today" *should *be accepted and recorded.

For the /admin/featured.php, find the statements (2 each) that currently read

  $featured_date_available = (date('Y-m-d') < $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';

  $expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';
> and change to
> ```
      $featured_date_available = (date('Y-m-d') <[B]=[/B] $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';

      $expires_date = (date('Y-m-d') <[B]=[/B] $expires_date_raw) ? $expires_date_raw : '0001-01-01';

Similarly, for the /admin/specials.php, find the statements (2 each) that currently read

  $specials_date_available = (date('Y-m-d') < $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';

  $expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';
> and change to
> ```
      $specials_date_available = (date('Y-m-d') <[B]=[/B] $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';

      $expires_date = (date('Y-m-d') <[B]=[/B] $expires_date_raw) ? $expires_date_raw : '0001-01-01';

So what about a product itself becoming available today? It too has suffered the same issue as you yourself have previously found out and reported on github.

Technically, today has already passed from a date only record, so what extra benefit is there in making this change?
Why not allow entry of any date, whether current, future or past? Would it not then get "accepted and recorded" as previously stated?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

30 Oct 2023, 12:01 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: Featured/Special Products Active From date cant be today

mc12345678:

So what about a product itself becoming available today? It too has suffered the same issue as you yourself have previously found out and reported on github.

Technically, today has already passed from a date only record, so what extra benefit is there in making this change?
Why not allow entry of any date, whether current, future or past? Would it not then get "accepted and recorded" as previously stated?
See the Zen Cart documentation on the features:

https://docs.zen-cart.com/user/products/start_end_dates/
https://docs.zen-cart.com/user/products/product_edit/
https://docs.zen-cart.com/user/products/upcoming_products/

5 Nov 2023, 4:54 AM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Featured/Special Products Active From date cant be today

lat9:

See the Zen Cart documentation on the features:

https://docs.zen-cart.com/user/products/start_end_dates/
https://docs.zen-cart.com/user/products/product_edit/
https://docs.zen-cart.com/user/products/upcoming_products/

I forgot how much had been changed about this coding and processing of dates. For example, if in update or creation of either of these, the end date is in the past (supposed to remain off) then the item gets stored to remain on indefinitely.... yup, that checks with all of those instructions, sure.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

5 Nov 2023, 12:39 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,114
Plugin Contributions:
56

Re: Featured/Special Products Active From date cant be today

mc12345678:

I forgot how much had been changed about this coding and processing of dates. For example, if in update or creation of either of these, the end date is in the past (supposed to remain off) then the item gets stored to remain on indefinitely.... yup, that checks with all of those instructions, sure.
Thanks for the bug report; the sarcasm was not necessary.