I want to move the VAT row below the delivery cost in the One Step Checkout review your order section. What would be the best approach to rearrange them?
Thanks in advanced for your help.
In order to do this, you'd need to reorder the totals array itself prior to the for loop which outputs them.
The foreach loop starts as follows:
<?php foreach ($this->getTotals() as $total): ?>
$this->getTotals() returns an array of totals that is pre-sorted. As you are looking for a different order, then you'll need to modify this declaration.
Firstly, you'll need to ascertain the keys and the current order:
<?php var_dump(array_keys($this->getTotals())); ?>
That code will output the order of the totals along with their identification keys.
Now you can look at re-ordering them. Change your
foreach loop to resemble this:
<?php // Get all totals $all_totals = $this->getTotals(); // Create a new array of totals (empty) $totals = array(); // Explicitly set the order of the totals into the totals array $totals = $all_totals['subtotal']; $totals = $all_totals['shipping']; $totals = $all_totals['tax']; $totals = $all_totals['grand_total']; // Loop through your new order foreach ($totals as $total): ?>
You'll need to adapt your own total keys into this format, and ensure that the indices of your new
$totals array are correct for what you want.