Is it possible to make the handling fee a percentage of the actual shipping cost?
Printable View
Is it possible to make the handling fee a percentage of the actual shipping cost?
You can customize the Shipping Modules in any manner that you need ...
On Handling fees, you will see where the constant is used ... change it to treat that as a percentage of the shipping rather than an amount ...
Zen Cart 1.3.7
My client wanted to have a 20% handling fee. They are using UPS.
Here's what I did:
includes/modules/shipping/ups.php
changed this line:
to:Code:'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING) * $shipping_num_boxes);
Then in admin: Modules >> Shipping >> UPS I set the handling to .2Code:'cost' => ($cost + ($order->info['subtotal'] * MODULE_SHIPPING_UPS_HANDLING)) * $shipping_num_boxes);
jmcdog - this takes a percentage of the total order not a percent of the UPS shipping charge:
example.
Checkout total is $20.00
UPS ground is $5.00
You method adds $2 (assuming 10% handling) making shipping $7.00.
What I would like is take 10% of $5.00 making shipping now $5.50.
The problem I see is that a $200.00 order would pay $20 shipping even if the $20 and $200 order both weigh the same.
I tried to change some variables around in the ups.php but I am no PHP expert and seemed to always choose the wrong thing.
i can set handling fee for 5% from my subtotal, but how to set it if i want to charge 5% from subtotal as well as shipping?
eg.:
Subtotal $50
Shipping $10
Total $60
I want to charge handling base on $60
You would need to add the $cost into where the handling fee is calculated ...
Hello- Hope I'm not high jacking this thread but it seemed like the right place to post.
---v1.3.9.f
--- add module two modules by Numinux, Ajax quick checkout and fedex
The problem is it seems that my site adds $3 per line ordered as a handling fee-
If you order several items the handling fee gets out of hand.
here is my site
vwsunroofs dot com
thanks
John
Found my problem-- under the order total module- it does not recognize the "%" sign- so it added $3 instead of 3%
does anyone know how to make it a percent?
John
Which Order Total Module are you trying to use a percentage in? :unsure:
I don't have a dedicated mod for the handling- I was referring to the order total- under "modules" for zencart
Admin-
modules-
order total-
handling fee-
but I still can't make it a percentage--
thanks
John
Where in the Modules ... Order Totals ... are you seeing a Handling Fee? :unsure:
The Handling Fees are in the Modules ... Shipping ... on each of the Shipping modules ... but you have me a bit lost here ...
Granted, I am only on my first cup of coffee and could be missing something ... but whatchu talk'n about willis? :blink:
Does this help?
John
I see you are using some sort of Add On for your Handling Fee and not the Handling Fee on the individual Shipping modules ...
Do you know what add on you are using?
Hey everyone sorry if I'm reviving this old thread but it covers the basis of my question. I'm rocking v 1.3.9h and im looking to do the % based handling fee for usps. I tried changing the code to what was suggested but to no avail.
So would there be any type of other fixes you guys would know of. By chance try and reply as soon as you can, as this is one of the last steps I have left to setting up the site. Thanks for you time and answers in advance.
What did you enter for the Handling Fee on USPS ...
What did you change the code to on the USPS shipping module? :unsure:
Well I figured it out:clap:
The finished result was two fold. For our Free Shipping we added a 3% charge for PayPal transactions and $2.75 handling charge to cover shipping overhead. For our USPS module (priority, express, international shipping and PayPal charges we added a 5% charge plus $1.70.
No need to have an additional "Handling Fee" on the Shipping Module, this formula by-passes that.
USPS Shipping:
/public_html/includes/modules/shipping/usps.php
insert " +($order->info['subtotal'] * .05 + 1.70) into Line 298
where ($order->info['subtotal'] is your subtotal price * percent + overhead shipping cost.
Orginal:
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
Updated:
'cost' => ($cost * $shipping_num_boxes) + ($order->info['subtotal'] * .05 + 1.70) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
Free Shipping:
/public_html/includes/modules/shipping/freeoptions.php
insert "($order->info['subtotal'] * .03 + 2.75) +"
where ($order->info['subtotal'] is your subtotal price * percent + overhead shipping cost.
Orginal:
'cost' => MODULE_SHIPPING_FREEOPTIONS_COST + MODULE_SHIPPING_FREEOPTIONS_HANDLING)));
Updated:
'cost' => MODULE_SHIPPING_FREEOPTIONS_COST + ($order->info['subtotal'] * .03 + 2.75) + MODULE_SHIPPING_FREEOPTIONS_HANDLING)));
Hope this helps anyone else out there.
Thanks for the update that you have this working now and how you did it ... :smile:
Hey, I'm looking and I don't see any handling fee under this module. Is this an add on?
There is a Handling fee on USPS ... what version of Zen Cart are you using? :unsure:
Regarding the solution in #17, is this percentage added to the order total or calculated shipping cost of order based on weight? Am needing to do similar and want to confirm it is based on the shipping amount vs the entire order. Thank you for any info.
Thank you for posting your solution, it works nicely. For info my question about what the percent is calculated on, it appears to be order total.
Hello:
I hate to keep this thread going, but based on the title, I think it applies to my dilemma. I am using the latest version of Zen Cart, and I am looking to apply a percentage-based handling fee to my shipping. I am using a priced-based table rate and would like to add a 5% handling fee based on total cost after taxes. I know from reading the other posts as well as other threads where to find the module's php, but am confused on how I would be able to change the formula to multiply by the handling fee instead of adding the fee.
Please help! Thanks!
Ok, this worked on the old version, but it doesn't seem to work on the January 2012 update. Anyone know what I might need to do different or what I'm doing wrong? I'm using .03 + 1.75 for the USPS module.
website: http://earthscauldron.com/store/
Add this line in RED to the code and see what is being calculated:
Code:$cost = preg_replace('/[^0-9.]/', '', $cost);
// add $this->usps_countries to title to test actual country
echo 'I See USPS Cost: ' . $cost . ' Extra: ' . ($order->info['subtotal'] * .03 + 1.75) . ' = ' . (($order->info['subtotal'] * .03 + 1.75) + $cost) . '<br>';
ya, shows it's only adding 1.75 and not the 3%
Could you paste what you see from the echo?
I See USPS Cost: 31.25 Extra: 1.75 = 33
I See USPS Cost: 5.65 Extra: 1.75 = 7.4
I See USPS Cost: 5.55 Extra: 1.75 = 7.3
Estimate Shipping Costs
Total Items: 1 Amount: $140.00
Country: Please Choose Your Country United States Australia Canada United Kingdom United States Minor Outlying Islands
State/Province: Please select ...AlabamaAlaskaAllAmerican SamoaArizonaArkansasArmed Forces AfricaArmed Forces AmericasArmed Forces CanadaArmed Forces EuropeArmed Forces Middle EastArmed Forces PacificCaliforniaColoradoConnecticutDelawareDistrict of ColumbiaFederated States Of MicronesiaFloridaGeorgiaGuamHawaiiIdahoIllinoisIndianaInternationalIowaKansasKen tuckyLouisianaMaineMarshall IslandsMarylandMassachusettsMichiganMinnesotaMississippiMissouriMontanaNebraskaN evadaNew HampshireNew JerseyNew MexicoNew YorkNorth CarolinaNorth DakotaNorthern Mariana IslandsOhioOklahomaOregonPennsylvaniaPuerto RicoRhode IslandSouth CarolinaSouth DakotaTennesseeTexasUtahVermontVirgin IslandsVirginiaWashingtonWest VirginiaWisconsinWyoming
Post/Zip Code:
Shipping quotes are based on the address information you selected:
Maine 04101 United States
Available Shipping Methods Rates
Store Pickup (Walk In) $0.00
United States Postal Service (Parcel Post (4 - 7 days)) $7.30
United States Postal Service (Priority Mail (2 - 3 days)) $7.40
United States Postal Service (Express Mail (1 - 2 days)) $33.00
United Parcel Service (1.00lbs) (Ground) $12.92
[ Close Window ]
And you are using:
Code:$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost * $shipping_num_boxes) + ($order->info['subtotal'] * .03 + 1.75) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee) );
Ya, this:
$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost * $shipping_num_boxes)+($order->info['subtotal'] * .03 + 1.75) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee) );
Could you go to your Admin and look in Modules ... Order Total ... and click on Subtotal ot_subtotal and make sure it is installed ...
Also change your echo in the USPS shipping module to:
what comes up?Code:echo 'I See USPS type: ' . $type . ' order subtotal: ' . $order->info['subtotal'] . ' Cost: ' . $cost . ' Extra: ' . ($order->info['subtotal'] * .03 + 1.75) . ' = ' . (($order->info['subtotal'] * .03 + 1.75) + $cost) . '<br>';
Ya installed:
Order Sub-Total
This module is installed
true
Sort Order
100
****************************
Ok changed echo:
I See USPS type: EXPRESS order subtotal: Cost: 31.25 Extra: 1.75 = 33
I See USPS type: PRIORITY order subtotal: Cost: 5.65 Extra: 1.75 = 7.4
I See USPS type: PARCEL order subtotal: Cost: 5.55 Extra: 1.75 = 7.3
Estimate Shipping Costs
Total Items: 1 Amount: $140.00
Country: Please Choose Your Country United States Australia Canada United Kingdom United States Minor Outlying Islands
State/Province: Please select ...AlabamaAlaskaAllAmerican SamoaArizonaArkansasArmed Forces AfricaArmed Forces AmericasArmed Forces CanadaArmed Forces EuropeArmed Forces Middle EastArmed Forces PacificCaliforniaColoradoConnecticutDelawareDistrict of ColumbiaFederated States Of MicronesiaFloridaGeorgiaGuamHawaiiIdahoIllinoisIndianaInternationalIowaKansasKen tuckyLouisianaMaineMarshall IslandsMarylandMassachusettsMichiganMinnesotaMississippiMissouriMontanaNebraskaN evadaNew HampshireNew JerseyNew MexicoNew YorkNorth CarolinaNorth DakotaNorthern Mariana IslandsOhioOklahomaOregonPennsylvaniaPuerto RicoRhode IslandSouth CarolinaSouth DakotaTennesseeTexasUtahVermontVirgin IslandsVirginiaWashingtonWest VirginiaWisconsinWyoming
Post/Zip Code:
Shipping quotes are based on the address information you selected:
Maine 04101 United States
Available Shipping Methods Rates
Store Pickup (Walk In) $0.00
United States Postal Service (Parcel Post (4 - 7 days)) $7.30
United States Postal Service (Priority Mail (2 - 3 days)) $7.40
United States Postal Service (Express Mail (1 - 2 days)) $33.00
United Parcel Service (1.00lbs) (Ground) $12.92
[ Close Window ]
It does not make a lot of sense ...
What version of Zen Cart are you using?
Clean install or an upgrade?
If you switch to the Classic template does it work in the shipping estimator?
Ok, this is weird, if I log in with my testing customer info two different ids both in FL and NY it shows the 1.75 plus 3%, if I'm not logged in it only shows the 1.75....wha??
I'm using version 1.3.9h clean install, I'm using the classic template, I've just tweeked it to what I want.
Well this makes it harder to debug ...
I have tried this code in my v1.3.9h and it works in both the shipping estimator whether I am logged in or not and the checkout ...
For giggles and grins, go to the Modules ... Shipping ... and click on USPS and EDIT it and save the settings to NotePad ... then, do a REMOVE, INSTALL and reconfigure it ...
Ok, removed, re-installed, no change....
Could something here be the problem:
Enable USPS Shipping
True
Enter the USPS Web Tools User ID
*************
Which server to use
production
Quote Sort Order
Price
Handling Fee - US
0
Handling Fee - International
0
Handling Per Order or Per Box
Order
Decimal Settings
3
Tax Class
--none--
Tax Basis
Shipping
Shipping Zone
--none--
Sort Order
1
All Packages are Machinable
True
USPS Options
Display transit time
Domestic Shipping Methods
EXPRESS, PRIORITY, FIRST CLASS, PARCEL
International Shipping Methods
Global Express, Priority Mail International, First Class Mail Int Parcel
Debug Mode
Off
So far nothing is indicating the problem ...
If you look at the usps.php file, and find the line that starts as:
what are the next 2 lines?Code:function quote($method = '') {
Code:function quote($method = '') {
// BOF: UPS USPS
global $order, $shipping_weight, $shipping_num_boxes, $transittime;
I am not finding a reason for this issue ...
Without going through your site and checking all of the files, I am not sure what the reason is ...
You can hide the problem by turning off the shipping estimator or you can see if you can find someone to pursue this further and try to hunt down the problem ...
Well thank you so much for your time !!! I really do appreciate the help.....I'm stumped here!
If I take the code out that does the 1.75 and just add the 1.75 into the shipping module under admin/module/shipping, usps, it shows it either logged in or not, I just cant add the 3% like I wanted... but took it out of the code.......can't show one price in the estimator then they log in and see a higher fee....would run them off...........
ugggghhh...I'll keep searching, if I find anything I'll post so that maybe it can help someone else if they have the same issue.
Thanks again!
Try this code instead and see if it works for both your shipping_estimator and the checkout_shipping ...
Code:global $cart;
$chk_cart_total = $_SESSION['cart']->show_total();
echo 'Cart total: ' . $chk_cart_total . ' Cost: ' . $cost . ' Extra: ' . ($chk_cart_total * .03 + 1.75) . ' = ' . (($chk_cart_total * .03 + 1.75) + $cost) . '<br>';
$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost * $shipping_num_boxes) + ($chk_cart_total * .03 + 1.75) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee) );
WWAAAAAAAAAHOOOOOOOOOOO !!!!!! :clap:
It works!
Thank you so very much for your time helping me figure this out !!!! I am so very grateful. Couldn't have done it without you.
Thanks for the update that this works for you ... :smile:
Hi, I'm trying to do this with 1.5.1 UPS module. I need to add 15% handling fee to the UPS fee estimate.
The solution proposed here seems like what I need: http://www.zen-cart.com/showthread.p...868#post392868
but the shipping module appears different in 1.5.1. I can't find the exact code they replaced. I did find something on line 269 that seems like the place it needs to be changed, but the code they used in the example above doesn't work.
Any ideas?
Are you wanting the handling fee to be 15% of the Order Total or 15% of the Shipping Cost?
Hi thanks for replying. 15% of the shipping cost.
To make handling 15% of the shipping cost, you can customize the UPS shipping file:
/includes/shipping/ups.php
with the code:
Code:// EOF: UPS USPS
$cost = preg_replace('/[^0-9.]/', '', $cost);
$new_handling = $cost * .15;
$methods[] = array('id' => $type,
'title' => $this->types[$type],
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? $new_handling * $shipping_num_boxes : $new_handling) );
The code is a little different than the code you have here, I wonder if it is because my UPS module file is UPSXML.php instead of UPS.php? How can I get the UPS.php module? I don't know why I ended up with this one.
Ok, never mind, I found the ups.php module. I was also able to find and change the code. The prices I'm getting from the 2 different modules are different though, even with the 15% factored in. I wonder which is more accurate? Seems like the regular UPS module is giving me higher price quotes.
Check your settings on the two modules ... you could also be getting different ones as you are logged into your account with one of them ...
On this topic of adding a %-age based handling fee: A while back, we converted our UPSXML module to use our input as a percentage instead of a flat $ amount. But the %-age method is sort of useless on small orders and the flat dollar amount is ineffective on large orders. Especially in light of setting the shipping to be based on COM and it's a RES order.
So, now we've changed our UPSXML mod to use both a %-age and flat rate. It works similarly to the Package Tare: Percentage: Weight setting under Configuration/ Shipping. We now have a percent and dollar amount in the UPS XML shipping module admin settings and the module uses both.
In includes\modules\shipping\upsxml.php; around line 324, i remmed out:
then added:Code:$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee / 100 * $cost + $cost));
Second, in phpMyAdmin, search the configuration table for key: MODULE_SHIPPING_UPSXML_RATES_HANDLINGCode:$za_handling_array= preg_split("/[:,]/" , str_replace(' ', '', $this->handling_fee));
$zc_handling_percent= (float)$za_handling_array[0];
$zc_handling_dollar= (float)$za_handling_array[1];
$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($cost + $zc_handling_dollar + $zc_handling_percent / 100 * $cost));
Change the configuration title to something like: "What is the handling fee for UPS? <br />Example: 10% markup + $1 10:1<br />10% + $0 10:0<br />0% + $5 0:5<br />0% + 0lbs 0:0"
to give proper instructions to the admin entering the handling fee settings for the shipping module.
Just putting this out there in case others find it helpful.