Post by Sladdaren » Thu Jan 14, 2021 5:16 pm

Hi
Need som help again. I know the sub-total has to be calculated to show the Total, but isn´t there a way to just hide it and still keep it in the calculation?I.
I have searched other threads about this topic, and found a solved thread but in version 1,5 opencart.
viewtopic.php?t=84695
I tried to do step by step in that instruction, but the file path or codes dont match.
The question is how do i hide SUB-TOTAL in checkout and in cart? I cant just do the sub-total inactive, but i know i could maybe hide it for showing. ???

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


New member

Posts

Joined
Fri Nov 13, 2020 12:15 am


Post by IP_CAM » Thu Jan 14, 2021 5:21 pm

There is no OC v.3.0.0.6... ??? And what Theme and Extensions do you use ?

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by thekrotek » Thu Jan 14, 2021 5:34 pm

And you want to hide it why?

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by paulfeakins » Fri Jan 15, 2021 5:57 pm

As above, get the version right and give us the "why" for this bizarre request.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by mikeinterserv » 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 :-)

Active Member

Posts

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

Post by thekrotek » Fri Jan 15, 2021 11:27 pm

mikeinterserv wrote:
Fri Jan 15, 2021 11:08 pm
What's it got to do with any one else
He wants to do it
We can help him or NOT :-)
He might also want to jump from the cliff. Please, help him, don't ask why does he want to do it.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by mikeinterserv » Fri Jan 15, 2021 11:29 pm

thekrotek wrote:
Fri Jan 15, 2021 11:27 pm
mikeinterserv wrote:
Fri Jan 15, 2021 11:08 pm
What's it got to do with any one else
He wants to do it
We can help him or NOT :-)
He might also want to jump from the cliff. Please, help him, don't ask why does he want to do it.
Yeah and some of us are able to discern the difference between the two and act ACCORDINGLY

Active Member

Posts

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

Post by OSWorX » Fri Jan 15, 2021 11:34 pm

Sladdaren wrote:
Thu Jan 14, 2021 5:16 pm
I know the sub-total has to be calculated to show the Total, but isn´t there a way to just hide it and still keep it in the calculation?

The question is how do i hide SUB-TOTAL in checkout and in cart? I cant just do the sub-total inactive, but i know i could maybe hide it for showing. ???
Before this discussion extends about the question "useful or not", the simple solution for your request is:
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')
		);
*/
In you case you could also delete this part completely ..

Note: this is the simpliest and most foolproof solution.
It could be done also in another way by creating an event, but for you this should be enough for the moment without paying anything.

p.s.: this code can be applied to all 2.x and 3.x versions.

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 12:00 am

@OSWorkX ;)

Or of course you could just go into admin => extensions => extensions => order totals and just disable sub-total ..

Attachments

Screen-Shot-2021-01-15-at-15.56.34.png

Screen-Shot-2021-01-15-at-15.56.34.png (76.62 KiB) Viewed 1574 times


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.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Sat Jan 16, 2021 12:07 am

by mona wrote:
Sat Jan 16, 2021 12:00 am
@OSWorkX ;)

Or of course you could just go into admin => extensions => extensions => order totals and just disable sub-total ..
That will not work
Try it and see what you see :-)

OSWorX provided a good solution - If not I have another I didn't try his yet.
The SUB TOTAL MUST be ACTIVE to work correctly - in this case it must just be HIDDEN and NOT eliminated.

Active Member

Posts

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

Post by by mona » Sat Jan 16, 2021 12:15 am

Firstly OSWorx is fully aware I have the utmost respect for him and would never question the quality of his work
Secondly - try refreshing your browser ..

Actually you are correct - the total is wrong .. that is a bug ..

Attachments

Screen-Shot-2021-01-15-at-16.11.49.png

Screen-Shot-2021-01-15-at-16.11.49.png (192.38 KiB) Viewed 1552 times


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.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Sat Jan 16, 2021 12:23 am

by mona wrote:
Sat Jan 16, 2021 12:15 am
Firstly OSWorx is fully aware I have the utmost respect for him and would never question the quality of his work
Secondly - try refreshing your browser ..

Actually you are correct - the total is wrong .. that is a bug ..
Did you bother to look at the differing amounts now in your screenshots - It is CLEARLY WRONG
Its not a bug its just how it works.
OSWorX solution is fine I can confirm :-)
Last edited by mikeinterserv on Sat Jan 16, 2021 12:26 am, edited 2 times in total.

Active Member

Posts

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

Post by OSWorX » Sat Jan 16, 2021 12:23 am

