Results 1 to 5 of 5
  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,289
    Plugin Contributions
    22

    Default 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.

    Code:
     ///////////////////////////////////////////////////////
            //// 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

  2. #2
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

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

    Quote Originally Posted by delia View Post
    When I updated the Product Extra fields mod for 1.3.9h, something stopped working.
    Updated from what?
    Quote Originally Posted by delia View Post
    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.

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,289
    Plugin Contributions
    22

    Default 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

  4. #4
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,289
    Plugin Contributions
    22

    Default 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

  5. #5
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default 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.

 

 

Similar Threads

  1. v150 can I add extra field on product page and admin for barcode
    By giuly in forum General Questions
    Replies: 4
    Last Post: 28 Nov 2012, 01:26 PM
  2. Ad a field to type in when you order + upload a file
    By oberheimer in forum General Questions
    Replies: 3
    Last Post: 23 Jun 2010, 11:01 AM
  3. adding extra name field
    By zas in forum Managing Customers and Orders
    Replies: 0
    Last Post: 13 Mar 2007, 11:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR