How to change handlings fee to percentage?
Posted: Mon Aug 08, 2016 3:37 pm
How can I set the handling fee to percentage? I would like to have a certain % charges for the total amount of product purchased.
Thanks
Thanks
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Code: Select all
<?php
class ModelTotalHandling extends Model {
public function getTotal($total) {
if (($this->cart->getSubTotal() > $this->config->get('handling_total')) && ($this->cart->getSubTotal() > 0)) {
$this->load->language('total/handling');
$handlingfee=($this->config->get('handling_fee')/100)*$this->cart->getTotal();
$total['totals'][] = array(
'code' => 'handling',
'title' => $this->language->get('text_handling'),
'value' => $handlingfee,
'sort_order' => $this->config->get('handling_sort_order')
);
if ($this->config->get('handling_tax_class_id')) {
$tax_rates = $this->tax->getRates($handlingfee, $this->config->get('handling_tax_class_id'));
foreach ($tax_rates as $tax_rate) {
if (!isset($total['taxes'][$tax_rate['tax_rate_id']])) {
$total['taxes'][$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$total['taxes'][$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total['total'] += $handlingfee;
}
}
}
Code: Select all
<?php
class ModelExtensionTotalHandling extends Model {
public function getTotal($total) {
if (($this->cart->getSubTotal() > $this->config->get('total_handling_total')) && ($this->cart->getSubTotal() > 0)) {
$this->load->language('extension/total/handling');
$handlingfee = ($this->config->get('total_handling_fee') / 100) * $this->cart->getTotal();
$total['totals'][] = array(
'code' => 'handling',
'title' => $this->language->get('text_handling'),
'value' => $handlingfee,
'sort_order' => $this->config->get('total_handling_sort_order')
);
if ($this->config->get('total_handling_tax_class_id')) {
$tax_rates = $this->tax->getRates($handlingfee, $this->config->get('total_handling_tax_class_id'));
foreach ($tax_rates as $tax_rate) {
if (!isset($total['taxes'][$tax_rate['tax_rate_id']])) {
$total['taxes'][$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$total['taxes'][$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total['total'] += $handlingfee;
}
}
}