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
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.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
What's it got to do with any one elsepaulfeakins wrote: ↑Fri Jan 15, 2021 5:57 pmAs above, get the version right and give us the "why" for this bizarre request.
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 :-)
He might also want to jump from the cliff. Please, help him, don't ask why does he want to do it.mikeinterserv wrote: ↑Fri Jan 15, 2021 11:08 pmWhat's it got to do with any one else
He wants to do it
We can help him or NOT :-)
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Yeah and some of us are able to discern the difference between the two and act ACCORDINGLYthekrotek wrote: ↑Fri Jan 15, 2021 11:27 pmHe might also want to jump from the cliff. Please, help him, don't ask why does he want to do it.mikeinterserv wrote: ↑Fri Jan 15, 2021 11:08 pmWhat's it got to do with any one else
He wants to do it
We can help him or NOT :-)
Before this discussion extends about the question "useful or not", the simple solution for your request is:Sladdaren wrote: ↑Thu Jan 14, 2021 5:16 pmI 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.
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')
);
*/
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.
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 (76.62 KiB) Viewed 1579 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
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.
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 (192.38 KiB) Viewed 1557 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
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 :-)
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.
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
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
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.
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.
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;
}
Code: Select all
$sub_total = $this->cart->getSubTotal();
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')
);
After that, the last line is:
Code: Select all
$total['total'] += $sub_total;
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.
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.
Users browsing this forum: pprmkr and 18 guests