本文整理汇总了PHP中Magento\Framework\DataObject::getShippingAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::getShippingAmount方法的具体用法?PHP DataObject::getShippingAmount怎么用?PHP DataObject::getShippingAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DataObject
的用法示例。
在下文中一共展示了DataObject::getShippingAmount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initTotals
/**
* Initialize all order totals relates with tax
*
* @return \Magento\Tax\Block\Sales\Order\Tax
*/
public function initTotals()
{
$parent = $this->getParentBlock();
$this->_order = $parent->getOrder();
$this->_source = $parent->getSource();
// $store = $this->getStore();
/*
Calculates the shoppree discount dynamically
by substracting grandtotal from the Total amount.
Also adds a row in the order view page in my orders page.
*/
$sdcnt = 0;
$totalAmnt = $this->_source->getSubTotal() + $this->_source->getShippingAmount();
$grandTotal = $this->_source->getGrandTotal();
if ($totalAmnt >= $grandTotal) {
$sdcnt = $totalAmnt - $grandTotal;
}
$fee = new \Magento\Framework\DataObject(['code' => 'fee', 'strong' => false, 'value' => $sdcnt, 'label' => __('Shoppree Discount [-]')]);
$parent->addTotal($fee, 'fee');
return $this;
}
示例2: _initShipping
/**
* @return $this
*/
protected function _initShipping()
{
$store = $this->getStore();
$parent = $this->getParentBlock();
$shipping = $parent->getTotal('shipping');
if (!$shipping) {
return $this;
}
if ($this->_config->displaySalesShippingBoth($store)) {
$shipping = (double) $this->_source->getShippingAmount();
$baseShipping = (double) $this->_source->getBaseShippingAmount();
$shippingIncl = (double) $this->_source->getShippingInclTax();
if (!$shippingIncl) {
$shippingIncl = $shipping + (double) $this->_source->getShippingTaxAmount();
}
$baseShippingIncl = (double) $this->_source->getBaseShippingInclTax();
if (!$baseShippingIncl) {
$baseShippingIncl = $baseShipping + (double) $this->_source->getBaseShippingTaxAmount();
}
$totalExcl = new \Magento\Framework\DataObject(['code' => 'shipping', 'value' => $shipping, 'base_value' => $baseShipping, 'label' => __('Shipping & Handling (Excl.Tax)')]);
$totalIncl = new \Magento\Framework\DataObject(['code' => 'shipping_incl', 'value' => $shippingIncl, 'base_value' => $baseShippingIncl, 'label' => __('Shipping & Handling (Incl.Tax)')]);
$parent->addTotal($totalExcl, 'shipping');
$parent->addTotal($totalIncl, 'shipping');
} elseif ($this->_config->displaySalesShippingInclTax($store)) {
$shippingIncl = $this->_source->getShippingInclTax();
if (!$shippingIncl) {
$shippingIncl = $this->_source->getShippingAmount() + $this->_source->getShippingTaxAmount();
}
$baseShippingIncl = $this->_source->getBaseShippingInclTax();
if (!$baseShippingIncl) {
$baseShippingIncl = $this->_source->getBaseShippingAmount() + $this->_source->getBaseShippingTaxAmount();
}
$total = $parent->getTotal('shipping');
if ($total) {
$total->setValue($shippingIncl);
$total->setBaseValue($baseShippingIncl);
}
}
return $this;
}
示例3: displayShippingPriceInclTax
/**
* Retrieve subtotal price include tax html formated content
*
* @param \Magento\Framework\DataObject $order
* @return string
*/
public function displayShippingPriceInclTax($order)
{
$shipping = $order->getShippingInclTax();
if ($shipping) {
$baseShipping = $order->getBaseShippingInclTax();
} else {
$shipping = $order->getShippingAmount() + $order->getShippingTaxAmount();
$baseShipping = $order->getBaseShippingAmount() + $order->getBaseShippingTaxAmount();
}
return $this->displayPrices($baseShipping, $shipping, false, ' ');
}