parsnipsius Posted September 28, 2005 Posted September 28, 2005 I've got the download controller and it's working fine but I was wondering if anyone knew how I could include free direct links to the downloads for my free products, so they don't have to go through the whole checkout, all they have to do is click the buy now button and it downloads.. Is this possible or not? Thanks in advance
Guest Posted September 29, 2005 Posted September 29, 2005 the code flow goes through the orders table before executing the download code. You could add a separate field for the products table to allow direct download (like a url extra column in the products sql table).
parsnipsius Posted September 29, 2005 Author Posted September 29, 2005 Thanks alot, umm how would I go about doing this? Or is this to big for an SQL nub like me? Any help much appreciated! Thanks! Sam
Guest Posted September 29, 2005 Posted September 29, 2005 First backup your dbase & files, get phpmyadmin if you don't have it yet, then you need to do the following (Just a possible approach) 1. Change the products_description table ALTER TABLE `products_description` ADD `products_free_url` varchar(255) NOT NULL default ''; This should change the products_description table adding an extra text field to accomodate the url 2. Change the catalog\admin\categories.php More or less you need to duplicate the code that exists there for the products_url You duplicate it using products_free_url 3. Assign the download link, open catalog\includes\application_top.php Locate this line case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) { right below it add this code: $free_url_query = tep_db_query("select products_free_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); if( ($free_url = tep_db_fetch_array($url_query)) && tep_not_null($free_url['products_free_url']) ) { tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($free_url['products_free_url']), 'NONSSL', true, false)); } So now in your admin you could assign for a product a free download url and when someone clicks the buy button they d/l immediately if the free url existis otherwise they buy as before. You have to do the admin part. Its easy but time consuming.
parsnipsius Posted September 29, 2005 Author Posted September 29, 2005 Wow thanks for taking the time to explain this in such detail! I'll give it a go later.. :D
parsnipsius Posted September 29, 2005 Author Posted September 29, 2005 Sorry for being such a pain as this is probably really easy stuff to you, but: a) How do I backup my database? I couldn't find anywhere in PhpMyAdmin except for export, is this it? b)Exactly how do I change that line? Sorry but MyAdmin is confusing as hell! I'm pretty sure I can do the rest from what you told me.
Mediajuggle Posted September 29, 2005 Posted September 29, 2005 you can backup your database using your stores Admin under "tools" My Contribution Music Download Store Template http://www.oscommerce.com/community/contributions,4275
parsnipsius Posted September 29, 2005 Author Posted September 29, 2005 Thankyou! Any ideas on: "1. Change the products_description table ALTER TABLE `products_description` ADD `products_free_url` varchar(255) NOT NULL default ''; This should change the products_description table adding an extra text field to accomodate the url"
parsnipsius Posted September 29, 2005 Author Posted September 29, 2005 Ok what I've done so far.. I ran an "SQL query" on "ALTER TABLE `products_description` ADD `products_free_url` varchar(255) NOT NULL default '' This appeared to be fine, I then copied lines that applied to products_url e.g here $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]), 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]), 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]), 'products_free_url' => tep_db_prepare_input($HTTP_POST_VARS['products_free_url'][$language_id])); And also added it after "products_url" in lists like this: $description_query = tep_db_query("select language_id, products_name, products_description, products_url, products_free_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); I guessed that this is what you meant by "duplicate".. I did this for every "products_url" I found in categories.php I then added the lines to application_top.php like you said.. I can access admin fine, so I guess I didnt mess anything up in categories.php, but when I try to access the store I get this parse error: Parse error: parse error, unexpected ')' in /www/m/mystore/htdocs/store/includes/application_top.php on line 373 Do you know what this means? Line 373 is this part of the code you told me to insert: tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($free_url['products_free_url']), 'NONSSL', true, false)); Thanks in advance!!
Guest Posted September 29, 2005 Posted September 29, 2005 that looks very good, you made good progress (yes there is an extra bracket at the end) but in the admin are you now able to insert the new free url and when you re-edit the product you see it ok? That was the hard part I mean. Here is the corrected line (I hope this time): tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($free_url['products_free_url']), 'NONSSL', true, false); now the last part will be to make the re-direction to work
parsnipsius Posted September 30, 2005 Author Posted September 30, 2005 Once again thanks so much!!! Looks like taking that ")" did the trick as I can now get on my store.. however it is now pointing out my categories errors.. Here is the first one: Parse error: parse error, unexpected T_ELSE in /www/m/mystore/htdocs/store/admin/categories.php on line 758 Here is the code around line 758 <?php /* Re-Post all POST'ed variables */ reset($HTTP_POST_VARS); while (list($key, $value) = each($HTTP_POST_VARS)) { if (!is_array($HTTP_POST_VARS[$key])) { echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value))); } } $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { echo tep_draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_free_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_free_url[$languages[$i]['id']]))); } echo tep_draw_hidden_field('products_image', stripslashes($products_image_name)); echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . ' '; if (isset($HTTP_GET_VARS['pID'])) { echo tep_image_submit('button_update.gif', IMAGE_UPDATE); } else { echo tep_image_submit('button_insert.gif', IMAGE_INSERT); } echo ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> </tr> </table></form> <?php } } else { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td> <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="smallText" align="right"> Line 758 is just simply the } else { about half way down.. If anyone can help me on this I would be soo greatful!! Thanks again!! Edit: I've put in some blank lines around it to make it stand out amongst all the code..
Guest Posted September 30, 2005 Posted September 30, 2005 use the winmerge tool if you dont have it is here http://winmerge.org/2.2/ then get the differences between the original file you have and the modified categories.php you made. Post the differences here
parsnipsius Posted September 30, 2005 Author Posted September 30, 2005 Ok here it goes: Ill always paste original and then edited. 1 $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]), 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]), 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id])); $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]), 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]), 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]), 'products_free_url' => tep_db_prepare_input($HTTP_POST_VARS['products_free_url'][$language_id])); 2 $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); while ($description = tep_db_fetch_array($description_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); $description_query = tep_db_query("select language_id, products_name, products_description, products_url, products_free_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); while ($description = tep_db_fetch_array($description_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_free_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '" . tep_db_input($description['products_free_url']) . "', '0')"); 3 if ($action == 'new_product') { $parameters = array('products_name' => '', 'products_description' => '', 'products_url' => '', 'products_id' => '', 'products_quantity' => '', 'products_model' => '', 'products_image' => '', 'products_price' => '', 'products_weight' => '', 'products_date_added' => '', 'products_last_modified' => '', 'products_date_available' => '', 'products_status' => '', 'products_tax_class_id' => '', 'manufacturers_id' => ''); if ($action == 'new_product') { $parameters = array('products_name' => '', 'products_description' => '', 'products_url' => '', 'products_free_url' => '', 'products_id' => '', 'products_quantity' => '', 'products_model' => '', 'products_image' => '', 'products_price' => '', 'products_weight' => '', 'products_date_added' => '', 'products_last_modified' => '', 'products_date_available' => '', 'products_status' => '', 'products_tax_class_id' => '', 'manufacturers_id' => ''); 4 $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, pd.products_free_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); 5 $pInfo->objectInfo($product); } elseif (tep_not_null($HTTP_POST_VARS)) { $pInfo->objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; } $pInfo->objectInfo($product); } elseif (tep_not_null($HTTP_POST_VARS)) { $pInfo->objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; $products_free_url = $HTTP_POST_VARS['products_free_url']; } 6 <tr> <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td> <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? $products_url[$languages[$i]['id']] : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> <tr> <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_FREE_URL . '<br><small>' . TEXT_PRODUCTS_FREE_URL_WITHOUT_HTTP . '</small>'; ?></td> <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_free_url[' . $languages[$i]['id'] . ']', (isset($products_free_url[$languages[$i]['id']]) ? $products_free_url[$languages[$i]['id']] : tep_get_products_free_url($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> 7 $pInfo = new objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; } else { $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); $pInfo = new objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; $products_free_url = $HTTP_POST_VARS['products_free_url']; } else { $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, pd.products_free_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); 8 if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']); $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']); $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']); } else { $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]); $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]); $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]); } if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']); $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']); $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']); $pInfo->products_free_url = tep_get_products_free_url($pInfo->products_id, $languages[$i]['id']); } else { $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]); $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]); $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]); $pInfo->products_free_url = tep_db_prepare_input($products_free_url[$languages[$i]['id']]); } 9 <?php if ($pInfo->products_url) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td> </tr> <?php if ($pInfo->products_url) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td> </tr> <?php if ($pInfo->products_free_url) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_free_url); ?></td> </tr> 10 $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { echo tep_draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']]))); } $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { echo tep_draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']]))); echo tep_draw_hidden_field('products_free_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_free_url[$languages[$i]['id']]))); } Hope you can make some sense of this.. I only pasted parts that I had edited close to.
Guest Posted September 30, 2005 Posted September 30, 2005 I stopped on item 6 because there is a function missing with the introduction of the free url. So open the admin\includes\functions\general.php and just after the tep_get_products_url function add this: function tep_get_products_free_url($product_id, $language_id) { $product_query = tep_db_query("select products_free_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_free_url']; } Also can you double check item -6 the old code is present as well as the extra code for the url is there too. (Just make sure you did not override the old code).
parsnipsius Posted September 30, 2005 Author Posted September 30, 2005 Yes sorry, I forgot to paste it in, item 6 has first the original code and then the new code, so basically it is the 2 examples i showed put together. I've added that to admin, anything else need to be done? Btw it's people like you that is helping OsCommerce turn into such great software! Thanks a million for your time!
Guest Posted September 30, 2005 Posted September 30, 2005 ok, how far you go now? can you edit the free url field in the admin and save it with a product?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.