I am trying to reorder Total and Subtotal values in e-mail and PDF with overriding order.php but without success.
I want to Total value displays above Subtotal.
Can you help me please?
Order of Total and Subtotal
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Order of Total and Subtotal
Hi,
in file: components/com_phocacart/layouts/order.php
cca on line 844, there is a foreach of all total items:
This array needs to be run in other pre foreach and reordered and then run in the following foreach.
so e.g. you will set new keys for each item and the last one which is total will be set e.g. as zero, example:
then instead of foreach($d['total'] as $k => $v) { this: foreach($newTotal as $k => $v) {
Jan
in file: components/com_phocacart/layouts/order.php
cca on line 844, there is a foreach of all total items:
Code: Select all
$d['total']
so e.g. you will set new keys for each item and the last one which is total will be set e.g. as zero, example:
Code: Select all
$newTotal =[];
$i = 1;
foreach($d['total'] as $k => $v) {
$newTotal[$i] = $v;
$i++;
}
// Latest item will become zero and last item removed
$newTotal[0] = $newTotal[$i-1];
unset($newTotal[$i-1]);
ksort($newTotal);
Jan
If you find Phoca extensions useful, please support the project
- Nidzo
- Phoca Professional
- Posts: 390
- Joined: 07 Nov 2018, 14:55
Re: Order of Total and Subtotal
Thanks Jan. I am asking this because I get informed that in Sweden practice is when an invoice is issued to a person, the total amount should be listed first. If it is a company, then the subtotal is listed first.
I am trying but with no luck.
Is that row with price 0 necessary and is it necessary to create $newTotal array?
This is //TOTAL// part of order.php in Phoca Cart 5.0.0. Beta61
Code: Select all
// TOTAL
// -----------
$t = array();
$toPay = '';
$tColspanLeft = 5;
$tColspanMid = 2;
$tColspanRight = 2;
if ($tax_calculation > 0) {
$tColspanLeft = 7;
$tColspanMid = 3;
$tColspanRight = 2;
}
if (!empty($d['total'])) {
foreach($d['total'] as $k => $v) {
// display or not display shipping and payment methods with zero amount
//if($v->amount == 0 && $v->amount_currency == 0 && $v->type != 'brutto' && $v->type != 'sbrutto' && $v->type != 'pbrutto') {
if($v->amount == 0 && $v->amount_currency == 0 && $v->type != 'brutto') {
// Don't display coupon if null
} else if ($v->type == 'netto') {
$t[] = '<tr '.$totalF.'>';
$t[] = '<td colspan="'.$tColspanLeft.'"></td>';
$t[] = '<td colspan="'.$tColspanMid.'"><b>'. PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' '), 1 => array($v->title_lang_suffix2, ' '))).'</b></td>';
$t[] = '<td style="text-align:right" colspan="'.$tColspanRight.'"><b>'.$d['price']->getPriceFormat($v->amount).'</b></td>';
$t[] = '</tr>';
if ($pR) { $oPr[] = $pP->printLineColumns(array(PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' '), 1 => array($v->title_lang_suffix2, ' '))), $d['price']->getPriceFormat($v->amount))); }
} else if ($v->type == 'brutto') {
// Brutto or Brutto currency
$amount = (isset($v->amount_currency) && $v->amount_currency > 0) ? $d['price']->getPriceFormat($v->amount_currency, 0, 1) : $d['price']->getPriceFormat($v->amount);
$t[] = '<tr '.$totalF.'>';
$t[] = '<td colspan="'.$tColspanLeft.'"></td>';
$t[] = '<td colspan="'.$tColspanMid.'"><b>'.PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' '), 1 => array($v->title_lang_suffix2, ' '))).'</b></td>';
$t[] = '<td style="text-align:right" colspan="'.$tColspanRight.'"><b>'.$amount.'</b></td>';
$t[] = '</tr>';
if ($pR) {
$oPr[] = $pP->printSeparator();
$oPr[] = $pP->printLineColumns(array(PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' '), 1 => array($v->title_lang_suffix2, ' '))), $amount), 0, 'pDoubleSize');
$oPr[] = $pP->printFeed(2);
}
if ($d['type'] == 2) {
$toPay = $amount;
}
} else if ($v->type == 'rounding') {
// Rounding or rounding currency
$amount = (isset($v->amount_currency) && $v->amount_currency > 0) ? $d['price']->getPriceFormat($v->amount_currency, 0, 1) : $d['price']->getPriceFormat($v->amount);
$t[] = '<tr '.$totalF.'>';
$t[] = '<td colspan="'.$tColspanLeft.'"></td>';
$t[] = '<td colspan="'.$tColspanMid.'">'.PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' '), 1 => array($v->title_lang_suffix2, ' '))).'</td>';
$t[] = '<td style="text-align:right" colspan="'.$tColspanRight.'">'.$amount.'</td>';
$t[] = '</tr>';
if ($pR) { $oPr[] = $pP->printLineColumns(array(PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' '), 1 => array($v->title_lang_suffix2, ' '))), $amount)); }
} else {
$t[] = '<tr '.$totalF.'>';
$t[] = '<td colspan="'.$tColspanLeft.'"></td>';
$t[] = '<td colspan="'.$tColspanMid.'">'.PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' - '), 1 => array($v->title_lang_suffix2, ' '))).'</td>';
$t[] = '<td style="text-align:right" colspan="'.$tColspanRight.'">'.$d['price']->getPriceFormat($v->amount).'</td>';
$t[] = '</tr>';
if ($pR) { $oPr[] = $pP->printLineColumns(array(PhocacartLanguage::renderTitle($v->title, $v->title_lang, array(0 => array($v->title_lang_suffix, ' - '), 1 => array($v->title_lang_suffix2, ' '))), $d['price']->getPriceFormat($v->amount))); }
}
}
}
if ($d['type'] != 3) {
$o[] = implode("\n", $t);
}
if ($tax_calculation > 0 || $d['type'] == 3) {
$o[] = '<tr><td colspan="12"> </td></tr>';
} else {
$o[] = '<tr><td colspan="9"> </td></tr>';
}
// -----------
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Order of Total and Subtotal
Hi, this what I have written,is just a proposal, of course you can do it other way, it fully depends on you.
If you find Phoca extensions useful, please support the project
- Nidzo
- Phoca Professional
- Posts: 390
- Joined: 07 Nov 2018, 14:55
Re: Order of Total and Subtotal
I tried really hard yesterday but I couldn't get result you proposed and showed on image
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Order of Total and Subtotal
Did you apply the code, I pasted, cca on line 844? Including adding new variable $newTotal to foreach.
It just creates new variable instead the old one, where it just moves the one item from total (the final total) to start of the array, so the final total will be rendered as first in the foreach.
Jan
It just creates new variable instead the old one, where it just moves the one item from total (the final total) to start of the array, so the final total will be rendered as first in the foreach.
Jan
If you find Phoca extensions useful, please support the project
- Nidzo
- Phoca Professional
- Posts: 390
- Joined: 07 Nov 2018, 14:55
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Order of Total and Subtotal
If you find Phoca extensions useful, please support the project
- Nidzo
- Phoca Professional
- Posts: 390
- Joined: 07 Nov 2018, 14:55
Re: Order of Total and Subtotal
Thank you Jan. Now I know where I was making a mistake and I totally understand how it works.
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact: