QUOTE (axioma @ Jan 24 2006, 11:18 PM)

can you provide a better instructions, because the instructions given on note path are a quite messy.
thanks
Virtual Unique Products (PIN & Phonecard selling)
Version 0.6 alpha
© 2005 <email address removed - bluenotemkvi>
Work in progress, not for production use!!!
###########
0.6 * Bugfixes in checkout_process.php and admin area.
+ Now correctly works if customer buys 2 or more PINs.
0.5. Initial release.
#############UPDATING#################
Overwrite pin_loader.php with new one.
Make to changes marked (UPD) below.
############# INSTALLATION ##############
Set following options in admin area:
Configuration - Download - Enable Download "true"
Configuration - Stock - Check stock level "true"
Configuration - Stock - Substract Stock "true"
Configuration - Stock - Allow checkout "false"
#FILE /admin/includes/database_tables.php
#AND
#FILE /includes/database_tables.php
#ADD BEFORE closing ?>
//PIN add
define('TABLE_PRODUCTS_PINS', 'products_pins');
#FILE /admin/includes/filenames.php
#ADD BEFORE closing ?>
//PIN add
define('FILENAME_PIN_LOADER', 'pin_loader.php');
#FILE /admin/includes/boxes/catalog.php (or where you want to)
#FIND
'<a href="' . tep_href_link(FILENAME_SPECIALS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_SPECIALS . '</a><br>' .
#ADD AFTER
//PIN add
'<a href="' . tep_href_link(FILENAME_PIN_LOADER, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PIN_LOADER . '</a><br>'.
!!! If you have clean MS2 installation - you can copy files from "overwrite" folder
!!! and jump to DATABASE OPERATIONS section.
!!! Else copy files from /admin folder to your /admin folder and process everything below.
#FILE /admin/products_attributes.php
#FIND (~68)
$products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);
$products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);
$products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);
#ADD AFTER
//PIN add
$products_attributes_is_pin = isset($HTTP_POST_VARS['products_attributes_is_pin'])?1:0;
//PIN end
#FIND (next lines usually)
if (tep_not_null($products_attributes_filename)) {
tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");
#CHANGE TO
//PIN change
if (tep_not_null($products_attributes_filename) || $products_attributes_is_pin) {
tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "', '$products_attributes_is_pin')");
#FIND (~120)
$products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);
#ADD AFTER
//PIN add
$products_attributes_is_pin = isset($HTTP_POST_VARS['products_attributes_is_pin'])?1:0;
//PIN end
#FIND (next lines again)
if (tep_not_null($products_attributes_filename)) {
tep_db_query("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . tep_db_input($products_attributes_filename) . "', products_attributes_maxdays = '" . tep_db_input($products_attributes_maxdays) . "', products_attributes_maxcount = '" . tep_db_input($products_attributes_maxcount) . "'");
#CHANGE TO
//PIN change
if (tep_not_null($products_attributes_filename) || $products_attributes_is_pin) {
tep_db_query("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . tep_db_input($products_attributes_filename) . "', products_attributes_maxdays = '" . tep_db_input($products_attributes_maxdays) . "', products_attributes_maxcount = '" . tep_db_input($products_attributes_maxcount) . "', products_attributes_is_pin='$products_attributes_is_pin'");
#FIND (~758)
if (tep_db_num_rows($download_query) > 0) {
$download = tep_db_fetch_array($download_query);
$products_attributes_filename = $download['products_attributes_filename'];
$products_attributes_maxdays = $download['products_attributes_maxdays'];
$products_attributes_maxcount = $download['products_attributes_maxcount'];
#ADD AFTER
//PIN add
$products_attributes_is_pin = $download['products_attributes_is_pin'];
//PIN end
#FIND (~780)
<td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?> </td>
#ADD AFTER
<!-- //PIN add -->
<td class="smallText"><?php echo TABLE_TEXT_IS_PIN; ?></td>
<td class="smallText"><?php echo tep_draw_checkbox_field('products_attributes_is_pin', '', $products_attributes_is_pin,1); ?> </td>
<!-- //PIN end -->
#FIND (~871)
<td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?> </td>
#ADD AFTER
<!-- //PIN add -->
<td class="smallText"><?php echo TABLE_TEXT_IS_PIN; ?></td>
<td class="smallText"><?php echo tep_draw_checkbox_field('products_attributes_is_pin', '', $products_attributes_is_pin,1); ?> </td>
<!-- //PIN end -->
#FILE /checkout_process.php
#FIND (~125)
$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
#CHANGE TO
//PIN change
$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename, pad.products_attributes_is_pin
#FIND (~146)
if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
#CHANGE TO
//PIN change
if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename']) || ($stock_values['products_attributes_is_pin']==1) ) {
#FIND (~180)
$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
#CHANGE TO
//PIN change
$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename, pad.products_attributes_is_pin
#FIND (~206)
if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
#CHANGE TO
//PIN change
if ((DOWNLOAD_ENABLED == 'true') && ((isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) or $attributes_values['products_attributes_is_pin'])) {
#(UPD) ADD AFTER
//PIN add
for($pincycle=0;$pincycle<$order->products[$i]['qty'];$pincycle++) {
if($attributes_values['products_attributes_is_pin']) {
$pin_query=tep_db_query("SELECT products_pin_id, products_pin_code FROM ".TABLE_PRODUCTS_PINS." WHERE products_id = '".$order->products[$i]['id']."' AND products_pin_used='0' LIMIT 1");
if(tep_db_num_rows($pin_query)=='0') { // We have no PIN for this product
// insert some error notifying here
$pin=PIN_NOT_AVAILABLE;
} else {
$pin_res=tep_db_fetch_array($pin_query);
$pin=$pin_res['products_pin_code'];
tep_db_query("UPDATE ".TABLE_PRODUCTS_PINS." SET products_pin_used='".$insert_id."' WHERE products_pin_id = '".$pin_res['products_pin_id']."'");
}
}
//PIN
#FIND (~226)
'download_count' => $attributes_values['products_attributes_maxcount']);
#CHANGE TO
'download_count' => $attributes_values['products_attributes_maxcount'],
'download_is_pin' => $attributes_values['products_attributes_is_pin'],
'download_pin_code' => $pin
);
#FIND (next line)
tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
#(UPD) ADD AFTER
}
#FILE /includes/modules/downloads.php
#FIND (~25)
$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 != ''");
#CHANGE TO
$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, opd.download_pin_code,opd.download_is_pin 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 != '' or opd.download_is_pin='1') and o.orders_status>='".DOWNLOADS_AVAILABLE_STATUS."'");
#FIND (~51)
// The link will appear only if:
// - Download remaining count is > 0, AND
#ADD BEFORE
//PIN add
if ($downloads['download_is_pin']==1) { //PIN processing
$pinstring=$downloads['download_pin_code'];
echo '<td class="main">'.$downloads['products_name'].'</td><td class="main">'.$pinstring.'</td><td class="main"> </td>';
} else { //usual stuff
#FIND (~74)
$downloads['download_count'] . TABLE_HEADING_DOWNLOAD_COUNT . '</td>' . "\n" .
' </tr>' . "\n";
}
#ADD AFTER
}
#DATABASE OPERATIONS
INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`,
`configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES (NULL, 'PIN Show status', 'DOWNLOADS_AVAILABLE_STATUS', '2', 'Order must have this or better status', 13, 4, NULL, NOW(), NULL, '');
ALTER TABLE `products_attributes_download` ADD `products_attributes_is_pin` TINYINT( 1 ) NULL DEFAULT '0';
ALTER TABLE `orders_products_download` ADD `download_is_pin` TINYINT( 1 ) NULL DEFAULT '0',
ADD `download_pin_code` VARCHAR( 250 ) NULL ;
CREATE TABLE products_pins (
products_pin_id int(11) NOT NULL auto_increment,
products_id int(11) NOT NULL,
products_pin_code char(250) NOT NULL,
products_pin_used tinyint(4) NOT NULL default '0',
PRIMARY KEY (products_pin_id)
)
#LANGUAGE CONSTANTS
#ADMIN AREA
define('TABLE_TEXT_IS_PIN','Is PIN code');
define('BOX_CATALOG_PIN_LOADER','PIN loader');
#CUSTOMER AREA
define('PIN_NOT_AVAILABLE', 'Products out of stock during checkout. Personnel notified.');
that were the instruccions... i know the text on word path is a little weird to read
edit - removed email address by request - bluenotemkvi