示例#1
0
function ship_methods()
{
    // Find all language directories
    $resultl = tep_db_query("SELECT * FROM " . TABLE_LANGUAGES . " ORDER BY languages_id");
    if ($myrowl = tep_db_fetch_array($resultl)) {
        do {
            $key = $myrowl["languages_id"];
            $lang_dirs[$key] = DIR_FS_CATALOG_LANGUAGES . $myrowl["directory"] . "/modules/shipping";
        } while ($myrowl = tep_db_fetch_array($resultl));
    }
    // Find all shipping modules for each language
    foreach ($lang_dirs as $lang_id => $lang_dir) {
        $dh = opendir($lang_dir);
        while (false !== ($ship_mod_file = readdir($dh))) {
            // Parse the payment text from the file
            if (strstr($ship_mod_file, "php")) {
                unset($ship_mod_text, $ship_mod_car_text, $ship_mod_car_code, $ship_mod_serv_text, $ship_mod_serv_code);
                // Open file
                $handle = fopen($lang_dir . "/" . $ship_mod_file, "rb");
                // Extract carrier code
                $ship_mod_car_code = str_replace(".php", "", $ship_mod_file);
                while (!feof($handle)) {
                    // Get a line of text
                    $ship_mod_text = fgets($handle);
                    // Check if line contains title (shipping carrier)
                    if (strstr($ship_mod_text, "TEXT_TITLE',") != FALSE) {
                        // Extract carrier text
                        $ship_mod_car_text = strstr($ship_mod_text, ",");
                        $start = strpos($ship_mod_car_text, "'") + 1;
                        $end = strrpos($ship_mod_car_text, "'");
                        $ship_mod_car_text = substr($ship_mod_car_text, $start, $end - $start);
                        // Check if line contains an option (shipping service)
                    } elseif (strstr($ship_mod_text, "_OPT_") != FALSE) {
                        // Extract service option text
                        $ship_mod_serv_txt = strstr($ship_mod_text, ",");
                        $start = strpos($ship_mod_serv_txt, "'") + 1;
                        $end = strrpos($ship_mod_serv_txt, "'");
                        $ship_mod_serv_text[] = substr($ship_mod_serv_txt, $start, $end - $start);
                        // Extract service option code
                        $ship_mod_serv_cd = strrchr($ship_mod_text, "_");
                        $start = strrpos($ship_mod_serv_cd, "_") + 1;
                        $end = strpos($ship_mod_serv_cd, "'");
                        $ship_mod_serv_code[] = substr($ship_mod_serv_cd, $start, $end - $start);
                    }
                }
                // end while
                if (!is_array($ship_mod_serv_text)) {
                    $ship_mod_serv_text[] = "";
                    $ship_mod_serv_code[] = "";
                }
                $ship_mod_serv_textcode = arraycombine($ship_mod_serv_text, $ship_mod_serv_code);
                foreach ($ship_mod_serv_textcode as $shipmod_serv_text => $shipmod_serv_code) {
                    // Update or insert into db
                    $result = tep_db_query("SELECT * FROM " . TABLE_QBI_SHIPOSC . " WHERE qbi_shiposc_car_code='{$ship_mod_car_code}' AND qbi_shiposc_serv_code='{$shipmod_serv_code}' AND language_id='{$lang_id}' LIMIT 1");
                    if (tep_db_fetch_array($result)) {
                        tep_db_query("UPDATE " . TABLE_QBI_SHIPOSC . " SET qbi_shiposc_car_text='{$ship_mod_car_text}', qbi_shiposc_serv_text='{$shipmod_serv_text}' WHERE qbi_shiposc_car_code='{$ship_mod_car_code}' AND qbi_shiposc_serv_code='{$shipmod_serv_code}' AND language_id='{$lang_id}'");
                    } else {
                        tep_db_query("INSERT INTO " . TABLE_QBI_SHIPOSC . " (qbi_shiposc_car_code,qbi_shiposc_serv_code,qbi_shiposc_car_text,qbi_shiposc_serv_text,language_id) VALUES ('{$ship_mod_car_code}','{$shipmod_serv_code}','{$ship_mod_car_text}','{$shipmod_serv_text}','{$lang_id}')");
                    }
                }
                // end foreach
            }
            // end if
        }
        // end while
    }
    // end foreach
    return;
}
         $prod_opt_val_id[] = $myrowpov["products_options_values_id_pov2"];
         // Get option value id
     }
 }
 // Determine language to use
 if (ITEM_OSC_LANG == 1) {
     $prod_name = $prod_name_cust;
     $prod_opt = $prod_opt_cust;
     $prod_opt_val = $prod_opt_val_cust;
 }
 // Construct product model and name
 if (is_array($prod_opt_val) and is_array($prod_opt)) {
     foreach ($prod_opt_val as $prod_opt_vals) {
         $prod_model .= ":" . $prod_opt_vals;
     }
     $prod_opt_val_opt = arraycombine($prod_opt, $prod_opt_val);
     foreach ($prod_opt_val_opt as $prod_opts => $prod_opt_vals) {
         $prod_name .= ", " . $prod_opts . ": " . $prod_opt_vals;
     }
 }
 // Check for product name substitutions and groups
 $resultqbp = tep_db_query("SELECT * FROM " . TABLE_QBI_PRODUCTS_ITEMS . " WHERE products_id='{$prod_id}' AND products_options_values_id='" . $prod_opt_val_id[0] . "'");
 if ($myrowqbp = tep_db_fetch_array($resultqbp)) {
     $qb_prod_refnum = $myrowqbp["qbi_groupsitems_refnum"];
     $resultqbi = tep_db_query("SELECT * FROM " . TABLE_QBI_ITEMS . " WHERE qbi_items_refnum='{$qb_prod_refnum}'");
     $resultqbg = tep_db_query("SELECT * FROM " . TABLE_QBI_GROUPS . " WHERE qbi_groups_refnum='{$qb_prod_refnum}'");
     // Write non-group substitution
     if ($myrowqbi = tep_db_fetch_array($resultqbi)) {
         $item_name_use_osc = 0;
         // feature to be added
         if ($item_name_use_osc == 0) {