I experienced another issue with the flat rate fee that my customer wanted.
The customer wanted a minimum of $8.00 for shipping, but anything greater than $8.00 add a 20% handling fee.
I had a difficult time getting the UPSXML module to calculate a 20% handling fee. I saw some instructions that stated to use 20.0 for a % but that was just adding $20.00 to the shipping cost.
Here is what I did.
Code:
// change the 8.00 to whatever MINIMUM charge you want for the UPS Shipping Fee
$oldHandlingFee = $this->handling_fee;
$cost = ($cost < 8.00 ? 8.00 : $cost);
//print "BEFORE | $type, Shipping Cost = $cost, Handling Fee = $handlingFee, " . $this->handling_fee . "<br />";
if( strstr( $this->handling_fee, "%" ) ) {
$isPercent = 1;
} else {
$isPercent = 0;
}
if( $isPercent ) {
if( floatval($cost) <= 8.00 ) {
$handlingFee = 0;
$this->handling_fee = $handlingFee;
} else {
$handlingFee = ( $cost * ( floatval( $this->handling_fee ) / 100 ) );
$this->handling_fee = $handlingFee;
}
}
// debugging
//print "AFTER | $type, Shipping Cost = $cost, Handling Fee = $handlingFee, " . $this->handling_fee . "<br />";
$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee + $cost));
// set the handling fee back to its original value to calc the rest of the shipping handling fees
$this->handling_fee = $oldHandlingFee;
What I did was put 20% in the handling fee field when in Admin->Modules->Shipping->UPSXML
It now works beautifully.