Totally Zenned
- Join Date:
- May 2006
- Location:
- Gardiner, Maine
- Posts:
- 2,383
- Plugin Contributions:
- 7
adding an extra product field for upload of file in 1.3.9h
When I updated the Product Extra fields mod for 1.3.9h, something stopped working.
When uploading a pdf file, the link displays correctly on the preview page. After updating, the pdf is uploaded correctly but that link/file name is not inserted into the database field.
Everything else is inserting without any problems. So there must have been a change in the upgrade that affected this.
Here's the code for the update_product.php that pertains to the extra fields. file_1, file_2 etc are the fields for the name of the uploaded file.
///////////////////////////////////////////////////////
//// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
//extra product fields
$tmp_value = zen_db_prepare_input($_POST['file_1']);
$file_1 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_2']);
$file_2 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_3']);
$file_3 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_4']);
$file_4 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_1_title']);
$file_1_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_2_title']);
$file_2_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_3_title']);
$file_3_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_4_title']);
$file_4_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['video']);
$video = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['video_title']);
$video_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['extra_field']);
$extra_field = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['height']);
$height = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['width']);
$width = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['specs']);
$specs = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['dimensions']);
$dimensions = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['compatibility']);
$compatibility = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['weight']);
$weight = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['warranty']);
$warranty = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['warranty']);
$warranty = ($tmp_value=='') ? "null" : $tmp_value;
$sql_data_array = array('products_id' => $products_id,
'extra_field' => $extra_field,
'video_title' => $video_title,
'file_1' => $file_1,
'file_2' => $file_2,
'file_3' => $file_3,
'file_4' => $file_4,
'file_1_title' => $file_1_title,
'file_2_title' => $file_2_title,
'file_3_title' => $file_3_title,
'file_4_title' => $file_4_title,
'video' => $video,
'height' => $height,
'width' => $width,
'specs' => $specs,
'dimensions' => $dimensions,
'compatibility' => $compatibility,
'weight' => $weight,
'package' => $package,
'warranty' => $warranty
);
zen_db_perform(TABLE_PRODUCT_EXTRA_FIELDS, $sql_data_array);
//// *END OF PRODUCT-TYPE-SPECIFIC INSERTS* ////////
///////////////////////////////////////////////////////
} elseif ($action == 'update_product') {
$update_sql_data = array( 'products_last_modified' => 'now()',
'master_categories_id' => ($_POST['master_category'] > 0 ? zen_db_prepare_input($_POST['master_category']) : zen_db_prepare_input($_POST['master_categories_id'])));
$sql_data_array = array_merge($sql_data_array, $update_sql_data);
zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
// reset products_price_sorter for searches etc.
zen_update_products_price_sorter((int)$products_id);
///////////////////////////////////////////////////////
//// INSERT PRODUCT-TYPE-SPECIFIC *UPDATES* HERE //////
//extra product fields
$tmp_value = zen_db_prepare_input($_POST['file_1']);
$file_1 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_2']);
$file_2 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_3']);
$file_3 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_4']);
$file_4 = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_1_title']);
$file_1_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_2_title']);
$file_2_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_3_title']);
$file_3_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['file_4_title']);
$file_4_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['video']);
$video = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['video_title']);
$video_title = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['extra_field']);
$extra_field = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['height']);
$height = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['width']);
$width = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['specs']);
$specs = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['dimensions']);
$dimensions = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['weight']);
$weight = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['compatibility']);
$compatibility = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['package']);
$package = ($tmp_value=='') ? "null" : $tmp_value;
$tmp_value = zen_db_prepare_input($_POST['warranty']);
$warranty = ($tmp_value=='') ? "null" : $tmp_value;
$sql_data_array = array('extra_field' => $extra_field,
'file_1' => $file_1,
'file_2' => $file_2,
'file_3' => $file_3,
'file_4' => $file_4,
'file_1_title' => $file_1_title,
'file_2_title' => $file_2_title,
'file_3_title' => $file_3_title,
'file_4_title' => $file_4_title,
'video' => $video,
'video_title' => $video_title,
'height' => $height,
'width' => $width,
'specs' => $specs,
'dimensions' => $dimensions,
'weight' => $weight,
'compatibility' => $compatibility,
'package' => $package,
'warranty' => $warranty
);
The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo