[HACK] Altering formatting for Shipping Quotes.
Posted: Wed Jun 17, 2009 7:27 pm
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:
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:
The key bit is the:
So to take the earlier example in the earlier post you would edit that to:
Alternatively if you wanted to reduce "Royal Mail" down to "RM" you would need to edit the whole code nugget from this:
to this:
.. this would output a shipping quote of
Hopefully that makes sense...
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;
}
}
Code: Select all
if($include_shipper_name) {
return sprintf("%s (%s)", $this->_shippername, $this->_desc);
}
Code: Select all
return sprintf("%s (%s)", $this->_shippername, $this->_desc);
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);
}
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);
}
.. instead of:RM: First Class £1.62
Royal Mail (First Class) £1.62
Hopefully that makes sense...