$order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
Wenn ich das Ergebnis drucken, Es zeigt:Wie Array-Index in PHP austauschen?
Array
(
[0] => Array
(
[order_id] => 1318
[code] => shipping
[title] => UK Shipping (Weight: 0.00kg)
[value] => 10.2000
[sort_order] => 1
)
[1] => Array
(
[order_id] => 1318
[code] => sub_total
[value] => 4.7000
[sort_order] => 3
)
[2] => Array
(
[order_id] => 1318
[code] => coupon
[title] => Coupon (10P)
[value] => -0.4700
[sort_order] => 4
)
[3] => Array
(
[order_id] => 1318
[code] => tax
[title] => VAT (20%)
[value] => 2.8860
[sort_order] => 8
)
[4] => Array
(
[order_id] => 1318
[code] => total
[title] => Total
[value] => 17.3160
[sort_order] => 9
)
)
Danach,
foreach ($order_total_query->rows as $total)
{
$text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
}
Wenn ich $text
drucken, Es zeigt:
Order Totals
UK Shipping (Weight: 4.00kg): £10.20
Sub-Total: £18.80
coupon : £-0.47
VAT (20%): £5.80
Total: £34.80
Aber ich will Tauschen Sie die Position von Sub-Total und Coupon aus, wenn der Coupon nicht leer ist. Ich brauche das Ergebnis t wie unten:
Order Totals
UK Shipping (Weight: 4.00kg): £10.20
coupon : £-0.47
Sub-Total: £18.80
VAT (20%): £5.80
Total: £34.80
Das Array, das Sie vorgestellt haben, hat keine Schlüssel 'currency_code' und' currency_value', Fehler? – RomanPerekhrest
Währungscode = £ 0.00, Währungswert = £ 1.00 –