News:

Looking for documentation? Take a look on our wiki

Main Menu

Displaying today date + 1 year in a custom field

Started by Malex, September 15, 2016, 16:55:12 PM

Previous topic - Next topic

Malex

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 ?

PRO

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.

Malex