Forums / General Questions / Make download available by time

Make download available by time

Locked

Views: 654

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
13 Mar 2010, 3:50 AM
#1
chrismarie avatar

chrismarie

New Zenner

Join Date:
Apr 2009
Location:
Chicago, IL
Posts:
45
Plugin Contributions:
0

Make download available by time

Hi y'all
I'd like to prevent a download from being available until midnight of the day that it's purchased - I know it's a random request, but any thoughts about where to start? I don't know a ton about php datetime controls, but since midnight of the purchase date is technically the beginning of the next day, I basically need to say that if it's the purchase date + 1 or later, the download is available.

Thanks for your time!
I'm Running v.1.3.8a btw

13 Mar 2010, 7:00 PM
#2
chrismarie avatar

chrismarie

New Zenner

Join Date:
Apr 2009
Location:
Chicago, IL
Posts:
45
Plugin Contributions:
0

Re: Make download available by time

Got it! For anybody wanting to implement this on your shop, I edited the tpl_modules_downloads.php file in includes/templates/my template/templates and added:

<?php
$purchase_date = $downloads->fields['date_purchased_day'] ;
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$available_date = strtotime($purchase_date.'+ 1 day'); 
?>

and then served up the download link with an if else statement like so

<?php if ($available_date <= $today) { ?>
<?php echo '<a href="' . zen_href_link(FILENAME_COUPON,'order=' . $downloads->fields['orders_products_download_id'] . '&id=' . $i, NONSSL) . '">' . zen_image_button(BUTTON_IMAGE_DOWNLOAD, BUTTON_DOWNLOAD_ALT) . '</a>' ;?>
<?php
 } else { DOWNLOADS_CONTROLLER_ON_HOLD_MSG } ?>