Post by by mona » Sat Jan 16, 2021 2:45 am

@OSWorX
OSWorX wrote:
Sat Jan 16, 2021 1:40 am
Hope I could explain it good enough ..
Perfectly as always - much appreciated - and I will find you :)
You will have to check me but I think this works as expected

Code: Select all

class ModelExtensionTotalTotal extends Model {
	public function getTotal($total) {
		$this->load->language('extension/total/total');

if (($this->config->get('total_sub_total_status')) == '0') {
		$sub_total = $this->cart->getSubTotal();

		if (!empty($this->session->data['vouchers'])) {
			foreach ($this->session->data['vouchers'] as $voucher) {
				$sub_total += $voucher['amount'];
			}
		}

		$total['total'] += $sub_total;
}
		
		$total['totals'][] = array(
			'code'       => 'total',
			'title'      => $this->language->get('text_total'),
			'value'      => max(0, $total['total']),
			'sort_order' => $this->config->get('total_total_sort_order')
		);
	}
}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by OSWorX » Sat Jan 16, 2021 4:19 am

by mona wrote:
Sat Jan 16, 2021 2:45 am

Code: Select all

if (($this->config->get('total_sub_total_status')) == '0')}
This line here inside the order totals controller is not required.
Why?
Let's have a look into the controller payment_method of the checkout.
There you will find this:

Code: Select all

if ($this->config->get('total_' . $result['code'] . '_status')) {
And it does the same as your addition, but before the totals subtotal controller is called.

Means, if the subtotal extension IS disabled, the controller (and calculation inside) will never be called.
Therefore, this checkout extension should be never disabled - or you should have very good reasons to do so!
But what it could have, another setting to disable the output (as decribed earlier here).

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by by mona » Sat Jan 16, 2021 4:58 am

@OSWorX
I have tried to follow that but I think we have wires crossed (and btw I did test it 3.0.3.2 - but I am not sure if it effects anything else) - and thank you - I appreciate

Just to make sure you understood - I added it to the model. ModelExtensionTotalTotal
i.e. what I did was say ok you do not call it because of the reasons you stated - I followed that bit - so I will tell the total model if it is disabled calculate it in anyway, whilst utilising the fact that it is not actually called so it doesn’t show.

and I am not disputing
But what it could have, another setting to disable the output (as decribed earlier here).
or even remove the disable function all together ..

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by by mona » Sat Jan 16, 2021 5:27 pm

I have been thinking about my logic and I think a new feature request / removal disable function is correct.

If you disable shipping, you do not want shipping to be included in the calculation, so in theory it is logical to disable sub-total would do the same. I stand corrected.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by sw!tch » Sat Jan 16, 2021 7:07 pm

Just keep in mind that by removing sub_total from the totals array, it no longer becomes a line item in the order total summary.

For example - Orders successfully placed will not have sub_total added to the oc_order_total table.

https://github.com/opencart/opencart/bl ... hp#L38-L42

If you need detailed order totals for accounting purposes then keep the above in mind.

The OP should better clarify hiding sub-total vs removing, etc.

-

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by by mona » Sat Jan 16, 2021 8:03 pm

Good point .. and thank you - Although in theory with the the other information it can still be calculated, I accept that is less convenient. Probably messes up your reports.
It can be done in css of course .. checkout is easy enough without core changes (especially since I don’t think sort order is fixed - in the official copies - :laugh: )

Code: Select all

#collapse-checkout-confirm > div > div > table > tfoot > tr:nth-child(1) > td:nth-child(1) {
	display: none;
}
.. the carts are a little messy .. but adding a class would probably be the cleanest and safest method.

Kind Regards
Johnny Five x

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Sat Jan 16, 2021 9:30 pm

sw!tch wrote:
Sat Jan 16, 2021 7:07 pm
Just keep in mind that by removing sub_total from the totals array, it no longer becomes a line item in the order total summary.

For example - Orders successfully placed will not have sub_total added to the oc_order_total table.

https://github.com/opencart/opencart/bl ... hp#L38-L42

If you need detailed order totals for accounting purposes then keep the above in mind.

The OP should better clarify hiding sub-total vs removing, etc.

-
Yes, agreed.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Sladdaren » Sun Jan 17, 2021 12:05 am

mikeinterserv wrote:
Fri Jan 15, 2021 11:08 pm
paulfeakins wrote:
Fri Jan 15, 2021 5:57 pm
As above, get the version right and give us the "why" for this bizarre request.
What's it got to do with any one else
He wants to do it
We can help him or NOT :-)

Do you still want to do that volvosweden
Its not that difficult if you really want but I don't want to waste my time if you changed your mind :-)
Hi all and mikeinterserv :)
Well, my boss want to get a clean checkout as possible. Other stores in our region / country does not have this on the checkout. Thats why. Sure if this is a hard work to hide this, then dont bother. We can live with this on our checkout :)

http://volvosweden.se
https://www.youtube.com/c/VolvoswedenSe


New member

Posts

Joined
Fri Nov 13, 2020 12:15 am

Post by Sladdaren » Sun Jan 17, 2021 12:15 am

Thank you all for your help.
Before i posted this thread this line called ( in swedish :-\ sry ) DELSUMMA. I manage to rename that line with SUB-TOTAL. We are pretty happy with this solution to rename it. But now i see that i have a solution in this thread if we want to delete it..Ty all for helping.
I dont want to mess to much with this code, maybe it can destroy the whole other functions thats work great..

http://volvosweden.se
https://www.youtube.com/c/VolvoswedenSe


New member

Posts

Joined
Fri Nov 13, 2020 12:15 am

Post by mikeinterserv » Sun Jan 17, 2021 12:39 am

OSWorX wrote:
Fri Jan 15, 2021 11:34 pm
disable the assigning of the output in the model sub_total
To do so, edit the file ../catalog/model/extension/sub_total.php and surround the code with a /** and */
It should look finaly:

Code: Select all

/**
		$total['totals'][] = array(
			'code'       => 'sub_total',
			'title'      => $this->language->get('text_sub_total'),
			'value'      => $sub_total,
			'sort_order' => $this->config->get('sub_total_sort_order')
		);
*/
THIS is it - Its all you have to do to achieve HIDING the subtotal.
Everything will work perfect and is easily reversible.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by OSWorX » Sun Jan 17, 2021 1:11 am

mikeinterserv wrote:
Sun Jan 17, 2021 12:39 am
THIS is it - Its all you have to do to achieve HIDING the subtotal.
Here viewtopic.php?f=202&t=221985#p810721 a better solution and installable as OCMod.
If it does not fit, simply disable the modification, biuld the cache new and delete.

The difference to the former solution is, that it adds only 2 lines into the controller BEFORE the HTML part is added to the array.
And return without it, but has calculated the sums correct.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: waylander1398 and 16 guests