// Price/Qty/Discounts
 $discount_index = 1;
 while (isset($filelayout['v_discount_qty_' . $discount_index])) {
     if ($row['v_products_discount_type'] != '0') {
         // if v_products_discount_type == 0 then there are no quantity breaks
         $sql2 = 'SELECT discount_id, discount_qty, discount_price FROM ' . TABLE_PRODUCTS_DISCOUNT_QUANTITY . ' WHERE products_id = ' . $row['v_products_id'] . ' AND discount_id=' . $discount_index;
         $result2 = ep_4_query($sql2);
         $row2 = $ep_uses_mysqli ? mysqli_fetch_array($result2) : mysql_fetch_array($result2);
         $row['v_discount_price_' . $discount_index] = $row2['discount_price'];
         $row['v_discount_qty_' . $discount_index] = $row2['discount_qty'];
     }
     $discount_index++;
 }
 // We check the value of tax class and title instead of the id
 // Then we add the tax to price if $price_with_tax is set to 1
 $row_tax_multiplier = ep_4_get_tax_class_rate($row['v_tax_class_id']);
 $row['v_tax_class_title'] = zen_get_tax_class_title($row['v_tax_class_id']);
 $row['v_products_price'] = round($row['v_products_price'] + $price_with_tax * $row['v_products_price'] * $row_tax_multiplier / 100, 2);
 // Clean the texts that could break CSV file formatting
 $dataRow = '';
 $problem_chars = array("\r", "\n", "\t");
 // carriage return, newline, tab
 foreach ($filelayout as $key => $value) {
     $thetext = $row[$key];
     // remove carriage returns, newlines, and tabs - needs review
     $thetext = str_replace($problem_chars, ' ', $thetext);
     // $thetext = str_replace("\r",' ',$thetext);
     // $thetext = str_replace("\n",' ',$thetext);
     // $thetext = str_replace("\t",' ',$thetext);
     // encapsulate data in quotes, and escape embedded quotes in data
     $dataRow .= '"' . str_replace('"', '""', $thetext) . '"' . $csv_delimiter;
     } else {
         // column doesn't exist in the IMPORT file
         // and product is new
         if ($product_is_new) {
             $v_products_url[$l_id] = "";
         }
     }
 }
 // Note: 11-08-2011 this section needs careful review
 // we get the tax_clas_id from the tax_title - from zencart??
 // on screen will still be displayed the tax_class_title instead of the id....
 if (isset($v_tax_class_title)) {
     $v_tax_class_id = ep_4_get_tax_title_class_id($v_tax_class_title);
 }
 // we check the tax rate of this tax_class_id
 $row_tax_multiplier = ep_4_get_tax_class_rate($v_tax_class_id);
 // And we recalculate price without the included tax...
 // Since it seems display is made before, the displayed price will still include tax
 // This is same problem for the tax_clas_id that display tax_class_title
 if ($price_with_tax == true) {
     $v_products_price = round($v_products_price / (1 + $row_tax_multiplier * $price_with_tax / 100), 4);
 }
 // if $v_products_quantity is null, set it to: 0
 if (trim($v_products_quantity) == '') {
     $v_products_quantity = 0;
     // new products are set to quanitity '0', updated products are set with default_these() values
 }
 // date variables - chadd ... these should really be products_date_available and products_date_added for clarity
 // date_avail is only set to show when out of stock items will be available, else it is NULL
 // 11-19-2010 fixed this bug where NULL wasn't being correctly set
 $v_date_avail = $v_date_avail ? "'" . date("Y-m-d H:i:s", strtotime($v_date_avail)) . "'" : "NULL";