Add a percentage based fee to the shipping total in Zen-Cart’s UPS shipping module

The default UPS shipping module for zen-cart allows the store owner to add a flat rate “shipping and handling fee” to orders. I wanted to add a percentage to the shipping total instead of a flat rate for every order. Here is a short snippet which worked worked for me. Edit includes/modules/shipping/ups.php Find the line

  // EOF: UPS USPS

    $methods[] = array('id' => $type,

                           'title' => $this->types[$type],

                           'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING) * $shipping_num_boxes)

and replace it with:

  // EOF: UPS USPS

  // calculate order total less free shipping

        $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

        $percentage_added = $cost * .15;



        $methods[] = array('id' => $type,

                           'title' => $this->types[$type],

                           'cost' => (($cost + MODULE_SHIPPING_UPS_HANDLING) * $shipping_num_boxes) + $percentage_added );

Update the percentage to whatever you need in this case I’m using 15%, see the .15 This should also be applicable to other shipping modules.

Leave a Reply

Your email address will not be published. Required fields are marked *