Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Canada Post Expedited US Business change name


1 reply to this topic

#1 greasemonkey

  • Community Member
  • 53 posts
  • Real Name:Scott
  • Gender:Male

Posted 02 December 2011, 23:50

Hi everyone, I'm so not a coder... but I'm trying to change the name returned by the Canada Post shipping module for Expedited US Business and Small Package Air services

I've tried multiple versions of

}else
	   if ($product=='Expedited US Business')
{
$strProduct=('USPS Priority Mail');
}
else if($product=='Small Packets Air')
{
$strProduct=('Small Parcel');


But it would seem my syntax is wrong of I don't know where to put it... Any help would be apprciated... below is the code in question from canadapost.php


$strProduct = substr($resultXML, strpos($resultXML, "<product id=")+strlen("<product id=>"), strpos($resultXML, "</product>")-strlen("<product id=>")-strpos($resultXML, "<product id="));
	  $index = 0;
	  $aryProducts = false;
	  while (strpos($resultXML, "</product>")) {
	   $name = substr($resultXML, strpos($resultXML, "<name>")+strlen("<name>"), strpos($resultXML, "</name>")-strlen("<name>")-strpos($resultXML, "<name>"));
	   $rate = substr($resultXML, strpos($resultXML, "<rate>")+strlen("<rate>"), strpos($resultXML, "</rate>")-strlen("<rate>")-strpos($resultXML, "<rate>"));
	   //$shippingDate = substr($resultXML, strpos($resultXML, "<shippingDate>")+strlen("<shippingDate>"), strpos($resultXML, "</shippingDate>")-strlen("<shippingDate>")-strpos($resultXML, "<shippingDate>"));
//SB edit US delivery estimates
	   if ($name=='Small Packets Air')
{
$deliveryDate=('5 to 10 Business Days. Tracking number NOT available.');
}
else if($name=='Parcel Surface')
{
$deliveryDate=('4 to 12 Weeks');
}
else
{
$deliveryDate = substr($resultXML, strpos($resultXML, "<deliveryDate>")+strlen("<deliveryDate>"), strpos($resultXML, "</deliveryDate>")-strlen("<deliveryDate>")-strpos($resultXML, "<deliveryDate>"));
}
				//$deliveryDayOfWeek = substr($resultXML, strpos($resultXML, "<deliveryDayOfWeek>")+strlen("<deliveryDayOfWeek>"), strpos($resultXML, "</deliveryDayOfWeek>")-strlen("<deliveryDayOfWeek>")-strpos($resultXML, "<deliveryDayOfWeek>"));
	   //$nextDayAM = substr($resultXML, strpos($resultXML, "<nextDayAM>")+strlen("<nextDayAM>"), strpos($resultXML, "</nextDayAM>")-strlen("<nextDayAM>")-strpos($resultXML, "<nextDayAM>"));
	   //$packingID = substr($resultXML, strpos($resultXML, "<packingID>")+strlen("<packingID>"), strpos($resultXML, "</packingID>")-strlen("<packingID>")-strpos($resultXML, "<packingID>"));
	   list($year, $month, $day) = split("-", $deliveryDate);
	if (!tep_not_null($day)) {
	 $deliveryDate = $year;
	} else {
		$deliveryDate = date('F d, Y', mktime(0, 0, 0, $month, $day, $year));
	}
	   $aryProducts[$index] = array($name . ", <acronym title='Estimated Delivery Date'>EDD</acronym>: " . $deliveryDate => $rate);
	   $index++;
	   $resultXML = substr($resultXML, strpos($resultXML, "</product>") + strlen("</product>"));
	  }
	  return $aryProducts;
	 } else {
	  if (strpos($resultXML, "<error>")) return $statusMessage;
	  else return false;
	 }
	}
  }


#2 greasemonkey

  • Community Member
  • 53 posts
  • Real Name:Scott
  • Gender:Male

Posted 06 December 2011, 01:38

Not having much luck... any ideas?

My latest is

if (strpos($resultXML, 'Expedited US Business'))
{
$resultXML=('USPS Priority Mail');
}else{
$resultXML = substr($resultXML, strpos($resultXML, "</product>") + strlen("</product>"));
}