Edit file File name : printLabel.phpbkp Content :<?php include("../include/config.php"); include("../include/functions.php"); include("../include/CourierService.php"); if ($_REQUEST['submitForm'] == 'yes') { $itemarr = $_POST['itemid']; $itemweight = $_POST['weight']; $weight = number_format(array_sum($itemweight),2); $orderid = $_POST['order_id']; $storeid = $_REQUEST['store']; if (count($itemarr) > 0) { $item_ids = implode(",", $itemarr); if ($orderid != '') { $sql = $obj->query("select * from tbl_order where id='$orderid'"); $result = $obj->fetchNextObject($sql); $sqlitem = $obj->query("select * from tbl_order_itmes where order_id='$orderid' and storeid='$storeid' and id in ($item_ids)"); $resultitem = $obj->fetchNextObject($sqlitem); } $_SESSION['sess_msg'] = "Label Generated Successfully.!"; } else { $_SESSION['sess_msg'] = "Label can not be generated.!"; } } //echo '<pre>'; // print_r($result); // exit; $print_label = ''; //print_r($obj); $ups = new CourierService($obj); $ups->setCarrier("UPS"); $ups->setOrderNumber($orderid); $ups->setStoreId($storeid); $ups->setShipFromName("Fresh Farms"); $ups->setShipFromAddressLine1("2626 W Devon Ave"); $ups->setShipFromCityLocality("Chicago"); $ups->setShipFromStateProvince("IL"); $ups->setShipFromPostalCode("60659"); $ups->setShipFROMCountryCode("US"); $ups->setShipToName($result->ship_fname . " " . $result->ship_lname); /*$ups->setShipToAddressLine1("914 Capitol Mall"); $ups->setShipToCityLocality("Sacramento"); $ups->setShipToStateProvince("CA"); $ups->setShipToPostalCode("95814");*/ $ups->setShipToAddressLine1($result->ship_house_no . " " . $result->ship_complex . " " . $result->ship_street); $ups->setShipToCityLocality($result->ship_city_id); $ups->setShipToStateProvince($result->ship_state); $ups->setShipToPostalCode($result->ship_pincode); $ups->setShipToCountryCode("US"); $ups->setTransactionReference($orderid); $ups->setBoxType("Small"); $ups->setWeight($weight); $ups->setUnitCode("LBS"); $ups->setShipper_Tax_Identification_Number('456999'); //$ups->getShipper_Tax_Identification_Number(); $ups->setShipperPhoneNumber('2243660987'); $ups->setShipToName($result->ship_fname . " " . $result->ship_lname); $ups->setShipToPhone($result->ship_mobile); $ups->setShipFromTaxIdentificationNumber('456999'); $ups->setShipFromPhone('2243660987'); $ups->setShipperNumber('7WY966'); $label = json_decode($ups->getShippingLabel()); echo '<pre>'; print_r($ups); //print_r(json_encode($ups->getError())->Status->result==false); $errors = (json_decode($ups->getError())); //print_r($errors); //echo (string)$errors->Status->result.'-----------'; //exit(); if (isset($errors->Status->result) && $errors->Status->result === false) { //print_r($errors->Status); echo "ddd".$errors->Status->message; //echo '<pre>'; // print_r($label->Status->CarrierResponse); exit; } $trackingNo = $label->Status->CarrierResponse->ShipmentResponse->ShipmentResults->PackageResults->TrackingNumber; $print_label = '<img src="data:image/png;base64,' . $label->Status->CarrierResponse->ShipmentResponse->ShipmentResults->PackageResults->ShippingLabel->GraphicImage . '"/>'; $obj->query("update tbl_order set tracking_no='$trackingNo' where id='$orderid'"); //echo '<pre>'; //print_r($label); //$label=json_decode($ups->getRates()); /*echo $ups->isError(); $isError=$ups->isError(); if ( $isError==true) { print_r($ups->getError()); }else{*/ //if($label->Status->result===true){ // echo '<img src="data:image/png;base64,'.$label->Status->CarrierResponse->ShipmentResponse->ShipmentResults->PackageResults->ShippingLabel->GraphicImage.'"/>'; //} // else // echo 'Error While creating label'; //} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo SITE_TITLE; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link href="css/admin.css" rel="stylesheet" type="text/css"/> </head> <body> <?php echo $print_label; ?> </body> </html> <script> var is_chrome = function () { return Boolean(window.chrome); } if (is_chrome) { window.print(); setTimeout(function () { window.close(); }, 20000); //give them 10 seconds to print, then close } else { window.print(); window.close(); } </script> Save