Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Downloads controller physical and virutal in cart...


sfergus

Recommended Posts

I've done extensive searching of the forums and I can't find the solution to this. My store sells both virutal and physical goods. If both types are in the cart, after checkout the customer will see download links for physical goods. This is clearly not supposed to happen. Here's a screenshot of what is occuring:

 

dlproblem2.jpg

 

The only thing that should have a link is CAM Skin Intensive Matters. Another odd problem is that an extra link is being generated for the virtual goods.

 

I'm using Downloads Controller v5.3 and Paypal Website Payments Pro v7.3.

 

My store is www.gloriagillbere.com/OsCommerce. If you go there, please be gentle and ignore the image quality (I'm getting better ones soon).

 

I suspect the solution to this problem lies in the downloads.php file, but I lack the php knowledge to figure it out.

The contents of my downloads.php file:

 

<?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 (c) 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
// BOF: WebMakers.com Added: Downloads Controller
// DEFINE WHICH ORDERS_STATUS TO USE IN downloads_controller.php
// USE last_modified instead of date_purchased
// original  $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 != ''");
		 $downloads_query = tep_db_query("select o.orders_status, date_format(o.last_modified, '%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_status >= '" . DOWNLOADS_CONTROLLER_ORDERS_STATUS . "' 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())) ) {
// WebMakers.com Added: Downloads Controller Show Button
// original MS1		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";
	echo '			<td class="main" align="center"><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '<br>' . tep_image_button('button_download.gif', '') . '</a></td>' . "\n";
  } else {
	echo '			<td class="main">' . $downloads['products_name'] . '</td>' . "\n";
  }
?>
<!-- right box -->
<?php
// BOF: WebMakers.com Added: Downloads Controller
  echo '			<td class="main">' . TABLE_HEADING_DOWNLOAD_DATE . '<br>' . tep_date_long($download_expiry) . '</td>' . "\n" .
	   '			<td class="main" align="right">' . $downloads['download_count'] . TABLE_HEADING_DOWNLOAD_COUNT . '</td>' . "\n" .
	   '		  </tr>' . "\n";
// EOF: WebMakers.com Added: Downloads Controller
}
?>
	  </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
}
 }
?>
<?php
// BOF: WebMakers.com Added: Downloads Controller
// If there is a download in the order and they cannot get it, tell customer about download rules
 $downloads_check_query = tep_db_query("select o.orders_id, opd.orders_products_download_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.orders_id = opd.orders_id and o.orders_id = '" . (int)$last_order . "' and opd.orders_products_filename != ''");

if (tep_db_num_rows($downloads_check_query) > 0 and tep_db_num_rows($downloads_query) < 1) {
// if (tep_db_num_rows($downloads_query) < 1) {
?>
  <tr>
	<td colspan="3" align="center" valign="top" class="main" height="30"><FONT FACE="Arial" SIZE=1 COLOR="FF000"><?php echo DOWNLOADS_CONTROLLER_ON_HOLD_MSG ?></FONT></td>
  </tr>
<?php
}
// EOF: WebMakers.com Added: Downloads Controller
?>
<!-- downloads_eof //-->

Link to comment
Share on other sites

I've done some more looking, and I wonder if the download.php file is also being used, in addition to the downloads.php file. Perhaps this is where the extra links are coming from. Or maybe the Downloads Controller is somehow adding the download product attribute to the physical items in the cart. Does anyone have any ideas for what I can do?

Link to comment
Share on other sites

:D Nevermind! I fixed it. Turns out it was the Add Weight to Product Attributes v0.2 contribution. I uninstalled that and removed the field from the database, and the download works fine now. That contribution seemed buggy anyway; it never really calculated the weight correctly for multiple orders of the same product.

 

Now I just need to find another way to make the same product have different weight options. But I'm happy. The downloads are a much bigger part of my sales. :thumbsup:

Link to comment
Share on other sites

:D Nevermind! I fixed it. Turns out it was the Add Weight to Product Attributes v0.2 contribution. I uninstalled that and removed the field from the database, and the download works fine now. That contribution seemed buggy anyway; it never really calculated the weight correctly for multiple orders of the same product.

 

Now I just need to find another way to make the same product have different weight options. But I'm happy. The downloads are a much bigger part of my sales. :thumbsup:

 

Hi sfergus,

