(1) Find:
Code: Select all
<td class="left"><?php echo $order['status']; ?>
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-->
Code: Select all
<?php foreach ($order['action'] as $action) { ?>
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> ]
<!--end invoice link-->
Code: Select all
function filter() {
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¬ify=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///////////////////////
///////////////////////////////////////////////////////////////////////
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!