public function getRates($items) { global $order; // Require the main ups class and upsRate include_once BASE . 'external/ups-php/classes/class.ups.php'; include_once BASE . 'external/ups-php/classes/class.upsRate.php'; $upsConnect = new ups($this->configdata['accessnumber'], $this->configdata['username'], $this->configdata['password']); $upsConnect->setTemplatePath(BASE . 'external/ups-php/xml/'); $upsConnect->setTestingMode($this->configdata['testmode']); // Change this to 0 for production $upsRate = new upsRate($upsConnect); $upsRate->request(array('Shop' => true)); // set the address we will be shipping from. this should be in the config data $upsRate->shipper($this->configdata['shipfrom']); // get the current shippingmethod and format the address for ups $currentmethod = $order->getCurrentShippingMethod(); $upsRate->shipTo($this->formatAddress($currentmethod)); // set the standard box sizes. $box_width = empty($this->configdata['default_width']) ? 0 : $this->configdata['default_width']; $box_height = empty($this->configdata['default_height']) ? 0 : $this->configdata['default_height']; $box_length = empty($this->configdata['default_length']) ? 0 : $this->configdata['default_length']; $box_volume = $box_height * $box_width * $box_length; // set some starting/default values $weight = 0; $volume = 0; $count = 0; $package_items = array(); // loop each product in this shipment and create the packages $has_giftcard = false; foreach ($items->orderitem as $item) { for ($i = 0; $i < $item->quantity; $i++) { if (empty($item->product->no_shipping) && $item->product->requiresShipping == true) { if ($item->product_type != 'giftcard') { $lbs = empty($item->product->weight) ? $this->configdata['default_max_weight'] : $item->product->weight; $width = empty($item->product->width) ? $this->configdata['default_width'] : $item->product->width; $height = empty($item->product->height) ? $this->configdata['default_height'] : $item->product->height; $length = empty($item->product->length) ? $this->configdata['default_length'] : $item->product->length; $package_items[$count]->volume = $width * $length * $height; $package_items[$count]->weight = $lbs; $package_items[$count]->w = $width; $package_items[$count]->h = $height; $package_items[$count]->l = $length; $package_items[$count]->name = $item->product->title; $count += 1; } else { $has_giftcard = true; } } } } // kludge for the giftcard shipping if (count($package_items) == 0 && $has_giftcard) { $rates = array("03" => array("id" => "03", "title" => "UPS Ground", "cost" => 5.0), "02" => array("id" => "02", "title" => "UPS Second Day Air", "cost" => 10.0), "01" => array("id" => "01", "title" => "UPS Next Day Air", "cost" => 20.0)); return $rates; } // sort the items by volume $package_items = expSorter::sort(array('array' => $package_items, 'sortby' => 'volume', 'order' => 'DESC')); // loop over all the items and try to put them into packages in a semi-intelligent manner // we have sorted the list of items from biggest to smallest. Items with a volume larger than // our standard box will generate a package with the dimensions set to the size of the item. // otherwise we just keep stuffing items in the current package until we can't find anymore that will // fit. Once that happens we close that package and start a new one...repeating until we are out of items $space_left = $box_volume; $total_weight = 0; while (!empty($package_items)) { $no_more_room = true; $used = array(); foreach ($package_items as $idx => $pi) { if ($pi->volume > $box_volume) { # echo $pi->name."is too big for standard box <br>"; # eDebug('created OVERSIZED package with weight of '.$pi->weight); # eDebug('dimensions: height: '.$pi->h." width: ".$pi->w." length: ".$pi->l); # echo "<hr>"; $weight = $pi->weight > 1 ? $pi->weight : 1; $upsRate->package(array('description' => 'shipment', 'weight' => $weight, 'code' => '02', 'length' => $pi->l, 'width' => $pi->w, 'height' => $pi->h)); $used[] = $idx; $no_more_room = false; } elseif ($pi->volume <= $space_left) { $space_left = $space_left - $pi->volume; $total_weight += $pi->weight; # echo "Adding ".$pi->name."<br>"; # echo "Space left in current box: ".$space_left."<br>"; $no_more_room = false; $used[] = $idx; } } // remove the used items from the array so they wont be there on the next go around. foreach ($used as $idx) { unset($package_items[$idx]); } // if there is no more room left on the current package or we are out of items then // add the package to the shippment. if ($no_more_room || empty($package_items) && $total_weight > 0) { $total_weight = $total_weight > 1 ? $total_weight : 1; # eDebug('created standard sized package with weight of '.$total_weight); # echo "<hr>"; $upsRate->package(array('description' => 'shipment', 'weight' => $total_weight, 'code' => '02', 'length' => $box_length, 'width' => $box_width, 'height' => $box_height)); $space_left = $box_volume; $total_weight = 0; } } $upsRate->shipment(array('description' => 'my description', 'serviceType' => '03')); $rateFromUPS = $upsRate->sendRateRequest(); $handling = empty($has_giftcard) ? 0 : 5; if ($rateFromUPS['RatingServiceSelectionResponse']['Response']['ResponseStatusCode']['VALUE'] == 1) { $rates = array(); $available_methods = $this->availableMethods(); foreach ($rateFromUPS['RatingServiceSelectionResponse']['RatedShipment'] as $rate) { if (array_key_exists($rate['Service']['Code']['VALUE'], $available_methods)) { $rates[$rate['Service']['Code']['VALUE']] = $rate['TotalCharges']['MonetaryValue']['VALUE']; $rates[$rate['Service']['Code']['VALUE']] = array('id' => $rate['Service']['Code']['VALUE'], 'title' => $this->shippingmethods[$rate['Service']['Code']['VALUE']], 'cost' => $rate['TotalCharges']['MonetaryValue']['VALUE'] + $handling); } } return $rates; } else { return $rateFromUPS['RatingServiceSelectionResponse']['Response']['Error']['ErrorDescription']['VALUE']; } }
} else { $err["contactnotfound"] = "There is no contact tied to shippment"; } if ($order_info["weight"] == '0' or $order_info["weight"] == '') { $err["weightblank"] = "The weight is empty"; //$return["javascript"] .= "alert('Shipping Weight is not set');$('#shipping_weight').focus();$('#shipping_weight_div').css('background','#ff0000');"; $return["javascript"] .= ""; $return["stop"] = 'YES'; } if ($order_info["contact_first_name"] != '' or $order_info["contact_last_name"] != '') { $to_attr = $order_info["contact_first_name"] . " " . $order_info["contact_last_name"]; } else { $to_attr = $to_person["display_name"]; } if (count($err) == 0) { $ups = new ups(); //$address["state"] $from_address = $ups->address_object(UPS_DEFAULT_FROM_STREET, UPS_DEFAULT_FROM_CITY, UPS_DEFAULT_FROM_STATE, UPS_DEFAULT_FROM_ZIP, UPS_DEFAULT_FROM_COUNTRY); $to_address = $ups->address_object($address["street_address"], $address["city"], $ups->convert_statename_to_abbr($address["state"]), $address["zip"]); $from = $ups->person_object(UPS_DEFAULT_SHIPPER_NAME, $from_attr, UPS_DEFAULT_SHIPPER_PHONE, $from_address, UPS_DEFAULT_SHIPPER_NUMBER); $to = $ups->person_object($to_person["display_name"], $to_attr, $to_person["phone"], $to_address); $xmlArr = $ups->run_shippment($from, $from, $to, $order_info["weight"], "LBS", $order_info["shipment_type"], "02", 'Order - ' . $order_info["order_id"], $order_info["grant_total"]); //file_put_contents("request.xml", $xmlArr["sourceXML"] ); //file_put_contents("responce.xml", $xmlArr["originalXML"] ); $accept = $ups->AcceptShip($xmlArr["children"]["ShipmentDigest"][0]["value"]); $up_order = array(); $shipping_label = $accept["children"]["ShipmentResults"][0]["children"]["PackageResults"][0]["children"]["LabelImage"][0]["children"]["GraphicImage"][0]["value"]; $up_order["shipment_label"] = $shipping_label; $ups->set_ship(); $ups->ship_class->add_shipment($module_name, $module_id, "Shippment for order {$module_id}", $xmlArr["children"]["ShipmentIdentificationNumber"][0]["value"], "UPS"); if ($accept["children"]["ShipmentResults"][0]["children"]["ControlLogReceipt"][0]["children"]["GraphicImage"][0]["value"] != '') {
function updatefield($shipping_charge='',$old_shipping_charge='',$multiplier='',$old_multiplier='',$total='',$choice=''){ ob_start(); $ups = new ups(); $calc = $ups->estamate_shipping_by_module( 'order' , $_REQUEST['order_id'] , $shipping_charge); $shipping_type = $shipping_charge; $shipping_charge = $calc; switch($choice){ case 'shipping': $update_sql_array = array(); $update_sql_array["shipment_type"] = $shipping_type; $update_sql_array["shipping_charges"] = $shipping_charge; $this->db->update(erp_ORDER,$update_sql_array,'order_id',$_REQUEST[order_id]); echo $calc; break; case 'multiplier': $update_sql_array = array(); $update_sql_array[multiplier] = $multiplier; $this->db->update(erp_ORDER,$update_sql_array,'order_id',$_REQUEST[order_id]); break; } /////end of switch $this->total_price = ($this->total_price + $shipping_charge) * $multiplier; // echo $this->total_price.' '.$shipping_charge.' '.$multiplier; $html=ob_get_contents(); ob_end_clean(); return $html; } ////////////end of function updatefield
// keep the thermal label encoded for now $output_label = base64_decode($label['graphic_image']); $file_ext = '.lpt'; // thermal printer } else { $output_label = base64_decode($label['graphic_image']); $file_ext = '.gif'; // plain paper } @rename($shipment->labelFilePath, $file_path . 'LabelImage_' . $count . $file_ext); $count++; } // generate the delete requests and save $count = 1; foreach ($deleteID as $tracking_number) { $shipment = new ups(); $shipment->tracking_number = $tracking_number; // override id with hard coded tracking number $shipment->deleteLabel(-1); if (!write_file($file_path . 'DeleteRequest_' . $count . '.txt', $shipment->labelDelRequest)) { break; } if (!write_file($file_path . 'DeleteResponse_' . $count . '.txt', $shipment->labelDelResponse)) { break; } $count++; } // zip the results and download $messageStack->add('Successfully created UPS validation files! Disregard error messages from delete operation, they are expected. The files can be found in: ' . $file_path, 'success'); break; default:
function estamate_shipping_by_module($module_name, $module_id, $shipment_type = "03") { $debug = "no"; if ($debug == "yes") { echo __LINE__ . "<br>\n"; } //echo __LINE__; $this->set_db(); // Database access is required for this module if ($debug == "yes") { echo __LINE__ . "<br>\n"; } switch ($module_name) { case "order": if ($debug == "yes") { echo __LINE__ . "<br>\n"; } // echo __LINE__; $sql = "SELECT a.* , b.first_name contact_first_name , b.last_name contact_last_name FROM erp_order a LEFT JOIN contacts b ON a.contact_id = b.contact_id WHERE order_id = '{$module_id}'"; // echo $sql; $order_info = $this->db->fetch_assoc($this->db->query($sql)); if ($debug == "yes") { echo __LINE__ . "<br>\n"; } if (is_array($order_info)) { if (key_exists("vendor_contact_id", $order_info)) { $contact_id = $order_info["vendor_contact_id"]; $address_id = $order_info["shipping_address"]; } else { $err["modulenotfound"] = "The order requested does not exsist, Shipping can not continue"; } } else { $err["modulenotfound"] = "The order requested does not exsist, Shipping can not continue"; } if ($debug == "yes") { echo __LINE__ . "<br>\n"; } if ($address_id != '') { $get_address_res = $this->db->query("SELECT * FROM module_address WHERE address_id = '{$address_id}'"); if ($this->db->num_rows($get_address_res) != 0) { $address = $this->db->fetch_assoc($get_address_res); } else { $err["addressnotfound"] = "No shipping address found"; } } else { $err["addressnotfound"] = "No shipping address found"; } if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($err, true)) . "<br>\n"; } if ($contact_id != '') { if ($debug == "yes") { echo __LINE__ . "<br>\n"; } $sql = "SELECT a.* , c.first_name csr_first_name , c.last_name csr_last_name FROM contacts a LEFT JOIN erp_contactscreen_custom b ON a.contact_id = b.contact_id LEFT JOIN tbl_user c ON b.csr = c.user_id WHERE a.contact_id = '{$contact_id}'"; //echo $sql; if ($debug == "yes") { echo __LINE__ . ":{$sql}<br>\n"; } //return $sql; $get_contact_res = $this->db->query($sql); if ($this->db->num_rows($get_contact_res) != 0) { $to_person = $this->db->fetch_assoc($get_contact_res); if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($to_person, true)) . "<br>\n"; } if ($to_person["type"] == "Company") { $to_person["display_name"] = $to_person["company_name"]; } else { $to_person["display_name"] == $to_person["first_name"] . " " . $to_person["last_name"]; } if ($to_person["csr_first_name"] != '' or $to_person["csr_last_name"] != '') { $from_attr = $to_person["csr_first_name"] . " " . $to_person["csr_last_name"]; } else { $from_attr = UPS_DEFAULT_SHIPPER_NAME; } $phone_res = $this->db->query("SELECT * FROM contacts_phone WHERE contact_id = '" . $contact_id . "'"); if ($this->db->num_rows($phone_res) != 0) { $found = 1; $to_person["phone"] = UPS_DEFAULT_SHIPPER_PHONE; while ($row = $this->db->fetch_assoc($phone_res)) { $tmp_type = 1; if ($debug == "yes") { echo __LINE__ . ":tmp_type = {$tmp_type}<br>\n"; } switch (strtolower($row["type"])) { case "work": $tmp_type = 5; // Prefered type break; case "mobile": $tmp_type = 3; // Better then most, not better then work break; case "home": $tmp_type = 2; // acceptable break; case "fax": $tmp_type = 0; // worse then anything ( for ups anyway ) break; } if ($tmp_type > $found) { if ($debug == "yes") { echo __LINE__ . ":tmp_type = {$tmp_type} > found = {$found}<br>\n"; } $to_person["phone"] = $row["number"]; if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($row, true)) . "<br>\n"; } $found = $tmp_type; } } } else { $to_person["phone"] = UPS_DEFAULT_SHIPPER_PHONE; } if ($debug == "yes") { echo __LINE__ . ":found = {$found}\n<br/>" . __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($to_person, true)) . "<br>\n"; } } else { $err["contactnotfound"] = "There is no contact tied to shippment"; } } else { $err["contactnotfound"] = "There is no contact tied to shippment"; } if ($order_info["weight"] == '0' or $order_info["weight"] == '') { $err["weightblank"] = "The weight is empty"; //$return["javascript"] .= "alert('Shipping Weight is not set');$('#shipping_weight').focus();$('#shipping_weight_div').css('background','#ff0000');"; $return["javascript"] .= ""; $return["stop"] = 'YES'; } if ($order_info["contact_first_name"] != '' or $order_info["contact_last_name"] != '') { $to_attr = $order_info["contact_first_name"] . " " . $order_info["contact_last_name"]; } else { $to_attr = $to_person["display_name"]; } //print_r($from_attr); // echo 'sadad'.count($err).'saa'; if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($err, true)) . "<br>\n"; } if (count($err) == 0) { //echo 'asa'; $ups = new ups(); $from_address = $ups->address_object(UPS_DEFAULT_FROM_STREET, UPS_DEFAULT_FROM_CITY, UPS_DEFAULT_FROM_STATE, UPS_DEFAULT_FROM_ZIP, UPS_DEFAULT_FROM_COUNTRY); //print_r($from_address); $to_address = $ups->address_object($address["street_address"], $address["city"], $ups->convert_statename_to_abbr($address["state"]), $address["zip"]); //print_r($to_address); $from = $ups->person_object(UPS_DEFAULT_SHIPPER_NAME, $from_attr, UPS_DEFAULT_SHIPPER_PHONE, $from_address, UPS_DEFAULT_SHIPPER_NUMBER); //print_r($from); if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($to_address, true)) . "<br>\n"; } if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($from_address, true)) . "<br>\n"; } $to = $ups->person_object($to_person["display_name"], $to_attr, $to_person["phone"], $to_address); //print_r($to); $xmlArr = $ups->run_shippment($from, $from, $to, $order_info["weight"], "LBS", $shipment_type, "02", 'Order - ' . $order_info["order_id"], $order_info["grant_total"]); //print_r($xmlArr); //echo str_replace(array("\n" , " "), array('<br/>', ' ' ), print_r($xmlArr["children"] , true)); //file_put_contents("request.xml", $xmlArr["sourceXML"] ); //file_put_contents("responce.xml", $xmlArr["originalXML"] ); /*$accept = $ups->AcceptShip($xmlArr["children"]["ShipmentDigest"][0]["value"]); $up_order = array(); $shipping_label = $accept["children"]["ShipmentResults"][0]["children"]["PackageResults"][0]["children"]["LabelImage"][0]["children"]["GraphicImage"][0]["value"]; $up_order["shipment_label"] = $shipping_label; if( $accept["children"]["ShipmentResults"][0]["children"]["ControlLogReceipt"][0]["children"]["GraphicImage"][0]["value"] != ''){ $hvr = $accept["children"]["ShipmentResults"][0]["children"]["ControlLogReceipt"][0]["children"]["GraphicImage"][0]["value"]; $up_order["shipment_hvr"] = $hvr; }*/ //$this->db->update('erp_order', $up_order, "order_id", $order_info["order_id"]); if ($debug == "yes") { echo __LINE__ . str_replace("\n", "<br>\n" . __LINE__ . ":", print_r($xmlArr, true)) . "<br>\n"; } $return = $xmlArr["children"]["ShipmentCharges"][0]["children"]["TotalCharges"][0]["children"]["MonetaryValue"][0]["value"]; //echo $return; } return $return; break; case "work order": break; } //return $return; }
public function getUPSresponse($cart, $method) { $vendorId = $this->vendor; $vendorModel = VmModel::getModel('vendor'); $vendorFields = $vendorModel->getVendorAddressFields(); $weight = 0; foreach ($cart->products as $product) { (double) ($product_weight = ShopFunctions::convertWeigthUnit($product->product_weight, $product->product_weight_uom, "LB")); $weight += $product_weight * $product->quantity; } if ($weight == 0) { JFactory::getApplication()->enqueueMessage("UPS Error: Product Weight not found", "error"); $this->clear(); $mainframe = JFactory::getApplication(); $redirectMsg = "UPS Error: Product Weight not found"; $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'), $redirectMsg); return FALSE; } $accessNumber = trim($method->api); $username = trim($method->username); $password = trim($method->password); $upsConnect = new ups($accessNumber, $username, $password); $upsConnect->setTemplatePath(JPATH_ROOT . '/plugins/vmshipment/jibon_ups/ups/xml/'); $upsConnect->setTestingMode($method->mood); // Change this to 0 for production $upsRate = new upsRate($upsConnect); $upsRate->request(array('Shop' => true)); $upsRate->shipper(array('name' => $vendorFields['fields']['first_name']['value'] . " " . $vendorFields['fields']['last_name']['value'], 'phone' => $vendorFields['fields']['phone_1']['value'], 'shipperNumber' => '', 'address1' => $vendorFields['fields']['address_1']['value'], 'address2' => '', 'address3' => '', 'city' => $vendorFields['fields']['city']['value'], 'state' => $vendorFields['fields']['virtuemart_state_id']['state_2_code'], 'postalCode' => $vendorFields['fields']['zip']['value'], 'country' => $vendorFields['fields']['virtuemart_country_id']['country_2_code'])); if (!is_array($cart->BT)) { JFactory::getApplication()->enqueueMessage("UPS Error: Please put valid shipping information !!", "error"); return false; } if (is_array($cart->ST)) { $upsRate->shipTo(array('companyName' => $cart->ST['company'], 'attentionName' => $cart->ST['first_name'] . " " . $cart->ST['last_name'], 'phone' => $cart->ST['phone_1'], 'address1' => $cart->ST['address_1'], 'address2' => '', 'address3' => '', 'city' => $cart->ST['city'], 'state' => ShopFunctions::getStateByID($cart->ST['virtuemart_state_id'], "state_2_code"), 'postalCode' => $cart->ST['zip'], 'countryCode' => ShopFunctions::getCountryByID($cart->ST['virtuemart_country_id'], "country_2_code"))); } else { $upsRate->shipTo(array('companyName' => $cart->BT['company'], 'attentionName' => $cart->BT['first_name'] . " " . $cart->BT['last_name'], 'phone' => $cart->BT['phone_1'], 'address1' => $cart->BT['address_1'], 'address2' => '', 'address3' => '', 'city' => $cart->BT['city'], 'state' => ShopFunctions::getStateByID($cart->BT['virtuemart_state_id'], "state_2_code"), 'postalCode' => $cart->BT['zip'], 'countryCode' => ShopFunctions::getCountryByID($cart->BT['virtuemart_country_id'], "country_2_code"))); } $upsRate->package(array('description' => 'my description', 'weight' => $weight, 'code' => '02', 'length' => 0, 'width' => 0, 'height' => 0)); $upsRate->shipment(array('description' => 'my description', 'serviceType' => '03')); //service type $upsRate->sendRateRequest(); $this->UPSresponse = $upsRate->returnResponseArray(); if (!empty($this->UPSresponse["RatingServiceSelectionResponse"]["Response"]["Error"]["ErrorCode"]) or empty($this->UPSresponse)) { $this->ups_rate = ""; $this->ups_service_name = ""; $this->ups_service_id = ""; $this->status = 0; $this->loadPost($method->virtuemart_shipmentmethod_id); JFactory::getApplication()->enqueueMessage("UPS Error: " . $this->UPSresponse["RatingServiceSelectionResponse"]["Response"]["Error"]["ErrorDescription"]["VALUE"], "error"); } $currency = CurrencyDisplay::getInstance(); if ($this->UPSresponse['RatingServiceSelectionResponse']['RatedShipment']) { foreach ($this->UPSresponse['RatingServiceSelectionResponse']['RatedShipment'] as $rate) { if ($this->ups_service_id === $rate["Service"]["Code"]["VALUE"]) { $this->ups_rate = $currency->convertCurrencyTo("USD", $rate["TotalCharges"]["MonetaryValue"]["VALUE"]); $this->ups_service_name = $this->getServiceName($rate["Service"]["Code"]["VALUE"]); $this->ups_service_id = $rate["Service"]["Code"]["VALUE"]; $this->save(); break; } } } return $this->UPSresponse; }
$results = explode("\n", $raw_results); $shipping_list = array(); foreach ($results as $result) { $result = explode("%", $result); if ($services[$result[1]] != '') { if ($result[1] == 'XPR' && $pre == 'XPR' || $result[1] == 'XDM' && $pre == 'XDM' || $result[1] == '1DP' && $pre == '1DP' || $result[1] == '1DM' && $pre == '1DM' || $result[1] == '1DA' && $pre == '1DA' || $result[1] == '2DA' && $pre == '2DA') { $shipping_list += array($services[$result[1] . "L"] => $result[8]); } else { if ($result[1] == 'GND' && $pre == 'GND') { $shipping_list += array($services[$result[1] . "RES"] => $result[8]); } else { $shipping_list += array($services[$result[1]] => $result[8]); } } $pre = $result[1]; } } $_SESSION['wpsc_shipping_cache_check']['zipcode'] = $zipcode; $_SESSION['wpsc_shipping_cache_check']['weight'] = $weight; $_SESSION['wpsc_shipping_cache'][$this->internal_name] = $shipping_list; } $shipping_list = array_reverse($shipping_list); //exit(); return $shipping_list; } function get_item_shipping() { } } $ups = new ups(); $wpsc_shipping_modules[$ups->getInternalName()] = $ups;
case 'delete': $shipment_id = db_prepare_input($_GET['sID']); $result = $db->Execute("select method, ship_date from " . TABLE_SHIPPING_LOG . " where shipment_id = " . (int) $shipment_id); $ship_method = $result->fields['method']; if ($result->RecordCount() == 0 || !$ship_method) { $messageStack->add(SHIPPING_FEDEX_DELETE_ERROR, 'error'); $error = true; break; } if ($result->fields['ship_date'] < date('Y-m-d', time())) { // only allow delete if shipped today or in future $messageStack->add(SHIPPING_FEDEX_CANNOT_DELETE, 'error'); $error = true; break; } $shipment = new ups(); if ($shipment->deleteLabel($shipment_id)) { $db->Execute("delete from " . TABLE_SHIPPING_LOG . " where shipment_id = " . $shipment_id); gen_add_audit_log(SHIPPING_UPS_LABEL_DELETED, $tracking_id); $messageStack->convert_add_to_session(); // save any messages for reload } else { $error = true; } break; default: $oID = db_prepare_input($_GET['oID']); $sql = "select shipper_code, ship_primary_name, ship_contact, ship_address1, ship_address2, \r\n\t\tship_city_town, ship_state_province, ship_postal_code, ship_country_code, ship_telephone1, \r\n\t\tship_email, purchase_invoice_id, purch_order_id, total_amount \r\n\t\tfrom " . TABLE_JOURNAL_MAIN . " where id = " . (int) $oID; $result = $db->Execute($sql); while (list($key, $value) = each($result->fields)) { $sInfo->{$key} = $value;
private function calc_package_shipping($weight) { $ups = new ups(); $shipping = $ups->get_item_shipping($weight, $this->zipcode); return $shipping; }
function updatefield($shipping_charge='',$old_shipping_charge='',$multiplier='',$old_multiplier='',$total='',$choice='',$auto_shipping=''){ ob_start(); $auto_shipping_flag = 0; $ups = new ups(); $shipping_type = $shipping_charge; switch( $shipping_charge ){ case "01": $shipping_charge = '75'; break; case "02": $shipping_charge = '50'; break; case "03": $shipping_charge = '30'; break; case "04": $shipping_charge = '0'; break; } // echo $shipping_charge.'aaaaaaa<br>'; $shipping_charge= $ups->estamate_shipping_by_module("order", $_REQUEST['order_id'], $shipping_type); if($auto_shipping != ''){ $shipping_charge = $auto_shipping; $auto_shipping_flag = 1; } // echo $shipping_charge.'aaaaaaa<br>'; //print_r($shipping_charge); switch($choice){ case 'shipping': $update_sql_array = array(); $update_sql_array["shipment_type"] = $shipping_type; $update_sql_array["shipping_charges"] = $shipping_charge; $update_sql_array["auto_shipping_charge"] = $auto_shipping_flag; $this->db->update(erp_ORDER,$update_sql_array,'order_id',$_REQUEST[order_id]); break; case 'multiplier': $update_sql_array = array(); $update_sql_array[multiplier] = $multiplier; $this->db->update(erp_ORDER,$update_sql_array,'order_id',$_REQUEST[order_id]); break; } /////end of switch $this->total_price = ($this->total_price + $shipping_charge) * $multiplier; $html=ob_get_contents(); ob_end_clean(); return $html; } ////////////end of function updatefield