jsx2 Posted April 2, 2006 Posted April 2, 2006 I have inserted the necessary code to have a customer upload a picture/image along with adding an item into the cart. The image is uploaded and saved onto the server. Now I am seeking assistance in getting the filename integrated with the cart, so that the customer can see their uploaded image along with the item in the cart, and also so the shop admin can see the image uploaded. Maybe the short answer is to have the HTTP link of the photo sent via email? Any ideas are welcome. Here is the instructions to upgrade the shopping cart to allow customer photo/images to be uploaded: (If someone see's a security problem, please let me know :) thanks) 1. **** copy admin/includes/classes/upload.php to includes/classes/upload.php 2. **** copy function tep_draw_file_field() { ... } **** from the file admin/includes/functions/html_output.php **** into the file includes/functions/html_output.php **** change: $field = tep_draw_input_field($name, '', '', $required, 'file'); **** to: $field = tep_draw_input_field($name, '', '', 'file', true); 3. **** in the file product_info.php **** find: if ($products_attributes['total'] > 0) { **** find matching "}" to the above line (vi users use '%') **** find </td></tr> **** After Add - start: <tr> <td class="main"><?php echo TEXT_STORES_IMAGE; ?> <?php echo tep_draw_file_field('store_image'). ' <br>' .(tep_not_null(ENTRY_LOGO_TEXT) ? '<span class="inputRequirement">' . ENTRY_LOGO_TEXT . '</span>': ''); ?></td> </tr> **** add -end 4. **** in the file product_info.php **** find: <td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> **** Change to: <td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> 5. **** in the file includes/languages/english/product_info.php **** Before "?>" at the last line of the file, insert: define('TEXT_STORES_IMAGE', 'Your Photo:'); define('ENTRY_LOGO_TEXT', 'Optional Here: If you prefer, you can email or mail us your photos instead.'); 6. **** in file includes/application_top.php, find: case 'add_product' **** insert after: // setup our boxes require(DIR_WS_CLASSES . 'boxes.php'); require(DIR_WS_CLASSES . 'table_block.php'); require(DIR_WS_CLASSES . 'box.php'); // initialize the message stack for output messages require(DIR_WS_CLASSES . 'message_stack.php'); $messageStack = new messageStack; require(DIR_WS_CLASSES . 'upload.php'); $allowed_files_types = array('gif', 'jpg', 'png'); $newname = DIR_FS_CATALOG .'images/customers/'; $jsxName=date("U")."___".rand(1000,9999); // copy image $store_logo_image = new upload('store_image'); $store_logo_image->set_destination($newname); $store_logo_image->set_extensions($allowed_files_types); $parsed = $store_logo_image->parse(); $ext = (substr($store_logo_image->filename, -4)); $store_logo_image->set_filename($jsxName . $ext); $saved = $store_logo_image->save(); if ($parsed && $saved){ $store_logo_image_name = $store_logo_image->filename; }else{ $store_logo_image_name = ''; } 7. **** create a directory: images/customers **** set permissions: chmod 777 images/customers/ 8. **** to limit the file size to 100K, in file includes/classes/upload.php **** find: if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) { **** replace with: if ($file['size'] > 100000) { $messageStack->add("FILE SIZE TOO LARGE", 'error'); } else if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) { 9. **** copy admin/includes/classes/table_block.php **** to includes/classes/table_block.php 10. **** copy admin/includes/classes/box.php **** to includes/classes/box.php --- Cheers. --Mike (http://js-x.com/)
bussieblues Posted April 4, 2006 Posted April 4, 2006 This makes it possible to view the uploaded file in Admin under "order edit" I have to check how I did manage to get the uploaded file visible in the basket. good luck Enhancement to file upload v.77 Purpose: -------- To facilitate the admin to view the file uploaded by user as part of product options IMPORTANT: ---------- This contribution will work only after installation of the contribution 'File Upload .77 (for PA - Option Type Feature)' by Matt Fletcher. Files that need to be modified: ------------------------------ /catalog/admin/includes/configure.php /catalog/admin/includes/database_tables.php /catalog/admin/orders.php Detailed Instructions: ---------------------- File #1: /catalog/admin/includes/configure.php Add the following lines at the end of the file define('DIR_WS_CATALOG_IMAGES_UPLOADS', DIR_WS_CATALOG_IMAGES . 'uploads/'); define('DIR_FS_CATALOG_IMAGES_UPLOADS', DIR_FS_CATALOG_IMAGES . 'uploads/'); File #2: /catalog/admin/includes/database_tables.php Add the following line at the end of the file define('TABLE_PRODUCTS_OPTIONS_TYPES', 'products_options_types'); File #3: /catalog/admin/orders.php You need to locate the following code in your orders.php [somewhere near line no 225] if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) { for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) { echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value']; if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; echo '</i></small></nobr>'; } } and Change it to if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) { for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) { // Customization #31101 for file_upload view begin $option = $order->products[$i]['attributes'][$j]['option']; ## Build a query to check if this option is of 'File' Type $file_check_sql = " select count(*) from ".TABLE_PRODUCTS_OPTIONS ." o, ".TABLE_PRODUCTS_OPTIONS_TYPES." ot WHERE o.products_options_type = ot.products_options_types_id AND products_options_types_name='File' AND o.products_options_name='".$option."'"; $file_check_sql_query = tep_db_query($file_check_sql); $isFile = tep_db_num_rows($file_check_sql_query); if($isFile == 1 && @file_exists(DIR_FS_CATALOG_IMAGES_UPLOADS.$order->products[$i]['attributes'][$j]['value'])){ $link = "<a href=". DIR_WS_CATALOG_IMAGES_UPLOADS.$order->products[$i]['attributes'][$j]['value']." target='_blank'><i>Click to View</i></a>"; }else { $link = ""; } echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value']; if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; echo ' '. $link.' </i></small></nobr>'; // Customization #31101 end } } thats it. Now you should see a link ' Click to View' beside the name of the file in the product options any comments or feedback is welcome to [email protected]
djfranknitti Posted August 23, 2006 Posted August 23, 2006 i would like to help you find the answer on how to view those uploaded files. Please get at me ;) [email protected]
Guest Posted August 23, 2006 Posted August 23, 2006 is this from a contribution? one of my friends have been trying to figure this out for some time. (if so, please point me in the right direction?) ;) i would like to help you find the answer on how to view those uploaded files. Please get at me ;) so you can charge them? :rolleyes:
Guest Posted August 29, 2006 Posted August 29, 2006 Very :'( this Thread :o Is a complete HowTo available ? Regards & THX Frank :thumbsup:
Guest Posted September 6, 2006 Posted September 6, 2006 I have inserted the necessary code to have a customer upload a picture/image along with adding an item into the cart.The image is uploaded and saved onto the server. Now I am seeking assistance in getting the filename integrated with the cart, so that the customer can see their uploaded image along with the item in the cart, and also so the shop admin can see the image uploaded. Maybe the short answer is to have the HTTP link of the photo sent via email? Any ideas are welcome. Is there a way of intergrating this into the attributes system so it can be applied to specific products? .
Recommended Posts
Archived
This topic is now archived and is closed to further replies.