Post by c7developer » Mon Aug 02, 2010 5:06 pm

Hi, there appears to be a bug regarding the "total" order extension.

If the "sub-total" extension is disable then the total order value is 0 (zero). If the sub-total order has a greater sort-order than the total extension, then the total is 0 (zero), but sub-total is correct. I have tried this with the handling fee installed and the problem remains.

I ran the following tests which replicate the problem. Please note the first test is a base test:

Base Text - Product £100 (no tax):

enabled extension: sub-total (sort-order 1) | total (sort-order 2)
expected results: 100.00 | 100.00
actual results: 100.00 | 100.00


Test 1 Product £100 (no tax):

enabled extension: total (sort-order 1) | sub-total (sort-order 2)
expected results: 100.00 | 100.00
actual results: 0.00 | 100.00


Test 2 Product £100 (no tax):

enabled extension: total (sort-order 1)
expected results: 100.00
actual results: 0.00


I wish to enable the total extension and the handling fee extension only. Thanks in advance for any information regarding this issue.

Newbie

Posts

Joined
Mon Aug 02, 2010 4:33 pm

Post by c7developer » Mon Aug 02, 2010 7:38 pm

Having taken a look at some of the underlying code (namely: catalog\model\total\total.php) the problem appears quite deep. Currently (version 1.48) the total extension uses the $total parameter to set it's value:

Code: Select all

$total_data[] = array(
     'title'      => $this->language->get('text_total'),
     'text'       => $this->currency->format(max(0,$total)),
     'value'      => max(0,$total),
     'sort_order' => $this->config->get('total_sort_order')
);
A possible solution is to calculate the total independently (removing it from the order-total extensions). This, I think, is necessary if this value is used in the payment modules. This total would need to utilise the cart values if either the sub-total and tax are disabled.

As I am fairly new to opencart I would appreciate any feedback, thanks.

Newbie

Posts

Joined
Mon Aug 02, 2010 4:33 pm

Post by Qphoria » Wed Aug 04, 2010 2:33 am

This was a feature added in 1.4.8 because it was possible to have

Subtotal: 100
Discount: -200
Total: -100

So I made it 0 if negative.

You are setting sort order of Total before Subtotal to get your results, which doesn't really make sense. Subtotal is technically required and needs to be first or second since it contains the product price information

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by c7developer » Wed Aug 04, 2010 6:55 pm

Thanks for the response.

I take you point regarding the negative values. However as the total extension, from the $total parameter, relies on all other order extensions being calculated first, then allowing an administrator to set the execution order (via the sort-order) is opening the platform up to problems. This is equally the case when allowing administrators to disable order extensions that are technically required (sub-total, total).

As a work around, I will reset the sort order to the default values and re-order them in my views.

Again any feedback is appreciated.

Newbie

Posts

Joined
Mon Aug 02, 2010 4:33 pm

Post by alcotana » Thu Jan 27, 2011 6:05 am

If the "sub-total" extension is disable then the total order value is 0 (zero).
This is a bug. Here is an easy solution:

SubTotal should be taken into account even if "sub_total_status" is disabled (which means no shown).
So, the code "$total += $this->cart->getSubTotal();" should be out of IF condition.

Here is the final version of \catalog\model\total\sub_total.php

Code: Select all

<?php
class ModelTotalSubTotal extends Model {
	public function getTotal(&$total_data, &$total, &$taxes) {
		if ($this->config->get('sub_total_status')) {
			$this->load->language('total/sub_total');
			
			$total_data[] = array( 
        				'title'      => $this->language->get('text_sub_total'),
        				'text'       => $this->currency->format($this->cart->getSubTotal()),
        				'value'      => $this->cart->getSubTotal(),
				'sort_order' => $this->config->get('sub_total_sort_order')
			);
		}
		$total += $this->cart->getSubTotal();
	}
}
?>

Newbie

Posts

Joined
Thu Jan 27, 2011 5:48 am

Post by Qphoria » Thu Jan 27, 2011 6:25 am

I guess technically we should just remove the status and sort options for subtotal and total

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by alcotana » Thu Jan 27, 2011 6:26 am

I guess technically we should just remove the status and sort options for subtotal and total
It's unduly.

O0 In order to solve the sort bug as well, we should remove the code "$total += $this->cart->getSubTotal();" from sub_total.php and put it to total.php:

\catalog\model\total\sub_total.php

Code: Select all

<?php
class ModelTotalSubTotal extends Model {
	public function getTotal(&$total_data, &$total, &$taxes) {
		if ($this->config->get('sub_total_status')) {
			$this->load->language('total/sub_total');
			
			$total_data[] = array( 
        		'title'      => $this->language->get('text_sub_total'),
        		'text'       => $this->currency->format($this->cart->getSubTotal()),
        		'value'      => $this->cart->getSubTotal(),
				'sort_order' => $this->config->get('sub_total_sort_order')
			);
		}
	}
}
?>
\catalog\model\total\total.php

Code: Select all

<?php
class ModelTotalTotal extends Model {
	public function getTotal(&$total_data, &$total, &$taxes) {
		if ($this->config->get('total_status')) {
			$this->load->language('total/total');
		 
		 	$this->load->model('localisation/currency');
			
			$total += $this->cart->getSubTotal();
			
			$total_data[] = array(
        		'title'      => $this->language->get('text_total'),
        		'text'       => $this->currency->format(max(0,$total)),
        		'value'      => max(0,$total),
				'sort_order' => $this->config->get('total_sort_order')
			);
		}
	}
}
?>

Newbie

Posts

Joined
Thu Jan 27, 2011 5:48 am

Post by StudioArt.cz » Tue Feb 26, 2013 1:02 am

Hi, i have same problem in 1.5.4. Any soulution?
This is not work... :(

http://www.studioart.cz/


Newbie

Posts

Joined
Mon Feb 25, 2013 10:56 pm
Who is online

Users browsing this forum: No registered users and 2 guests