Okay, I did it. If someone curious how, I'll explain it.
First an advice!
Create the following directories on your server
templates/"your_template"/html/com_virtuemart/category/
templates/"your_template"/html/com_virtuemart/productdetails/
Upload the following files to the right directories, after you edited them
components/com_virtuemart/views/category/tmpl/ default.php
components/com_virtuemart/views/productdetails/tmpl/ default.php
If something wrong, just delete the files, from the templates dir.
Okay, so open
components/com_virtuemart/views/category/tmpl/default.php
Search this line (around 370 to me)
Quote// Product Details Button
echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
And copy/paste the following code after that:
Quote//read the calc rule id based on product id
$db = JFactory::getDbo();
$query = 'SELECT `product_discount_id`'
. ' FROM `#__virtuemart_product_prices` '
. ' WHERE `virtuemart_product_id` = "'.$product->virtuemart_product_id.'" ';
$db->setQuery($query);
//rule's id
$discount_id = $db->loadResult();
//read start date, based on the rule's id
$query = 'SELECT `publish_up`'
. ' FROM `#__virtuemart_calcs` '
. ' WHERE `virtuemart_calc_id` = "'.$discount_id.'" ';
$db->setQuery($query);
$discountstart = $db->loadResult();
//read end date, based on the rule's id
$query = 'SELECT `publish_down`'
. ' FROM `#__virtuemart_calcs` '
. ' WHERE `virtuemart_calc_id` = "'.$discount_id.'" ';
$db->setQuery($query);
$discountend = $db->loadResult();
//echo discount date, if there is a discount amount
if($product->prices['discountAmount'])
{
if($discountstart && $discountend){echo "From".$discountstart." to ".$discountend;}
else{echo "While stock last";}
}
Now open
components/com_virtuemart/views/productdetails/tmpl/ default.php
Search this line (around 190 to me)
Quote// Product Price
if ($this->show_prices and (empty($this->product->images[0]) or $this->product->images[0]->file_is_downloadable == 0)) {
echo $this->loadTemplate('showprices');
And copy/paste the following code after that:
//read the calc rule id based on product id
$db = JFactory::getDbo();
$query = 'SELECT `product_discount_id`'
. ' FROM `#__virtuemart_product_prices` '
. ' WHERE `virtuemart_product_id` = "'.$this->product->virtuemart_product_id.'" ';
$db->setQuery($query);
//rule's id
$discount_id = $db->loadResult();
//read start date, based on the rule's id
$query = 'SELECT `publish_up`'
. ' FROM `#__virtuemart_calcs` '
. ' WHERE `virtuemart_calc_id` = "'.$discount_id.'" ';
$db->setQuery($query);
$discountstart = $db->loadResult();
//read end date, based on the rule's id
$query = 'SELECT `publish_down`'
. ' FROM `#__virtuemart_calcs` '
. ' WHERE `virtuemart_calc_id` = "'.$discount_id.'" ';
$db->setQuery($query);
$discountend = $db->loadResult();
//echo discount date, if there is a discount amount
if($this->product->prices['discountAmount'])
{
if($discountstart && $discountend){echo "From".$discountstart." to ".$discountend;}
else{echo "While stock last";}
}
You can create the discount rules and set the dates in
joomla admin->compontents->virtuemart->Taxes & Calculation Rules->New
I gave the name, checked publish, chose Price mod. Before tax., value empty, both of visible yes, and gave the dates. SAVE
Then Products->Select which you want->roll down to Pricing rules overrides → Discount type-> your given name. SAVE
And this is how I update the product price override to '0', if the discount date ends.
Put this to
Quote{echo "From".$discountstart." to ".$discountend; *here* }
Quote//Comparing dates...
$exp_date = $akcioend;
$mai_datum = date("Y-m-d");
$ma = strtotime($mai_datum);
$akcio_vege = strtotime($exp_date);
if ($akcio_vege < $ma) {
$valid = "Discount cancelled!";
//...and set override 1->0 if discount end date < today
$db =& JFactory::getDBO();
$query = "UPDATE `joomla`.`#__virtuemart_product_prices`
SET `override` = '0'
WHERE `#__virtuemart_product_prices`.`virtuemart_product_id` =".$product->virtuemart_product_id."";
$db->setQuery($query);
$db->query();
}
echo $valid;