by mona wrote:
Sat Jan 16, 2021 12:00 am
@OSWorkX ;)

Or of course you could just go into admin => extensions => extensions => order totals and just disable sub-total ..
No .. not really.
Why not simply disabling?
Because then the totals are completely NOT calculated correct ..

Therefore, either "hiding" the output by fiddling around inside the templates (cart and checkout and so on ..), or use my solution (which I have tested before publishing).
And "my" solution simply is not creating the HTML output to the totals array - which is enough for this task.

p.s.: OSWorX ;)

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 mikeinterserv » Sat Jan 16, 2021 12:28 am

^^^^ WINNER
and an excellent quick solution for this problem - THE END :-)

Active Member

Posts

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

Post by xxvirusxx » Sat Jan 16, 2021 12:36 am

Edit and remove the tax code..

Attachments


Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by by mona » Sat Jan 16, 2021 1:18 am

@OSWorX - :-[ I can pronounce it correctly !

yes - thank you - it has to go through sub_total.php, but that is insane - and very dangerous
There appears to be no valid reason for the ability to disable and not to calculate correctly - Is there a reason?

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.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Sat Jan 16, 2021 1:26 am

by mona wrote:
Sat Jan 16, 2021 1:18 am
@OSWorX - :-[ I can pronounce it correctly !

yes - thank you - it has to go through sub_total.php, but that is insane - and very dangerous
There appears to be no valid reason for the ability to disable and not to calculate correctly - Is there a reason?
Because its an extension and that's how they work - whether disabling or uninstallng breaks something, which it often can as you've discovered, that's how they work.

Active Member

Posts

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

Post by OSWorX » Sat Jan 16, 2021 1:40 am

xxvirusxx wrote:
Sat Jan 16, 2021 12:36 am
Edit and remove the tax code..
Well, we could start now a "Contest" who is providing the most useful or best solution.
While a respect your work, I think that your solution maybe a bit "over sophisticated" when editing several files while 1 line could to it also.
Therefore attached a small OCMod (available for OC 2.x and 3.x) - doing such I proposed above.

Attachments

Hide Subtotal during Checkout, but calculate 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

Post by OSWorX » Sat Jan 16, 2021 1:54 am

by mona wrote:
Sat Jan 16, 2021 1:18 am
@OSWorX - :-[ I can pronounce it correctly !

yes - thank you - it has to go through sub_total.php, but that is insane - and very dangerous
There appears to be no valid reason for the ability to disable and not to calculate correctly - Is there a reason?
Don't worry about - important you find me and my Website if you need it ;)

The reason why it has to go through the file, is - the sums (subtotal and total) are calculated inside.
Subtotal is in 99% of all shops the first line in the cart - displaying the net value of the whole cart.
This is done inside the cart controller (system file) by calling the function getSubtotal():

Code: Select all

	public function getSubTotal() {
		$total = 0;

		foreach ($this->getProducts() as $product) {
			$total += $product['total'];
		}

		return $total;
	}
As can be seen here, it loops through all products are in the cart and summarize the net value ($total) which is then returned (into the sub_total controller):

Code: Select all

$sub_total = $this->cart->getSubTotal();
After getting the subtotal in the subtotal controller, a check is made if there are any voucher values to add.
Then, the subtotal controller builds the output:

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')
		);
which we do not need here in this case (or this request).

After that, the last line is:

Code: Select all

$total['total'] += $sub_total;
which adds the former build subtotal to the total value ($total['total']) which itself is available later in some controllers (e.g. payment_method).

And this is the reason why this subtotal function (available through the menu Extensions > Extensions >Order Totals >> Sub-Total) shall NOT be disabled.
Because if, the whole further calculation is not correct.

Hope I could explain it good enough ..

What could be done to extend the core code by adding a setting to "hide" the output.
A "feature request" - maybe usefull for users and cases like this here: simply define if output yes or no inside the order totals definitions.
But calculation is done in every case.

And yes, simply disabling this order total module/extension can lead to some very unwanted results ..

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 mikeinterserv » Sat Jan 16, 2021 1:55 am

If you can't get to sub_total.php and edit that file with just 5 character comment tag then maybe you shouldn't be fiddling with opencart at all :-)
OSWorX original solution is the easiest - quickest - and most easily REVERSBALE solution with NO side effects etc available for this question. There should be NOTHING left to discuss and OSWorX explanation as to WHY, goes well above and beyond.

Active Member

Posts

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

Users browsing this forum: Adminas99999, Bing [Bot], Google [Bot], Semrush [Bot] and 93 guests