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


PHP Data::getShippingPrice方法代码示例

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


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

示例1: _prepareShippingOptions

 /**
  * Attempt to collect address shipping rates and return them for further usage in instant update API
  * Returns empty array if it was impossible to obtain any shipping rate
  * If there are shipping rates obtained, the method must return one of them as default.
  *
  * @param Address $address
  * @param bool $mayReturnEmpty
  * @param bool $calculateTax
  * @return array|false
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _prepareShippingOptions(Address $address, $mayReturnEmpty = false, $calculateTax = false)
 {
     $options = [];
     $i = 0;
     $iMin = false;
     $min = false;
     $userSelectedOption = null;
     foreach ($address->getGroupedAllShippingRates() as $group) {
         foreach ($group as $rate) {
             $amount = (double) $rate->getPrice();
             if ($rate->getErrorMessage()) {
                 continue;
             }
             $isDefault = $address->getShippingMethod() === $rate->getCode();
             $amountExclTax = $this->_taxData->getShippingPrice($amount, false, $address);
             $amountInclTax = $this->_taxData->getShippingPrice($amount, true, $address);
             $options[$i] = new \Magento\Framework\DataObject(['is_default' => $isDefault, 'name' => trim("{$rate->getCarrierTitle()} - {$rate->getMethodTitle()}", ' -'), 'code' => $rate->getCode(), 'amount' => $amountExclTax]);
             if ($calculateTax) {
                 $options[$i]->setTaxAmount($amountInclTax - $amountExclTax + $address->getTaxAmount() - $address->getShippingTaxAmount());
             }
             if ($isDefault) {
                 $userSelectedOption = $options[$i];
             }
             if (false === $min || $amountInclTax < $min) {
                 $min = $amountInclTax;
                 $iMin = $i;
             }
             $i++;
         }
     }
     if ($mayReturnEmpty && $userSelectedOption === null) {
         $options[] = new \Magento\Framework\DataObject(['is_default' => true, 'name' => __('N/A'), 'code' => 'no_rate', 'amount' => 0.0]);
         if ($calculateTax) {
             $options[$i]->setTaxAmount($address->getTaxAmount());
         }
     } elseif ($userSelectedOption === null && isset($options[$iMin])) {
         $options[$iMin]->setIsDefault(true);
     }
     // Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
     if (count($options) > 10) {
         usort($options, [get_class($this), 'cmpShippingOptions']);
         array_splice($options, 10);
         // User selected option will be always included in options list
         if ($userSelectedOption !== null && !in_array($userSelectedOption, $options)) {
             $options[9] = $userSelectedOption;
         }
     }
     return $options;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:61,代码来源:Checkout.php

示例2: _getShippingPrice

 /**
  * Get selected shipping method price
  *
  * @param bool $inclTax
  * @return string
  */
 protected function _getShippingPrice($inclTax)
 {
     $address = $this->getQuote()->getShippingAddress();
     $rate = $address->getShippingRateByCode($address->getShippingMethod());
     return $this->formatPrice($this->_taxData->getShippingPrice($rate->getPrice(), $inclTax, $address));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:Progress.php

示例3: getShippingPrice

 /**
  * @param float $price
  * @param bool|null $flag
  * @return float
  */
 public function getShippingPrice($price, $flag)
 {
     return $this->getQuote()->getStore()->convertPrice($this->_taxData->getShippingPrice($price, $flag, $this->getAddress()), true);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:9,代码来源:Available.php

示例4: _getShippingPrice

 /**
  * Return formatted shipping price
  *
  * @param float $price
  * @param bool $isInclTax
  * @return string
  */
 protected function _getShippingPrice($price, $isInclTax)
 {
     return $this->_formatPrice($this->_taxHelper->getShippingPrice($price, $isInclTax, $this->_address));
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:11,代码来源:Review.php

示例5: getShippingPrice

 /**
  * Get shipping price
  *
  * @param float $price
  * @param bool $flag
  * @return float
  */
 public function getShippingPrice($price, $flag)
 {
     return $this->priceCurrency->convertAndFormat($this->_taxData->getShippingPrice($price, $flag, $this->getAddress(), null, $this->getAddress()->getQuote()->getStore()), true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->getQuote()->getStore());
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:11,代码来源:Form.php

示例6: getShippingPriceWithFlag

 /**
  * Get Shipping Price including or excluding tax
  *
  * @param bool $flag
  * @return float
  */
 protected function getShippingPriceWithFlag($flag)
 {
     $price = $this->taxHelper->getShippingPrice($this->getShippingRate()->getPrice(), $flag, $this->getAddress(), $this->getQuote()->getCustomerTaxClassId());
     return $this->priceCurrency->convertAndFormat($price, true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->getQuote()->getStore());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:Price.php

示例7: getShippingPriceWithFlag

 /**
  * Get Shipping Price including or excluding tax
  *
  * @param \Magento\Quote\Model\Quote\Address\Rate $rateModel
  * @param bool $flag
  * @return float
  */
 private function getShippingPriceWithFlag($rateModel, $flag)
 {
     return $this->taxHelper->getShippingPrice($rateModel->getPrice(), $flag, $rateModel->getAddress(), $rateModel->getAddress()->getQuote()->getCustomerTaxClassId());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:ShippingMethodConverter.php

示例8: getShippingPrice

 /**
  * @param Address $address
  * @param float $price
  * @param bool $flag
  * @return float
  */
 public function getShippingPrice($address, $price, $flag)
 {
     return $address->getQuote()->getStore()->convertPrice($this->_taxHelper->getShippingPrice($price, $flag, $address), true);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:Shipping.php

示例9: getShippingPrice

 /**
  * @param Address $address
  * @param float $price
  * @param bool $flag
  * @return float
  */
 public function getShippingPrice($address, $price, $flag)
 {
     return $this->priceCurrency->convertAndFormat($this->_taxHelper->getShippingPrice($price, $flag, $address), true, PriceCurrencyInterface::DEFAULT_PRECISION, $address->getQuote()->getStore());
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:10,代码来源:Shipping.php

示例10: getShippingPrice

 /**
  * Get Shipping Price
  *
  * @param float $price
  * @param bool $flag
  * @return float
  */
 public function getShippingPrice($price, $flag)
 {
     return $this->formatPrice($this->_taxHelper->getShippingPrice($price, $flag, $this->getAddress(), $this->getQuote()->getCustomerTaxClassId()));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:11,代码来源:Shipping.php

示例11: getShippingPriceWithFlag

 /**
  * Get Shipping Price including or excluding tax
  *
  * @param bool $flag
  * @return float
  */
 protected function getShippingPriceWithFlag($flag)
 {
     $price = $this->taxHelper->getShippingPrice($this->getShippingRate()->getPrice(), $flag, $this->getAddress(), $this->getQuote()->getCustomerTaxClassId());
     return $this->getQuote()->getStore()->convertPrice($price, true);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Price.php


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