I'm new to osCommerce and am having problems getting downloads working. Is there a step by step guide anywhere that shows how to get an out of the box installation of osCommerce working so that it only supports downloadable content?

 

Can you shed any light on your experiences?

Link to comment
Share on other sites

Here is my file if you want to compare:

 

 

<?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 = $_GET['order_id'];

}

 

// Admin Config Note:

// The redirect method is not good because the redirect link can easily be captured and given away with unlimited use until someone else places an order and the old links get deleted. Also I think download links currently in use can get deleted if more than one person is downloading at a time. On the other hand the direct download always requires a store login before downloading.

 

// Now get all downloadable products in that order

// BOF: WebMakers.com Added: Downloads Controller

// DEFINE WHICH ORDERS_STATUS TO USE IN downloads_controller.php

// USE last_modified instead of date_purchased

// original $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 != ''");

$downloads_query = tep_db_query("select o.orders_status, date_format(o.last_modified, '%Y-%m-%d') as date_purchased_day, o.orders_id, 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 = '" . $last_order . "' and o.orders_status >= '2' 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="1" 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

// START Pending Order Downloads v2.10

// Language-independent version of Jeff Thornton's Patch by Matthias C. Hormann 2004-11-23

// The link will appear only if:

// - Order status is 'Processed' or above ('Delivered')

// - 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) && ($order->info['orders_status'] != "") && ($order->info['orders_status'] != 4) && ($order->info['orders_status'] != "Verified") && (file_exists(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])) && ( ($downloads['download_maxdays'] == 0) || ($download_timestamp > time())) ) {

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

if ( ($downloads['download_count'] > 0) && ($order->info['orders_status'] != '') && ($order->info['orders_status'] != '1') && ($order->info['orders_status'] != 'Order Placed') && ($order->info['orders_status'] != 'Pending') && ($order->info['orders_status'] != 'Processing') && ($order->info['orders_status'] != 'Cancelled') && ($order->info['orders_status'] != 'Void') && (file_exists(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])) && ( ($downloads['download_maxdays'] == 0) || ($download_timestamp > time())) ) {

 

// END Pending Order Downloads v2.10

 

// WebMakers.com Added: Downloads Controller Show Button

echo ' <td class="main" valign="top" align="center"><br><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . (int)$downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '<br><br>' . tep_image_button('button_download.gif', 'Click To Download This Item Now') . '</a><br><br></td>' . "\n";

} else {

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

}

?>

<!-- right box -->

<?php

// BOF: WebMakers.com Added: Downloads Controller

echo ' <td class="main" valign="top"><br>  ' . TABLE_HEADING_DOWNLOAD_DATE . '<br>  ' .

tep_date_long($download_expiry) . '</td>' . "\n" .

' <td class="main" valign="top" align="left"><br>  ' . (int)$downloads['download_count'] .

TABLE_HEADING_DOWNLOAD_COUNT . '</td>' . "\n" .

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

// EOF: WebMakers.com Added: Downloads Controller

}

?>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></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

}

}

?>

<?php

// BOF: WebMakers.com Added: Downloads Controller

// If there is a download in the order and they cannot get it, tell customer about download rules

$downloads_check_query = tep_db_query("select o.orders_id, opd.orders_products_download_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.orders_id = opd.orders_id and o.orders_id = '" . $last_order . "' and opd.orders_products_filename != ''");

 

if (tep_db_num_rows($downloads_check_query) > 0 and tep_db_num_rows($downloads_query) < 1) {

// if (tep_db_num_rows($downloads_query) < 1) {

?>

<tr>

<td align="left" valign="top" class="main"><font color="FF0000"><?php echo DOWNLOADS_CONTROLLER_ON_HOLD_MSG; ?></font></td>

</tr>

<?php

}

// EOF: WebMakers.com Added: Downloads Controller

?>

<!-- downloads_eof //-->

Link to comment
Share on other sites

Oscommerce supports downloads by default, but the method is not very practical. You'll probably need to install a downloads controller such as this:

 

http://www.oscommerce.com/community/contri...oads+controller

 

and if you're using a payment gateway to process credit cards, you'll need a contribution for your gateway.

 

Be sure that when you install contribs like this that you back up, and use a file comparison program such as Beyond Compare, because gateway contribs will probably modify some of the same files as the download controller.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...