Post by GoldenTongs » Fri Jul 10, 2015 4:14 pm

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 ?

http://Lilphones.com
Image


Active Member

Posts

Joined
Sun Jul 29, 2012 5:26 pm

Post by fido-x » Fri Jul 10, 2015 11:29 pm

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.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by GoldenTongs » Fri Jul 10, 2015 11:41 pm

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 ?

http://Lilphones.com
Image


Active Member

Posts

Joined
Sun Jul 29, 2012 5:26 pm

Post by fido-x » Fri Jul 10, 2015 11:57 pm

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

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by imdevlper18 » Mon Oct 09, 2023 3:12 pm

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.

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by halfhope » Mon Oct 09, 2023 11:53 pm

Hi!

Also you can just change type of date_start/date_end columns from date to datetime.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego
Who is online

Users browsing this forum: No registered users and 12 guests