当前位置: 首页>>代码示例>>PHP>>正文


PHP Data::getShippingTax方法代码示例

本文整理汇总了PHP中Magento\Tax\Helper\Data::getShippingTax方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getShippingTax方法的具体用法?PHP Data::getShippingTax怎么用?PHP Data::getShippingTax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Tax\Helper\Data的用法示例。


在下文中一共展示了Data::getShippingTax方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFullTaxInfo

 /**
  * Get array of arrays with tax information for display in PDF
  * array(
  *  $index => array(
  *      'amount'   => $amount,
  *      'label'    => $label,
  *      'font_size'=> $font_size
  *  )
  * )
  *
  * @return array
  */
 public function getFullTaxInfo()
 {
     $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
     $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($this->getOrder());
     $shippingTax = $this->_taxHelper->getShippingTax($this->getOrder());
     $taxClassAmount = array_merge($shippingTax, $taxClassAmount);
     if (!empty($taxClassAmount)) {
         foreach ($taxClassAmount as &$tax) {
             $percent = $tax['percent'] ? ' (' . $tax['percent'] . '%)' : '';
             $tax['amount'] = $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($tax['tax_amount']);
             $tax['label'] = __($tax['title']) . $percent . ':';
             $tax['font_size'] = $fontSize;
         }
     } else {
         /** @var $orders \Magento\Tax\Model\Resource\Sales\Order\Tax\Collection */
         $orders = $this->_taxOrdersFactory->create();
         $rates = $orders->loadByOrder($this->getOrder())->toArray();
         $fullInfo = $this->_taxCalculation->reproduceProcess($rates['items']);
         $tax_info = array();
         if ($fullInfo) {
             foreach ($fullInfo as $info) {
                 if (isset($info['hidden']) && $info['hidden']) {
                     continue;
                 }
                 $_amount = $info['amount'];
                 foreach ($info['rates'] as $rate) {
                     $percent = $rate['percent'] ? ' (' . $rate['percent'] . '%)' : '';
                     $tax_info[] = array('amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($_amount), 'label' => __($rate['title']) . $percent . ':', 'font_size' => $fontSize);
                 }
             }
         }
         $taxClassAmount = $tax_info;
     }
     return $taxClassAmount;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:47,代码来源:DefaultTotal.php

示例2: getFullTaxInfo

 /**
  * Get full information about taxes applied to order
  *
  * @return array
  */
 public function getFullTaxInfo()
 {
     /** @var $source \Magento\Sales\Model\Order */
     $source = $this->getOrder();
     $taxClassAmount = array();
     if ($source instanceof \Magento\Sales\Model\Order) {
         $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($source);
         $shippingTax = $this->_taxHelper->getShippingTax($source);
         $taxClassAmount = array_merge($taxClassAmount, $shippingTax);
         if (empty($taxClassAmount)) {
             $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($source)->toArray();
             $taxClassAmount = $this->_taxCalculation->reproduceProcess($rates['items']);
         }
     }
     return $taxClassAmount;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:Tax.php


注:本文中的Magento\Tax\Helper\Data::getShippingTax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。