If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / adding an extra product field for upload of file in 1.3.9h

adding an extra product field for upload of file in 1.3.9h

Started by delia on 10 Mar 2011, 8:50 PM · Views: 926

Results 1 to 5 of 5
10 Mar 2011, 8:50 PM
#1
delia avatar

delia

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

12 Mar 2011, 7:10 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: adding an extra product field for upload of file in 1.3.9h

delia:

When I updated the Product Extra fields mod for 1.3.9h, something stopped working.Updated from what?
delia:

Everything else is inserting without any problems. So there must have been a change in the upgrade that affected this.The only thing that changed from v1.3.9c to v1.3.9h related to uploads was an improvement to error messages to be more specific about details triggering the error.
And nothing was changed in the code that handles saving the data once collected and displayed in the preview. The update_product.php files weren't changed.

I'm uncertain what "change in the upgrade" you think is causing your problem. Or maybe you're talking about the update you did to your addon?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Mar 2011, 12:00 PM
#3
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: adding an extra product field for upload of file in 1.3.9h

Yes, it appeared after my update so I was hoping that there was a reason for it besides my error.

I guess I go back to a file compare and see if I screwed up something somewhere.

Thanks for the answer. As always I really appreciate your support.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

12 Mar 2011, 12:18 PM
#4
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: adding an extra product field for upload of file in 1.3.9h

And it was really obvious once I did that. I managed not to do the hidden field thing on the preview file so the file names were not being sent.

Thanks for setting me straight!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

15 Mar 2011, 10:54 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: adding an extra product field for upload of file in 1.3.9h

Glad you got it sorted out!

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.