News:

Looking for documentation? Take a look on our wiki

Main Menu

DHL Percentage Handling

Started by jonahcoyote, July 26, 2008, 19:48:52 PM

Previous topic - Next topic

jonahcoyote

Hi all, by default it appears that DHL does not tack on the handling by percentage but rather by dollar amount. For example, the default handling for DHL is set to 6% in the admin and all it does is add $6 to the total shipping amount.

I think I've figured out a way to have it calculate by percentage instead. This will only work for either or though. It would ideally be nice to have a drop down that lets you first select if you want a flat rate handling or percentage and then calculate accordingly. So, first decide what you want. If you want percentage based handling then follow these instructions:

Open up administrator/components/com_virtuemart/classes/shipping/dhl.php and find this line (around 487):

$total_rate = $ship_rate + floatval(DHL_HANDLING_FEE);

Here you can see that all it does is add the ship rate and handling fee together instead of multiplying for a percentage.

Comment that line out and add the following below:

$cart = $_SESSION['cart'];

for ($i = 0; $i < $cart['idx']; $i++) {
$item_value = $this->get_duty_value(
    $cart[$i]['product_id']) * $cart[$i]['quantity'];
}
$percentage_handling = $item_value * floatval(DHL_HANDLING_FEE);
$total_rate = $ship_rate + $percentage_handling;
$ship_postage = $CURRENCY_DISPLAY->getFullValue(
$total_rate);


This first gets the value of the items in the cart and then takes the value and multiplies it by the handling fee. Then that handling fee is added to the ship rate.

For this to work, you must also set your DHL handling fee to a percentage value formatted in decimal value. So for 6% you would type in .06

I hope this helps others out there and please let me know if anyone finds any flaws in this change.

Thanks,
Jonah
VM 1.1.0 & Joomla 1.5.3

titoch67

#1
Hello, everybody

I want to add a percentage on shipping rate in the shipping process 'cause i don't want to calculate all the shipping rates (many many rates to correct after: 2280 exactly). Is there a way to add a $ in calculation during the process to facilitate the operation. I have searched on virtuemart forum and french joomla forum but i don't have found what i want, only your post.
I search something looking like this:
total shipping rate = shipping rate + percentage
I just want to precise that my shipping rates at the begging not include VAT, the percentage is a margin which my customer takes on transport on the basis of the price out-tax of transport.

Hope i'm clear in my explication.

All suggestions will be appreciated. Thank you with all for your answers.

if i see right could i apply your script in standard_shipping.php with modification to my own usage for calculate the percentage add to the shipping rate? can you tell me please.

thanks a lot.

jhoompk

Hi,

You need to use flex shipping module instead of standard_shipping.

That will solve the problem for the people who want to calculated by either fixed shipping rates or a percentage of the cart subtotal.

Thanks
Aamir