Page 1 of 1
specials, discounts, coupons ending start of end date ???
Posted: Fri Jul 10, 2015 4:14 pm
by GoldenTongs
wonder if anyone else has this, or a fix or reason why i am getting (OC2.0.3.1)
firstly i have already checked time etc. OC is set to Europe/London.
(server is located GMT+3)
problem is, special, discounts and coupons
are ending at the start of the end date instead of the end (midnight) of the end date
i have also checked it on fresh test install
if a special or coupon is set to end on 30th, it ends on midnight 29th
(ends as soon as it is the 30th)
i have extensions that display offer end dates and coupon end dates,
but customers are complaining they cannot use coupon on last day or offer ended a day earlier than advertised.
i assume
admin/controller/catalog/product.php
Code: Select all
if (($product_special['date_start'] == '0000-00-00' || strtotime($product_special['date_start']) < time()) && ($product_special['date_end'] == '0000-00-00' || strtotime($product_special['date_end']) > time())) {
would apply to specials end date, but i cannot find a fix
does anyone else have this issue, or have a reason why or a fix ?
Re: specials, discounts, coupons ending start of end date ??
Posted: Fri Jul 10, 2015 11:29 pm
by fido-x
The problem results from a "digital" time issue. In human (and "analog") terms, midnight is 24:00:00, however, "digital" time works differently.
One second before midnight would be 23:59:59. The clock ticks over one second and the "digital" time zeroes everything and shows midnight as 00:00:00. Subsequently, specials, discounts and coupons end a day earlier than they are supposed to.
The only way around it is to set the end date a day later.
Re: specials, discounts, coupons ending start of end date ??
Posted: Fri Jul 10, 2015 11:41 pm
by GoldenTongs
yes i am setting the end date a day later as temp fix
but issue is when customer gets a promo coupon stating the end date they expect to use it on that end date
(this is how i was made aware)
same as if you advertise special price end date as 30th, customers expect it to end the end of 30th
i have an extension that sends out promo coupons, and it sets the days valid, and sends email with end date, but obviously this is now wrong, as the coupon expires when end date starts, also same with your lovely special ends extension, it displays the end date but by then the promotion has ended
and the general norm is if something is advertised on sale from the 1st till the 10th,
you have until end of the day on the 10th to purchase at sale price
is there no way to insert time into code above (i did try but got nowhere) like 23:59 so end date will end correctly ?
Re: specials, discounts, coupons ending start of end date ??
Posted: Fri Jul 10, 2015 11:57 pm
by fido-x
GoldenTongs wrote:.. if you advertise special price end date as 30th, customers expect it to end the end of 30th
Agreed.
I would suggest that the database query needs to be looked at, so that instead of checking if the end date is greater than "NOW()", it uses "NOW() + 1day".
Re: specials, discounts, coupons ending start of end date ???
Posted: Mon Oct 09, 2023 3:12 pm
by imdevlper18
This is old problem. But the issue is still present. I have added a fix and it works well.
In this file:
catalog/model/extension/total/coupon.php
Find:
Code: Select all
$coupon_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon` WHERE code = '" . $this->db->escape($code) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND status = '1'");
Replace with:
Code: Select all
$coupon_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon` WHERE code = '" . $this->db->escape($code) . "' AND ((date_start = '0000-00-00' OR date_start <= '".date("Y-m-d")."') AND (date_end = '0000-00-00' OR date_end >= '".date("Y-m-d")."')) AND status = '1'");
Click refresh modification on the admin side. Should start working.
Import Coupons In Bulk Plus Automatic coupon creator with search filters. View extension. Best-selling coupon import extension.
Re: specials, discounts, coupons ending start of end date ???
Posted: Mon Oct 09, 2023 11:53 pm
by halfhope
Hi!
Also you can just change type of date_start/date_end columns from date to datetime.