Jump to content

How to highlighting coupons with a Prestashop that is in a different timezone than the MYSQL server


Florian_29298
 Share

Recommended Posts

Hello everyone !

I have a problem that I have been unable to solve for several weeks with time zone.

My server configuration :

  • Prestashop is configured with Paris time zone.
  • Debian server which hosts my PHP and MYSQL is configured with London time zone.
  • PHP and MYSQL are configured with the London time zone.

When a coupon is automatically generated, its validity start date at the present time of Paris.

However, this coupon is not highlighted (in checkout page) on Prestashop because since Prestashop 1.7.4, the highlighting function retrieves all coupons between the present time of the MYSQL server (with NOW() function) and the end of the day.

Highlighted function in Prestashop < 1.7.4 in /classes/CartRule.php:384 :

$sql_part2 = ' AND cr.date_from < "' . date('Y-m-d H:i:59') . '"
				AND cr.date_to > "' . date('Y-m-d H:i:59') . '"
				' . ($active ? 'AND cr.`active` = 1' : '') . '
				' . ($inStock ? 'AND cr.`quantity` > 0' : '');

Highlighted function in Prestashop > 1.7.4 :

$sql_part2 = ' AND NOW() BETWEEN cr.date_from AND cr.date_to
				' . ($active ? 'AND cr.`active` = 1' : '') . '
				' . ($inStock ? 'AND cr.`quantity` > 0' : '');

So there is obviously a time difference, but if my Prestashop was configured with the California time zone, the time difference would be even greater.

What should I do? Override the function? Configure my SQL server to be the same time zone as my Prestashop?

Thank you in advance !

Edited by Florian_29298 (see edit history)

Share this post


Link to post
Share on other sites

8 minutes ago, joseantgv said:

Setting the same time zone in both sides should fix this issue and, from my point of view, the best solution.

Why would you want to keep a different time zone?

Hello.

Thank you for your answer 🙂 .

If my MySQL server is in the same timezone of my Prestashop, the problem is solved.

But, what if I have a second (or more) Prestashop, on the same MySQL server but in a different database, I will have this problem.

Indeed, to my knowledge, it is only possible to define a timezone on a whole MySQL server and not only in a database.

Edited by Florian_29298 (see edit history)

Share this post


Link to post
Share on other sites

1 minute ago, Florian_29298 said:

Hello.

Thank you for your answer.

If my MySQL server is in the same timezone of my Prestashop, the problem is solved.

But, what if I have a second (or more) Prestashop, on the same MySQL server but in a different database, I will have this problem.

Indeed, to my knowledge, it is only possible to define a timezone on a whole MySQL server and not only in a database.

Another problem, if I can't change the timezone of my MySQL server because my host doesn't allow me to do?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More