VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Malex on September 15, 2016, 16:55:12 PM

Title: Displaying today date + 1 year in a custom field
Post by: Malex on September 15, 2016, 16:55:12 PM
Hello,
i need to add a storable custom field on all my product pages just displaying today date + one year
like :
<?php
date_default_timezone_set
('UTC');
$date=date("d-m-Y"strtotime("+1 year"));
?>

<input name="expiration-date" class="expiration" readonly="readonly" style="cursor: text" value="<?php echo $date?>">


do anyone have an idea how to do ?
Title: Re: Displaying today date + 1 year in a custom field
Post by: PRO on September 15, 2016, 22:37:06 PM
so you need it added to cart right? and not editable?

so for warranty display or something right?

create a plugin.

then in this function, just change the value="1"    to your date

   function plgVmOnDisplayProductFEVM3(&$product,&$group) {

      if ($group->custom_element != $this->_name) return '';
      $group->display = '<input type="hidden" name="customProductData['.$product->virtuemart_product_id.']['.$group->virtuemart_custom_id.']['.$group->virtuemart_customfield_id.'][hidden]" value="1" />';
return true;
   }


if you can code a little, what I would do it  copy the dropbox plugin, or some other cart variant plugin, and change the code & names etc.
Title: Re: Displaying today date + 1 year in a custom field
Post by: Malex on September 16, 2016, 08:16:57 AM
Thank's for your answer, i'll try to do this