Post by TonyHolmes » Wed Sep 01, 2010 2:48 am

I made a modifed copy of the original Handling Fee, to allow a percentage of the subtotal, instead of a flat rate.

/catalog/model/total/handling.php

Since this still uses the old-style Order Total, I use:
Order Total: 99999
Fee: 3.5%
Tax Class: None
Status: Enabled
Sort Order: 2

And I'm good to go. Hope I'm putting this is the right place...

Code: Select all

<?php
class ModelTotalHandling extends Model {
    public function getTotal(&$total_data, &$total, &$taxes) {
        if ($this->config->get('handling_status') && ($this->cart->getSubTotal() < $this->config->get('handling_total'))) {
            $this->load->language('total/handling');
             
            $this->load->model('localisation/currency');

            $rate = $this->config->get('handling_fee');
            if (strpos($rate, '%') !== false) {
                $rate = str_replace('%', '', $rate);
                $totalcost = $this->cart->getSubTotal() * ((float)$rate / 100);
            } else {
                $totalcost = (float)$rate;
            }
            
            $total_data[] = array( 
                'title'      => $this->language->get('text_handling'),
                'text'       => $this->currency->format($totalcost),
                'value'      => $totalcost,
                'sort_order' => $this->config->get('handling_sort_order')
            );

            if ($this->config->get('handling_tax_class_id')) {
                if (!isset($taxes[$this->config->get('handling_tax_class_id')])) {
                    $taxes[$this->config->get('handling_tax_class_id')] = $totalcost / 100 * $this->tax->getRate($this->config->get('handling_tax_class_id'));
                } else {
                    $taxes[$this->config->get('handling_tax_class_id')] += $totalcost / 100 * $this->tax->getRate($this->config->get('handling_tax_class_id'));
                }
            }
            
            $total += $totalcost;
        }
    }
}
?>
Last edited by Qphoria on Wed Sep 01, 2010 3:52 am, edited 1 time in total.
Reason: Moved to its own thread because it didn't do "multiple" rate as the other thread offers

Newbie

Posts

Joined
Thu Aug 26, 2010 3:46 am

Post by Qphoria » Wed Sep 01, 2010 3:58 am

TonyHolmes wrote:

Code: Select all

<?php
class ModelTotalHandling extends Model {
    public function getTotal(&$total_data, &$total, &$taxes) {
        if ($this->config->get('handling_status') && ($this->cart->getSubTotal() < $this->config->get('handling_total'))) {

  
You appear to have some leftovers If you have a percentage sign in the field, I'm not sure how php will calculate "less than" on
'10.00' < '10%'

Maybe it just ignores the string data and works by default but that doesn't seem like it should be there. Not tested tho

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by TonyHolmes » Wed Sep 01, 2010 4:15 am

Thanks. I thought I had dealt with all of them, since I only expected an optional % in the 'handling_fee', not the 'handling_total'. If your mod has all the gunk appropriate for 1.4.9, I'd rather use that anyway. You're the guru, certainly not me. 8)

Newbie

Posts

Joined
Thu Aug 26, 2010 3:46 am
Who is online

Users browsing this forum: No registered users and 4 guests