Zwischensumme als PHP-Variable verwenden

Thema wurde von Anonymous, 4. Juni 2019 erstellt.

  1. Anonymous

    Anonymous Erfahrener Benutzer

    Registriert seit:
    19. Juni 2012
    Beiträge:
    4.831
    Danke erhalten:
    1.122
    Danke vergeben:
    947
    Hi, hat jemand eine Idee wie ich den Brutto-Warenwert einer Bestellung in der admin/html/compatibility/order_details.php als PHP-Variable verwenden kann?

    if ($GLOBALS['order']->totals['title'] == 'Zwischensumme:')
    {
    echo $GLOBALS['order']->totals['value'];
    }

    funktioniert nicht. Hier der Original-Code aus der Datei:


    Code:
                                <tr id="order-sum-row">
                                    <td colspan="<?php if($productInformation['allow_tax']) { ?>6<?php } else { ?>4<?php } ?>" class="text-right">
                                        <div class="grid">
                                            <?php
                                            $counter          = 0;
                                            $countOrderTotals = count($GLOBALS['order']->totals);
                                            ?>
                                            <?php foreach($GLOBALS['order']->totals as $orderInfoArray): ?>
                                                <?php if($counter <= ($countOrderTotals - 2)): ?>
                                                    <div class="span12">
                                                        &nbsp;<?php echo strip_tags($orderInfoArray['title']) ?>
                                                    </div>
                                                    <?php $counter++; ?>
                                                <?php endif; ?>
                                            <?php endforeach; ?>
                                        </div>
                                    </td>
                                    <td class="text-right">
                                        <div class="grid">
                                            <?php
                                            $counter = 0;
                                            ?>
                                            <?php foreach($GLOBALS['order']->totals as $orderInfoArray): ?>
                                                <?php if($counter <= ($countOrderTotals - 2)): ?>
                                                    <div class="span12">
                                                        &nbsp;<?php echo $orderInfoArray['text'] ?>
                                                    </div>
                                                    <?php $counter++; ?>
                                                <?php endif; ?>
                                            <?php endforeach; ?>
                                        </div>
                                    </td>
                                </tr>
     
  2. Anonymous

    Anonymous Erfahrener Benutzer
    Mitarbeiter

    Registriert seit:
    22. Juni 2011
    Beiträge:
    4.760
    Danke erhalten:
    1.748
    Danke vergeben:
    137
    Da fehlt eine Array-Ebene. Eher so:
    PHP:
    $subTotal null;
    foreach (
    $GLOBALS['order']->totals as $orderTotal) {
      if (
    $orderTotal['code'] === 'ot_subtotal') {
        
    $subTotal = [
          
    'value' => $orderTotal['value'],
          
    'text' => $orderTotal['text'],
          
    'title' => $orderTotal['title'],
        ];
      }
    }
    if (
    $subTotal !== null) {
      
    printf('%s: %s'$subTotal['title'], $subTotal['text']);
    } else {
      echo 
    'no subtotal';
    }
    Ungetestet, ich hab das nur eben schnell hier hingeschmiert. :)