當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。