Magento在总计表中切换Grand Total(Excl.Tax)和Grand Total(Incl.Tax)

时间:2015-11-16 13:42:06

标签: php mysql magento

我有一个关于转换Grand Total(Incl.Tax)和Grand Total(Incl.Tax)的位置的问题,这些位置列在总计表中。我的意思是我的销售电子邮件中的总计表。 Grand Total(Excl.Tax)位于总计中间位置,Grand Total(Incl.Tax)的位置位于底部。我用Magento ver。 1.9.2.1。

我发现总数是在此代码段中呈现的。

<?php foreach ($this->getTotals() as $_code => $_total): ?>
      <?php if ($_total->getBlockName()): ?>
          <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
      <?php else:?>
      <tr class="<?php echo $_code?>">       
          <td <?php echo $this->getLabelProperties()?>>
              <?php if ($_total->getStrong()):?>
              <strong><?php echo $this->escapeHtml($_total->getLabel());?></strong>
              <?php else:?>
              <?php echo $this->escapeHtml($_total->getLabel());?>
              <?php endif?>
          </td>
          <td <?php echo $this->getValueProperties()?>>
              <?php if ($_total->getStrong()):?>
              <strong><?php echo $this->formatValue($_total) ?></strong>
              <?php else:?>
              <?php echo $this->formatValue($_total) ?>
              <?php endif?>
          </td>
      </tr>
      <?php endif?>
  <?php endforeach ?>

但我无法找到类似职位的订单或类似的东西。我在互联网上找到了一些教程但没有真正有效。

更新

我可以通过更改Tax.php中的方法来解决问题(/app/code/local/Mage/Tax/Block/Sales/Order/Tax.php):

protected function _initGrandTotal()
    {
        $store  = $this->getStore();
        $parent = $this->getParentBlock();
        $grandototal = $parent->getTotal('grand_total');
        if (!$grandototal || !(float)$this->_source->getGrandTotal()) {
            return $this;
        }

        if ($this->_config->displaySalesTaxWithGrandTotal($store)) {
            $grandtotal         = $this->_source->getGrandTotal();
            $baseGrandtotal     = $this->_source->getBaseGrandTotal();
            $grandtotalExcl     = $grandtotal - $this->_source->getTaxAmount();
            $baseGrandtotalExcl = $baseGrandtotal - $this->_source->getBaseTaxAmount();
            $grandtotalExcl     = max($grandtotalExcl, 0);
            $baseGrandtotalExcl = max($baseGrandtotalExcl, 0);
            $totalExcl = new Varien_Object(array(
                'code'      => 'grand_total',
                'strong'    => false,
                'value'     => $grandtotalExcl,
                'base_value'=> $baseGrandtotalExcl,
                'label'     => $this->__('Grand Total (Excl.Tax)')
            ));
            $totalIncl = new Varien_Object(array(
                'code'      => 'grand_total_incl',
                'strong'    => true,
                'value'     => $grandtotal,
                'base_value'=> $baseGrandtotal,
                'label'     => $this->__('Grand Total (Incl.Tax)')
            ));
            $parent->addTotal($totalIncl, 'tax');
            $parent->addTotal($totalExcl, 'grand_total');
            $this->_addTax('grand_total');

        }
        return $this;
    }

0 个答案:

没有答案