Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

You'll all hate me for this but...


Guest

Recommended Posts

Posted

Ok here it is... It's a problem related to downloads

 

 

Still Here? Thanks for sticking with me then!

 

I am using OSC 2.76c MS2 with no other contribs except Easy Populate.

 

The problem I experience is once a customer selects a file to purchase by download, they go through the payment process and are returned to my site where they get the usual page with the option to select the Update Notification and then below that is the link to the file they just paid for.

 

Now this link seems to work fine in all the scenarios I've tried. But if I decide NOT to click on that download link and instead wander off around the store then decide to return to "My Account" to download the file from the order information page, I run into trouble.

 

At the bottom of the Order Information page under the order history information is the box for the Download Links, The title of the file shows up (shown below) along with the link expiration date and number of remaining downloads. All very good except for the first bit. The file title should show up as a clickable link. But it does not. It's just some text that does nothing.

A downloadable product Test Item Link expires: Friday, 25. August 2006 3 downloads remaining

 

(Current date is 23-Aug-06)

 

I have the relevant file sat in the download directory, I configured the settings for download in the Admin panel under Configuration/Download as follows:

Enable download true

Download by redirect false

Expiry delay (days) 2

Maximum number of downloads 3

 

I am able to download this file with no problems as long as I do so immediately after being returned to my store from the PayPal payment pages. But if I go to My Account and look under the Order Information pages, the link is not available though the correct information shows up - just no link.

 

I had a look in the catalog/includes/modules/downloads.php file and (despite the fact I don't know what I would be looking for) everything looked ok.

 

 

<?php

/*

$Id: downloads.php,v 1.3 2003/06/09 22:49:58 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

?>

<!-- downloads //-->

<?php

if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {

// Get last order id for checkout_success

$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by orders_id desc limit 1");

$orders = tep_db_fetch_array($orders_query);

$last_order = $orders['orders_id'];

} else {

$last_order = $HTTP_GET_VARS['order_id'];

}

 

// Now get all downloadable products in that order

$downloads_query = tep_db_query("select date_format(o.date_purchased, '%Y-%m-%d') as date_purchased_day, opd.download_maxdays, op.products_name, opd.orders_products_download_id, opd.orders_products_filename, opd.download_count, opd.download_maxdays from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = '" . (int)$last_order . "' and o.orders_id = op.orders_id and op.orders_products_id = opd.orders_products_id and opd.orders_products_filename != ''");

if (tep_db_num_rows($downloads_query) > 0) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="main"><b><?php echo HEADING_DOWNLOAD; ?></b></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<!-- list of products -->

<?php

while ($downloads = tep_db_fetch_array($downloads_query)) {

// MySQL 3.22 does not have INTERVAL

list($dt_year, $dt_month, $dt_day) = explode('-', $downloads['date_purchased_day']);

$download_timestamp = mktime(23, 59, 59, $dt_month, $dt_day + $downloads['download_maxdays'], $dt_year);

$download_expiry = date('Y-m-d H:i:s', $download_timestamp);

?>

<tr class="infoBoxContents">

<!-- left box -->

<?php

// The link will appear only if:

// - Download remaining count is > 0, AND

// - The file is present in the DOWNLOAD directory, AND EITHER

// - No expiry date is enforced (maxdays == 0), OR

// - The expiry date is not reached

if ( ($downloads['download_count'] > 0) && (file_exists(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])) && ( ($downloads['download_maxdays'] == 0) || ($download_timestamp > time())) ) {

echo ' <td class="main"><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '</a></td>' . "\n";

} else {

echo ' <td class="main">' . $downloads['products_name'] . '</td>' . "\n";

}

?>

<!-- right box -->

<?php

echo ' <td class="main">' . TABLE_HEADING_DOWNLOAD_DATE . tep_date_long($download_expiry) . '</td>' . "\n" .

' <td class="main" align="right">' . $downloads['download_count'] . TABLE_HEADING_DOWNLOAD_COUNT . '</td>' . "\n" .

' </tr>' . "\n";

}

?>

</tr>

</table></td>

</tr>

<?php

if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="smalltext" colspan="4"><p><?php printf(FOOTER_DOWNLOAD, '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . HEADER_TITLE_MY_ACCOUNT . '</a>'); ?></p></td>

</tr>

<?php

}

}

?>

<!-- downloads_eof //-->

 

Is there any of you good people out there who may be able to help me with this little problem.

 

I've been tearing my hair out over other issues which so far all you forum contributors have been able to help me with either directly or via other peoples questions. I am still very new to OSC but would like to thank all those who post responses to questions (not just mine) as without you folks, all us newbies would be stumpped out of existance and end up paying someone to create our shops for us.

 

So once again, thanks in anticipation of your help.

  • 5 months later...
Posted

Hi Mike,

did you ever got an answer for this?

I've something simular in diff situation when customers don't succeed download then go back, or when I update their link when download has expired.

thanks in advance

 

 

Danny

Posted

Not positive about this but in the code it tells you at the top if I am reading it right

// The link will appear only if:

// - Download remaining count is > 0, AND

// - The file is present in the DOWNLOAD directory, AND EITHER

// - No expiry date is enforced (maxdays == 0), OR

// - The expiry date is not reached

So the way I read it is that you can only use maxdays or max downloads not both. Turn one of them off and see if it works.
Enable download true

Download by redirect false

Expiry delay (days) 2

Maximum number of downloads 3

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...