function ecom_shipping_USPS($shipping_option, $index, $packages, $org_zip, $dest_zip, $dest_country, $error) { global $_TABLES; $shipper_res = DB_query("SELECT user_name, live_server FROM {$_TABLES['ecom_shipper']} WHERE id = 1"); $shipper_row = DB_fetchArray($shipper_res); $pc = new USPS($shipper_row['user_name'], $org_zip, $dest_zip, $dest_country, $index); //user, z_org, z_dest $data_error = $pc->check_data(); if ($data_error != "") { $error .= $data_error; return 1; } foreach ($packages as $p) { $pc->add_package($p['w'], $p['h'], $p['l'], $p['p'], $p['o']); //w, h, l, p, o } $pc->merge_packages(); //Not yet functioning # Set the shipping options for national shipping US and US territories if ($dest_country == "US" || $dest_country == "PR" || $dest_country == "US" || $dest_country == "FM" || $dest_country == "PW") { $res = DB_query("SELECT * FROM {$_TABLES['ecom_shipper_service']} WHERE ecom_shipper_service_enabled = true AND ecom_shipper_id = 1 AND ecom_shipper_service_international = false"); while ($row = DB_fetchArray($res)) { //Check if it is media, library, or bound printed matter $can_ship = true; if ($row['ecom_shipper_service_service'] == "BPM") { //check to see if any items in cart can not be shipped this way foreach ($packages as $p) { if (!$p['bmp']) { $can_ship = false; } } } else { if ($row['ecom_shipper_service_service'] == "MEDIA") { //check to see if any items in cart can not be shipped this way foreach ($packages as $p) { if (!$p['media']) { $can_ship = false; } } } else { if ($row['ecom_shipper_service_service'] == "LIBRARY") { foreach ($packages as $p) { if (!$p['library']) { $can_ship = false; } } } } } if ($can_ship) { $total = $pc->get_price($row['ecom_shipper_service_service'], $row['ecom_shiper_service_code'], $shipper_row['live_server']); if ($total > 0) { //if total is 0 then error occurred (counldn't ship package). $shipping_option[$index]['description'] = $row['ecom_shipper_service_description']; $shipping_option[$index]['price'] = $total; $index++; } } } } else { # INTERNATION Shipping $res = DB_query("SELECT ecom_shiper_service_code FROM {$_TABLES['ecom_shipper_service']} WHERE ecom_shipper_service_enabled = true AND ecom_shipper_id = 1 AND ecom_shipper_service_international = true"); while ($row = DB_fetchArray($res)) { $service[$i++] = $row['ecom_shiper_service_code']; } $shipping_result = $pc->get_price($service, 0, $shipper_row['live_server']); if (is_array($shipping_result)) { foreach ($shipping_result as $shipping) { $shipping_option[$index]['description'] = $shipping['description']; // $shipping_option[$index]['price'] = $shipping['price']; $index++; } } } }