Post by marcelwoo » Tue Jul 12, 2011 12:00 am

open: admin\view\template\sale\order_list.tpl

(1) Find:

Code: Select all

<td class="left"><?php echo $order['status']; ?>
and add after:

Code: Select all

			<!--begin custom tracking code-->
			<!-- **READ ME** "Pending" must match the text used for pending orders which need shipped-->
			<?php if ($order['status'] == "Pending") { ?>
			<input id="trk_<?php echo $order['order_id']; ?>" name="txt_<?php echo $order['order_id']; ?>" type="text" size="30" /> 
			<input type="button" id=btn_<?php echo $order['order_id']; ?> onclick="update_history(<?php echo $order['order_id']; ?>);" value="Ship"> 
			<?php } ?>
			<!--end custom tracking code-->	
(2)Find:

Code: Select all

<?php foreach ($order['action'] as $action) { ?>
and add before:

Code: Select all

			  <!--begin invoice link-->
			  [ <a target="_blank" href="index.php?route=sale/order/invoice&token=<?php echo $token; ?>&order_id=<?php echo $order['order_id']; ?>">Invoice</a> ]&nbsp;&nbsp;
			  <!--end  invoice link-->
(3)Find:

Code: Select all

function filter() {
and add before:

Code: Select all

///////////////////////////////////////////////////////////////////////
//////////////////BEGIN BULK TRACKING UPDATER CODE/////////////////////
///////////////////////////////////////////////////////////////////////
var err = 0;
function update_history(oid) 
{
	err = 0;
	//var txt = $('input[name=\'txt_'+oid+'\']').val();
	var num = $('input[name=\'txt_'+oid+'\']').attr('value');	
	
	//remove spaces from begining and end
	num = num.replace(/^\s+|\s+$/g,"") + "";
	
	//make sure filed is not blank
	if(num == "")
	{alert("The Tracking Number Field Cannot be Empty"); return;}	
	
	//parse for USPS, UPS, FedEx, DHL, ect...
	var txt = GetTrackMessage(num);
	
	//check if we could not fiqure out the tracking number format
	//alert(txt);
	if(err == 1)
	{ 
		var ret = confirm("Tracking number format is unknown\n\nDo you want to continue?");
		if(!ret){return;}
	}
	
	//**READ ME**
	//order_status_id=3
	//the order status ID below in the ajax function must match the order status ID number of your status "Shipped"
	$.ajax({
		type: 'POST',
		url: 'index.php?route=sale/order/history&token=<?php echo $token; ?>&order_id='+oid,
		dataType: 'json',
		data: 'order_status_id=3&notify=1&append=1&comment=' + encodeURIComponent(txt),
		beforeSend: function() { $('#btn_'+oid).remove(); },
		complete: function() { $('textarea[name=\'tkt_'+oid+'\']').val('complete'); },
		success: function(data) { filter(); }
		});
}

//create a tracking number messaged based on the tracking number format
function GetTrackMessage(n)
{
	var s = "";
	n = n.toUpperCase();

	//get customized message based on type of tracking number...
	if(IsUSPSExpress(n))
	{ s = "USPS Express Mail Tracking: " + n + ", Thanks!";	}
	else if(IsUSPSInternatinal(n))
	{s = "USPS International Label Number: " + n + ", note: some international packages might not be trackable at the usps website, expected delivery time to your country is 5 to 10 business days, this may vary depending on customs, Thank you!"; }
	else if(IsUSPS(n))
	{ s = "USPS Tracking Number: " + n + ", Thanks!"; }
	else if(IsUPS(n))
	{ s = "UPS Tracking Number: " + n + ", Thanks!"; }
	else if(IsFedEx(n))
	{ s = "FedEx Tracking Number: " + n + ", Thanks!"; }
	else if(IsDHL(n))
	{ s = "DHL Tracking Number: " + n + ", Thanks!"; }
	else//could not figure out the tracking number type
	{ s = "Tracking Number: " + n + ", Thanks!"; err = 1; }
	return s;
}

//13 characters, first and last 2 are letters, first letter is E
function IsUSPSExpress(n)
{
	var len = n.length;
	if(len != 13){return false;}
	var end = n.substr(len-2);//grab last 2 chars "US"
	var top = n.substr(0,1);//grab first chars "EC"
	var mid = n.substr(2,9);//grab middle section "numbers"
	if(IsNumeric(end)){return false;}
	if(IsNumeric(top)){return false;}
	if(!IsNumeric(mid)){return false;}
	if(n.substr(0,1) != "E"){return false;}//first letter must be E
	return true;
}

//13 characters, first and last 2 are letters, first letter is L
function IsUSPSInternatinal(n)
{
	var len = n.length;
	if(len != 13){return false;}
	var end = n.substr(len-2);//grab last 2 chars "US"
	var top = n.substr(0,1);//grab first chars "EC"
	var mid = n.substr(2,9);//grab middle section "numbers"
	if(IsNumeric(end)){return false;}
	if(IsNumeric(top)){return false;}
	if(!IsNumeric(mid)){return false;}
	if(n.substr(0,1) != "L"){return false;}//first letter must be L
	return true;
}

//22 digit number
function IsUSPS(n)
{
	if(n.length != 22){return false;}
	if(!IsNumeric(n)){return false;}
	return true;
}

//starts with 1Z
function IsUPS(n)
{
	if(n.substr(0,2) != "1Z"){return false;}//first letters must be 1Z
	return true;
}

//12 digit numeric
function IsFedEx(n)
{
	if(n.length != 12){return false;}
	if(!IsNumeric(n)){return false;}
	return true;
}

//10 or 11 digit numeric
function IsDHL(n)
{
	var len = n.length
	if(len < 10 || len > 11){return false;}//must be 10 or 11 digits
	if(!IsNumeric(n)){return false;}//must be numeric
	return true;
}

function IsNumeric(strString)
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	if(strString.length == 0){return false;}
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
	  strChar = strString.charAt(i);
	  if(strValidChars.indexOf(strChar) == -1){blnResult = false;}
	}
	return blnResult;
}
///////////////////////////////////////////////////////////////////////
//////////////////END BULK TRACKING UPDATER CODE///////////////////////
///////////////////////////////////////////////////////////////////////
That's all!

