BigCommerce - Hosted Ecommerce Software by Interspire

Interspire Forum

 
Go Back   Interspire Forum > Interspire Shopping Cart Community Forum > Customization and Integration > Code Modification and Addon Releases

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2008, 08:33 AM
Funky Monkey + Funky Monkey is offline
Interspire Customer
 
Join Date: Nov 2008
Posts: 20
Default Track multiple shipments

Version 4.0 added multiple shipments per order, but when customers view their order status the tracking numbers are not displayed (it only displays a single tracking number per order). So I wrote a quick hack to show tracking numbers in this situation:

In class.account.php:

Find the following code:
Code:
if ($row['ordtrackingno'] != "0") {
	$GLOBALS['HideTrackingText'] = "";
	$GLOBALS['OrderTrackingNo'] = isc_html_escape($row['ordtrackingno']);

	// Let's instantiate an object for the shipper
	$shipper_object = false;
	if ($row['ordershipmodule'] != "" && GetModuleById('shipping', $shipper_object, $row['ordershipmodule'])) {

		// Does it have a link to track the order?
		if ($shipper_object->GetTrackingLink() != "") {
			// Show the tracking link
			$GLOBALS['TrackURL'] = $shipper_object->GetTrackingLink();
			$GLOBALS['HideTrackingLink'] = "";
		}
		else {
			// Hide the tracking link
			$GLOBALS['HideTrackingLink'] = "none";
		}
	}
	else {
		$GLOBALS['HideTrackingLink'] = "none";
	}
}
else {
	$GLOBALS['HideTrackingText'] = "none";
	$GLOBALS['HideTrackingLink'] = "none";
}
And afterwards add the following:
Code:
// scan shipments list
$shipmentquery = "SELECT s.* FROM [|PREFIX|]shipments s WHERE shiporderid={$row['orderid']}";
$result = $GLOBALS['ISC_CLASS_DB']->Query($shipmentquery);
$aTrackingNos = array();
while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($result))
{
	if ($shipment['shiptrackno'] != "")
	{
		$trackstr = "<strong><em>" . isc_html_escape($shipment['shiptrackno']) . "</em></strong>";;

		$trackno = $shipment['shiptrackno'];
		$trackno = str_replace (' ', '', $trackno);	// remove spaces
		//validate $shipment['shiptrackno']
		if (preg_match('/^(\d+)$/',$trackno))
		{
			// all numeric - must be USPS????
			$trackstr .= "&nbsp;&nbsp;&nbsp;USPS";
			$trackstr .= "&nbsp;&nbsp;&nbsp;<a href='http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum={$trackno}'>Track</a>";
		}
		else
		{
			// contains one or more non-numerals
			// for my store that means UPS!
			$trackstr .= "&nbsp;&nbsp;&nbsp;UPS";
			$trackstr .= "&nbsp;&nbsp;&nbsp;<a href='http://www.ups.com/WebTracking/track?loc=en_US&WT.svl=PNRO_L1'>Track</a>";
		}

		$aTrackingNos[] = $trackstr;
	}
}

if (count($aTrackingNos))
{
	if (count($aTrackingNos) > 1)
	{
		$GLOBALS['HideTrackingText'] = "none";
		$GLOBALS['HideTrackingLink'] = "none";
		$GLOBALS['HideTrackingTextMulti'] = "";
		$GLOBALS['OrderTrackingMulti'] = "";
		foreach ($aTrackingNos as $key=>$value)
		{
			$GLOBALS['OrderTrackingMulti'] .= $value;
			$GLOBALS['OrderTrackingMulti'] .= "<br>";
		}
	}
	else
	{
		$GLOBALS['HideTrackingText'] = "";
		$GLOBALS['HideTrackingLink'] = "none";
		$GLOBALS['HideTrackingTextMulti'] = "none";
		$GLOBALS['OrderTrackingNo'] = $aTrackingNos[0];
	}
}
Then open up AccountOrderStatusItem.html:

Where you see:
Code:
<span style="display:%%GLOBAL_HideTrackingText%%">
	%%LNG_OrderTrackingNoIs%% <strong><em>%%GLOBAL_OrderTrackingNo%%</em></strong>
</span>
Add immediately afterwards:
Code:
<span style="display:%%GLOBAL_HideTrackingTextMulti%%">
<br>This order has multiple tracking numbers:<br>
%%GLOBAL_OrderTrackingMulti%%
</span>
And that's it! Of course you'll see that in my ghetto code I only check for USPS and UPS because those are the only carriers I support. There's another thread somewhere in the forums that describes how to build tracking links for various carriers, so that is an exercise for the reader to implement.

Enjoy.

Last edited by Funky Monkey; 12-28-2008 at 07:29 PM..
Reply With Quote
  #2  
Old 12-28-2008, 03:55 AM
moe80
Guest
 
Posts: n/a
Default

He Funky,

I am getting this error when I try your HACK:

PHP Code:
Parse errorsyntax errorunexpected T_ELSEexpecting T_FUNCTION in /home/cwt/public_html/extra/includes/classes/class.account.php on line 1324 
Any Idea??

Thanks in advance..
Reply With Quote
  #3  
Old 12-28-2008, 07:31 PM
Funky Monkey + Funky Monkey is offline
Interspire Customer
 
Join Date: Nov 2008
Posts: 20
Default Oops, extra curly brace

When I cut-n-pasted my code into the forum I accidentally added an extra curly brace that shouldn't have been there

I have edited the code in my original post so it should work now.

HINT: I removed the extra closing curly brace in the block of code where I decide that the tracking is UPS.

Hope it works for you now!
Reply With Quote
  #4  
Old 12-28-2008, 08:58 PM
moe80
Guest
 
Posts: n/a
Default

Works Like a charm .... I really appreciate your help...
Reply With Quote
  #5  
Old 12-30-2008, 05:38 PM
teebo + teebo is offline
Interspire Customer
 
Join Date: Oct 2008
Posts: 125
Default

How can we adapt this to look for fedex numbers as well? We use ups, fedex, and usps.
This would be a great mod to do, currrently we modded the tracking to link to a tracking page, but as you can guess it all leads to just that one provider, so if you ship usps and the tracking is ups, the customer thinks something is fishy, so if the system can automatically tell who is the provider it would work wonders.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump