本文整理汇总了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;
}
示例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;
}