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


PHP PriceCurrencyInterface::format方法代码示例

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


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

示例1: getListValues

 /**
  * @param $products
  * @return array
  */
 public function getListValues($ids)
 {
     $values = [];
     $searchCriteria = $this->_criteriaBuilder->addFilter('entity_id', $ids, 'in')->create();
     $products = $this->_productRepository->getList($searchCriteria);
     foreach ($products->getItems() as $product) {
         $image = $this->_imageHelper->init($product, 'product_page_image_small')->getUrl();
         $price = $product->getFinalPrice();
         if ($price == 0 && $product->getTypeId() == 'grouped') {
             $children = $product->getTypeInstance()->getAssociatedProducts($product);
             foreach ($children as $child) {
                 if ($child->getPrice() < $price || $price == 0) {
                     $price = $child->getPrice();
                 }
             }
         }
         $value = array();
         $value['escape_name'] = $this->escapeHtml($product->getName());
         $value['name'] = $product->getName();
         $value['url'] = $product->getProductUrl();
         $value['price'] = $this->_priceCurrency->format($price, false);
         $value['image'] = $image;
         $values[] = $value;
     }
     return $values;
 }
开发者ID:boxalino,项目名称:plugin-magento2,代码行数:30,代码来源:Autocomplete.php

示例2: displayPrices

 /**
  * Get "double" prices html (block with base and place currency)
  *
  * @param   \Magento\Framework\Object $dataObject
  * @param   float $basePrice
  * @param   float $price
  * @param   bool $strong
  * @param   string $separator
  * @return  string
  */
 public function displayPrices($dataObject, $basePrice, $price, $strong = false, $separator = '<br/>')
 {
     $order = false;
     if ($dataObject instanceof \Magento\Sales\Model\Order) {
         $order = $dataObject;
     } else {
         $order = $dataObject->getOrder();
     }
     if ($order && $order->isCurrencyDifferent()) {
         $res = '<strong>';
         $res .= $order->formatBasePrice($basePrice);
         $res .= '</strong>' . $separator;
         $res .= '[' . $order->formatPrice($price) . ']';
     } elseif ($order) {
         $res = $order->formatPrice($price);
         if ($strong) {
             $res = '<strong>' . $res . '</strong>';
         }
     } else {
         $res = $this->priceCurrency->format($price);
         if ($strong) {
             $res = '<strong>' . $res . '</strong>';
         }
     }
     return $res;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Admin.php

示例3: prepareDataSource

 /**
  * Prepare Data Source
  *
  * @param array $dataSource
  * @return void
  */
 public function prepareDataSource(array &$dataSource)
 {
     if (isset($dataSource['data']['items'])) {
         foreach ($dataSource['data']['items'] as &$item) {
             $item[$this->getData('name')] = $this->priceFormatter->format($item[$this->getData('name')], false);
         }
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:14,代码来源:Price.php

示例4: prepareDataSource

 /**
  * Prepare Data Source
  *
  * @param array $dataSource
  * @return array
  */
 public function prepareDataSource(array $dataSource)
 {
     if (isset($dataSource['data']['items'])) {
         foreach ($dataSource['data']['items'] as &$item) {
             $currencyCode = isset($item['base_currency_code']) ? $item['base_currency_code'] : null;
             $item[$this->getData('name')] = $this->priceFormatter->format($item[$this->getData('name')], false, null, null, $currencyCode);
         }
     }
     return $dataSource;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:16,代码来源:Price.php

示例5: getAssociatedProducts

 /**
  * Retrieve grouped products
  *
  * @return array
  */
 public function getAssociatedProducts()
 {
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->_registry->registry('current_product');
     $associatedProducts = $product->getTypeInstance()->getAssociatedProducts($product);
     $products = [];
     foreach ($associatedProducts as $product) {
         $products[] = ['id' => $product->getId(), 'sku' => $product->getSku(), 'name' => $product->getName(), 'price' => $this->priceCurrency->format($product->getPrice(), false), 'qty' => $product->getQty(), 'position' => $product->getPosition()];
     }
     return $products;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:ListAssociatedProducts.php

示例6: renderRangeLabel

 /**
  * Prepare text of range label
  *
  * @param float|string $fromPrice
  * @param float|string $toPrice
  * @return float|\Magento\Framework\Phrase
  */
 public function renderRangeLabel($fromPrice, $toPrice)
 {
     $formattedFromPrice = $this->priceCurrency->format($fromPrice);
     $priceInterval = $this->scopeConfig->getValue(self::XML_PATH_ONE_PRICE_INTERVAL, ScopeInterface::SCOPE_STORE);
     if ($toPrice === '') {
         return __('%1 and above', $formattedFromPrice);
     } elseif ($fromPrice == $toPrice && $priceInterval) {
         return $formattedFromPrice;
     } else {
         if ($fromPrice != $toPrice) {
             $toPrice -= 0.01;
         }
         return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:Render.php

示例7: _renderRangeLabel

 /**
  * @SuppressWarnings(PHPMD.CamelCaseMethodName)
  *
  * {@inheritDoc}
  */
 protected function _renderRangeLabel($fromPrice, $toPrice)
 {
     $formattedPrice = $this->priceCurrency->format($fromPrice);
     if ($toPrice === '') {
         $formattedPrice = __('%1 and above', $formattedPrice);
     } elseif ($fromPrice != $toPrice || !$this->dataProvider->getOnePriceIntervalValue()) {
         $formattedPrice = __('%1 - %2', $formattedPrice, $this->priceCurrency->format($toPrice));
     }
     return $formattedPrice;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:15,代码来源:Price.php

示例8: formatPrice

 /**
  * Format price
  *
  * @param float $price
  * @return string
  */
 public function formatPrice($price)
 {
     $item = $this->getItem();
     if ($item instanceof QuoteItem) {
         return $this->priceCurrency->format($price, true, PriceCurrencyInterface::DEFAULT_PRECISION, $item->getStore());
     } elseif ($item instanceof OrderItem) {
         return $item->getOrder()->formatPrice($price);
     } else {
         return $item->getOrderItem()->getOrder()->formatPrice($price);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Renderer.php

示例9: renderRangeLabel

 /**
  * Prepare text of range label
  *
  * @param float|string $fromPrice
  * @param float|string $toPrice
  * @return \Magento\Framework\Phrase
  */
 protected function renderRangeLabel($fromPrice, $toPrice)
 {
     $formattedFromPrice = $this->priceCurrency->format($fromPrice);
     if ($toPrice === '') {
         return __('%1 and above', $formattedFromPrice);
     } else {
         if ($fromPrice != $toPrice) {
             $toPrice -= 0.01;
         }
         return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:19,代码来源:Decimal.php

示例10: _renderRangeLabel

 /**
  * Prepare text of range label
  *
  * @param float|string $fromPrice
  * @param float|string $toPrice
  * @return string
  */
 protected function _renderRangeLabel($fromPrice, $toPrice)
 {
     $formattedFromPrice = $this->priceCurrency->format($fromPrice);
     if ($toPrice === '') {
         return __('%1 and above', $formattedFromPrice);
     } elseif ($fromPrice == $toPrice && $this->_scopeConfig->getValue(self::XML_PATH_ONE_PRICE_INTERVAL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
         return $formattedFromPrice;
     } else {
         if ($fromPrice != $toPrice) {
             $toPrice -= 0.01;
         }
         return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
     }
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:21,代码来源:Price.php

示例11: getItems

 /**
  * getItems method
  *
  * @return array
  */
 public function getItems()
 {
     $result = [];
     $query = $this->queryFactory->get()->getQueryText();
     $productIds = $this->searchProductsFullText($query);
     // Check if products are found
     if ($productIds) {
         $searchCriteria = $this->searchCriteriaBuilder->addFilter('entity_id', $productIds, 'in')->create();
         $products = $this->productRepository->getList($searchCriteria);
         foreach ($products->getItems() as $product) {
             $image = $this->imageHelper->init($product, 'product_page_image_small')->getUrl();
             $resultItem = $this->itemFactory->create(['title' => $product->getName(), 'price' => $this->priceCurrency->format($product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(), false), 'special_price' => $this->priceCurrency->format($product->getPriceInfo()->getPrice('special_price')->getAmount()->getValue(), false), 'has_special_price' => $product->getSpecialPrice() > 0 ? true : false, 'image' => $image, 'url' => $product->getProductUrl()]);
             $result[] = $resultItem;
         }
     }
     return $result;
 }
开发者ID:sebwite,项目名称:magento2-smartsearch,代码行数:22,代码来源:SearchDataProvider.php

示例12: getItems

 /**
  * {@inheritdoc}
  */
 public function getItems()
 {
     $result = [];
     $query = $this->queryFactory->get()->getQueryText();
     $productIds = $this->searchProductsFullText($query);
     // Check if products are found
     if ($productIds) {
         $searchCriteria = $this->searchCriteriaBuilder->addFilter('entity_id', $productIds, 'in')->create();
         $products = $this->productRepository->getList($searchCriteria);
         $baseUrl = $this->storeManager->getStore()->getBaseUrl();
         // Loop through products
         foreach ($products->getItems() as $product) {
             $resultItem = $this->itemFactory->create(['title' => $product->getName(), 'price' => $this->priceCurrency->format($product->getFinalPrice(), false), 'special_price' => $this->priceCurrency->format($product->getSpecialPrice(), false), 'has_special_price' => $product->getSpecialPrice() > 0 ? true : false, 'image' => str_replace('index.php/', '', $baseUrl) . '/pub/media/catalog/product' . $product->getImage(), 'url' => $product->getProductUrl()]);
             $result[] = $resultItem;
         }
     }
     return $result;
 }
开发者ID:srbarba,项目名称:Magento2-SmartSearch,代码行数:21,代码来源:SearchDataProvider.php

示例13: getFormatedPrice

 /**
  * Get formatted by currency product price
  *
  * @param   Product $product
  * @return  array || float
  */
 public function getFormatedPrice($product)
 {
     return $this->priceCurrency->format($product->getFinalPrice());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Price.php

示例14: formatPrice

 /**
  * @param float $price
  * @return mixed
  *
  * @codeCoverageIgnore
  */
 public function formatPrice($price)
 {
     return $this->priceCurrency->format($price, true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->getQuote()->getStore());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Overview.php

示例15: _renderItemLabel

 /**
  * Prepare text of item label
  *
  * @param   int $range
  * @param   float $value
  * @return \Magento\Framework\Phrase
  */
 protected function _renderItemLabel($range, $value)
 {
     $from = $this->priceCurrency->format(($value - 1) * $range, false);
     $to = $this->priceCurrency->format($value * $range, false);
     return __('%1 - %2', $from, $to);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Decimal.php


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