[HACK] Altering formatting for Shipping Quotes.

For Articles relating to more than one ISC version
Post Reply
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

[HACK] Altering formatting for Shipping Quotes.

Post by Martin »

This KB Article deals with altering the formatting provided for the shipping quotes, etc...

Usually you will see... £1.xx (Royal Mail) or similar and it's the last part (Royal Mail) that this hack deals with...

The actual code used is in the "includes/classes/class.shipping.quote.php" file

This function:

Code: Select all

		function getdesc($include_shipper_name=false)
		{

			// Hack for Intershipper and FedEx
			$this->_desc = str_replace("FedEx FedEx", "FedEx", $this->_desc);
			$this->_desc = str_replace("FedEx FDX", "FedEx", $this->_desc);

			if($this->_desc != "") {
				if($include_shipper_name) {
					return sprintf("%s (%s)", $this->_shippername, $this->_desc);
				}
				else {
					return $this->_desc;
				}
			}
			else {
				return $this->_shippername;
			}
		}
Having looked through the code it seems you would have to change a number of calls to getdesc() using "false" instead of true to get this to work but to be honest if all you want to do is use a slightly different format all you need to do is edit the line above:

Code: Select all

				if($include_shipper_name) {
					return sprintf("%s (%s)", $this->_shippername, $this->_desc);
				}
The key bit is the:

Code: Select all

return sprintf("%s (%s)", $this->_shippername, $this->_desc);
So to take the earlier example in the earlier post you would edit that to:

Code: Select all

return sprintf("%s: %s", $this->_shippername, $this->_desc);

Alternatively if you wanted to reduce "Royal Mail" down to "RM" you would need to edit the whole code nugget from this:

Code: Select all

			// Hack for Intershipper and FedEx
			$this->_desc = str_replace("FedEx FedEx", "FedEx", $this->_desc);
			$this->_desc = str_replace("FedEx FDX", "FedEx", $this->_desc);

			if($this->_desc != "") {
				if($include_shipper_name) {
					return sprintf("%s (%s)", $this->_shippername, $this->_desc);
				}
to this:

Code: Select all

			// Hack for Intershipper and FedEx
			$this->_desc = str_replace("FedEx FedEx", "FedEx", $this->_desc);
			$this->_desc = str_replace("FedEx FDX", "FedEx", $this->_desc);

				// Hack for RoyalMail
			$this->_desc = str_replace("Royal Mail", "RM", $this->_desc);

			if($this->_desc != "") {
				if($include_shipper_name) {
					return sprintf("%s: %s", $this->_shippername, $this->_desc);
				}
.. this would output a shipping quote of
RM: First Class £1.62
.. instead of:
Royal Mail (First Class) £1.62

Hopefully that makes sense...
The Impossible can be on your desk by lunchtime, Miracles will take a little longer
SnailSolution Interspire Mods/Hacks store
Post Reply