Post by yukicyan » 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

Newbie

Posts

Joined
Mon Aug 08, 2016 3:31 pm

Post by knowband.plugins » Thu Aug 11, 2016 2:37 pm

It can be done easily by modifying following file.

/catalog/model/total/handling.php

Could you plese tell us which version of Opencart are you using so that we can help you.

Regards,
Knowband Team

Opencart Plugins: Knowband Store
Email: support@knowband.com


User avatar
Active Member

Posts

Joined
Thu Aug 04, 2016 2:56 pm


Post by yukicyan » Fri Aug 12, 2016 9:13 am

I'm using opencart 2.2.0.0

Newbie

Posts

Joined
Mon Aug 08, 2016 3:31 pm

Post by knowband.plugins » Fri Aug 12, 2016 3:27 pm

Edit below file

/catalog/model/total/phandling.php

and make changes as shown below

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;
		}
	}
}

Regards,
Knowband Team

Opencart Plugins: Knowband Store
Email: support@knowband.com


User avatar
Active Member

Posts

Joined
Thu Aug 04, 2016 2:56 pm


Post by yukicyan » Fri Aug 12, 2016 3:52 pm

Well done. Thanks a lot.

Newbie

Posts

Joined
Mon Aug 08, 2016 3:31 pm

Post by bless57 » Sun Jul 07, 2019 6:32 am

hi can you tell me how to do this in opencart 3

Newbie

Posts

Joined
Tue Jul 22, 2014 12:51 pm

Post by straightlight » Sun Jul 07, 2019 7:01 am

bless57 wrote:
Sun Jul 07, 2019 6:32 am
hi can you tell me how to do this in opencart 3

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;
		}
	}
}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 14 guests