Skip to content

Commit

Permalink
Featured/Specials, save dates when 'today' (zencart#6030)
Browse files Browse the repository at this point in the history
  • Loading branch information
lat9 authored and drbyte committed Jan 30, 2024
1 parent 4522579 commit fb9db49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions admin/featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
$featured_date_available_raw = $dt->format('Y-m-d');
}
}
$featured_date_available = (date('Y-m-d') < $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';
$featured_date_available = (date('Y-m-d') <= $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';

$expires_date_raw = zen_db_prepare_input($_POST['expires_date']);
if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($expires_date_raw)) {
$local_fmt = zen_datepicker_format_fordate();
Expand All @@ -52,7 +53,7 @@
$expires_date_raw = $dt->format('Y-m-d');
}
}
$expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';
$expires_date = (date('Y-m-d') <= $expires_date_raw) ? $expires_date_raw : '0001-01-01';

$db->Execute("INSERT INTO " . TABLE_FEATURED . " (products_id, featured_date_added, expires_date, status, featured_date_available)
VALUES (" . (int)$products_id . ", now(), '" . zen_db_input($expires_date) . "', 1, '" . zen_db_input($featured_date_available) . "')");
Expand All @@ -79,7 +80,8 @@
$featured_date_available_raw = $dt->format('Y-m-d');
}
}
$featured_date_available = (date('Y-m-d') < $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';
$featured_date_available = (date('Y-m-d') <= $featured_date_available_raw) ? $featured_date_available_raw : '0001-01-01';

$expires_date_raw = zen_db_prepare_input($_POST['expires_date']);
if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($expires_date_raw)) {
$local_fmt = zen_datepicker_format_fordate();
Expand All @@ -89,7 +91,7 @@
$expires_date_raw = $dt->format('Y-m-d');
}
}
$expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';
$expires_date = (date('Y-m-d') <= $expires_date_raw) ? $expires_date_raw : '0001-01-01';

$db->Execute("UPDATE " . TABLE_FEATURED . "
SET featured_last_modified = now(),
Expand Down
10 changes: 6 additions & 4 deletions admin/specials.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
$specials_date_available_raw = $dt->format('Y-m-d');
}
}
$specials_date_available = (date('Y-m-d') < $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';
$specials_date_available = (date('Y-m-d') <= $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';

$expires_date_raw = zen_db_prepare_input($_POST['expires_date']);
if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($expires_date_raw)) {
$local_fmt = zen_datepicker_format_fordate();
Expand All @@ -76,7 +77,7 @@
$expires_date_raw = $dt->format('Y-m-d');
}
}
$expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';
$expires_date = (date('Y-m-d') <= $expires_date_raw) ? $expires_date_raw : '0001-01-01';

$db->Execute("INSERT INTO " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status, specials_date_available)
VALUES (" . (int)$products_id . ", " . (float)$specials_price . ", now(), '" . zen_db_input($expires_date) . "', 1, '" . zen_db_input($specials_date_available) . "')");
Expand Down Expand Up @@ -119,7 +120,8 @@
$specials_date_available_raw = $dt->format('Y-m-d');
}
}
$specials_date_available = (date('Y-m-d') < $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';
$specials_date_available = (date('Y-m-d') <= $specials_date_available_raw) ? $specials_date_available_raw : '0001-01-01';

$expires_date_raw = zen_db_prepare_input($_POST['expires_date']);
if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($expires_date_raw)) {
$local_fmt = zen_datepicker_format_fordate();
Expand All @@ -129,7 +131,7 @@
$expires_date_raw = $dt->format('Y-m-d');
}
}
$expires_date = (date('Y-m-d') < $expires_date_raw) ? $expires_date_raw : '0001-01-01';
$expires_date = (date('Y-m-d') <= $expires_date_raw) ? $expires_date_raw : '0001-01-01';

$db->Execute("UPDATE " . TABLE_SPECIALS . "
SET specials_new_products_price = '" . zen_db_input($specials_price) . "',
Expand Down

0 comments on commit fb9db49

Please sign in to comment.