News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Problem with dates for multiple prices

Started by sandomatyas, June 12, 2019, 16:46:02 PM

Previous topic - Next topic

sandomatyas

I already asked about this 4 years back back here I am again :)

I run a site which uses CEST timezone, so we have UTC +2
When I try to set a time-limited price and select today as publish_up and tomorrow as publish_down date for it, VM stores 2019-06-12 00:00:00 and 2019-06-13 00:00:00 in #__virtuemart_product_prices table.
But when you check loadProductPrices method in VirtueMartModelProduct, there is `product_price_publish_down` >= "' .$db->escape($this->_now) . '" where $this->_now is  JFactory::getDate()->toSQL() which is UTC
So this price will be deactivated at 2AM tomorrow because at local midnight will be 10PM in UTC

What do you suggest, which is the correct way to use the real timezone but have the correct price publish up/down times?

Milbo

thank you for the bug report.

in the product model, function loadProductPrices use this


if(!isset($this->_now)){

$config = JFactory::getConfig();
$siteOffset = $config->get('offset');
$siteTimezone = new DateTimeZone($siteOffset);

$jnow = JFactory::getDate();
$date = new JDate($jnow);
$date->setTimezone($siteTimezone);
$this->_now = $date->format('Y-m-d H:i:s',true);

//vmdebug('my timezone ',$this->_now);
}


for the if(!isset($this->_now)){
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/