If you know a bit about javascript, you can add codes into the third part of codes above to parse any kind of tracking number. 12oclocker has commented the codes very well and clearly. So I guess you won't have trouble finding where to add your own codes.

This part is about how to parse tracking numbers:


//13 characters, first and last 2 are letters, first letter is L
function IsUSPSInternatinal(n)
{
var len = n.length;
if(len != 13){return false;}
var end = n.substr(len-2);//grab last 2 chars "US"
var top = n.substr(0,1);//grab first chars "EC"
var mid = n.substr(2,9);//grab middle section "numbers"
if(IsNumeric(end)){return false;}
if(IsNumeric(top)){return false;}
if(!IsNumeric(mid)){return false;}
if(n.substr(0,1) != "L"){return false;}//first letter must be L
return true;
}

//22 digit number
function IsUSPS(n)
{
if(n.length != 22){return false;}
if(!IsNumeric(n)){return false;}
return true;
}

//starts with 1Z
function IsUPS(n)
{
if(n.substr(0,2) != "1Z"){return false;}//first letters must be 1Z
return true;
}

//12 digit numeric
function IsFedEx(n)
{
if(n.length != 12){return false;}
if(!IsNumeric(n)){return false;}
return true;
}

//10 or 11 digit numeric
function IsDHL(n)
{
var len = n.length
if(len < 10 || len > 11){return false;}//must be 10 or 11 digits
if(!IsNumeric(n)){return false;}//must be numeric
return true;
}

function IsNumeric(strString)
{
var strValidChars = "0123456789";
var strChar;
var blnResult = true;
if(strString.length == 0){return false;}
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if(strValidChars.indexOf(strChar) == -1){blnResult = false;}
}
return blnResult;


Enjoy, opencarters!
Last edited by marcelwoo on Sun Mar 25, 2012 4:09 pm, edited 2 times in total.

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by 12oclocker » Tue Jul 12, 2011 9:23 pm

good job marcelwoo....

Another thing to note...
Whoever adds this code needs to read the **READ ME** notes in it to configure it...
There are two variables that may need configured based on your opencart settings...
here they are....
......$order['status'] == "Pending".....
......data: 'order_status_id=3.......

Active Member

Posts

Joined
Fri Feb 19, 2010 10:50 am

Post by chokoret » Sun Jul 31, 2011 1:41 am

This is Fantastic!
May I suggest something ?
once I click 'ship' button with tracking number the field and button disappears-
so if i made a mistake (ex) typo, or tracking number for wrong item), it will be nice if i can still modify it as leaving the field with submitted tracking number filled in along with button - just like quantity box in cart page

User avatar
New member

Posts

Joined
Thu Jun 09, 2011 1:26 am
Location - Los Angeles, CA

Post by scanreg » Thu Oct 13, 2011 12:19 am

more batch order processing capability would be outstanding :)

oops, just found this:

http://www.opencart.com/index.php?route ... on_id=3296

Active Member

Posts

Joined
Thu May 06, 2010 12:15 am

Post by Mike Guenther » Thu Oct 13, 2011 1:57 am

I get error messages on my Order management page after uploading the file and verifying the code is correct as per instructions.

Can anyone give me some direction based off of the screenshot provided?

Thanks,

MG

Attachments

SS.jpg

SS.jpg (305.68 KiB) Viewed 4998 times


Active Member

Posts

Joined
Thu Oct 13, 2011 12:00 am

Post by habibieu2 » Wed Mar 07, 2012 10:27 am

do you have for 1.5.2.1 ??

http://www.RodaEmpat.net


User avatar
Newbie

Posts

Joined
Mon Mar 05, 2012 9:55 am

Post by nick5000 » Mon Jun 08, 2015 1:19 pm

I'm willing to pay to get this working for OC 2.0.

New member

Posts

Joined
Fri Apr 13, 2012 2:25 pm
Who is online

Users browsing this forum: No registered users and 7 guests