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


PHP PriceCurrencyInterface::convertAndFormat方法代码示例

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


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

示例1: currencyByStore

 /**
  * Convert and format price value for specified store
  *
  * @param   float $value
  * @param   int|\Magento\Store\Model\Store $store
  * @param   bool $format
  * @param   bool $includeContainer
  * @return  float|string
  */
 public function currencyByStore($value, $store = null, $format = true, $includeContainer = true)
 {
     if ($format) {
         $value = $this->priceCurrency->convertAndFormat($value, $includeContainer, PriceCurrencyInterface::DEFAULT_PRECISION, $store);
     } else {
         $value = $this->priceCurrency->convert($value, $store);
     }
     return $value;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Data.php

示例2: getFormatedTierPrice

 /**
  * Get formatted by currency tier price
  *
  * @param   float $qty
  * @param   Product $product
  * @return  array|float
  * @deprecated
  */
 public function getFormatedTierPrice($qty, $product)
 {
     $price = $product->getTierPrice($qty);
     if (is_array($price)) {
         foreach (array_keys($price) as $index) {
             $price[$index]['formated_price'] = $this->priceCurrency->convertAndFormat($price[$index]['website_price']);
         }
     } else {
         $price = $this->priceCurrency->format($price);
     }
     return $price;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:Price.php

示例3: getAdditionalData

 /**
  * $excludeAttr is optional array of attribute codes to
  * exclude them from additional data array
  *
  * @param array $excludeAttr
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getAdditionalData(array $excludeAttr = [])
 {
     $data = [];
     $product = $this->getProduct();
     $attributes = $product->getAttributes();
     foreach ($attributes as $attribute) {
         if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
             $value = $attribute->getFrontend()->getValue($product);
             if (!$product->hasData($attribute->getAttributeCode())) {
                 $value = __('N/A');
             } elseif ((string) $value == '') {
                 $value = __('No');
             } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
                 $value = $this->priceCurrency->convertAndFormat($value);
             }
             if (is_string($value) && strlen($value)) {
                 $data[$attribute->getAttributeCode()] = ['label' => $attribute->getStoreLabel(), 'value' => $value, 'code' => $attribute->getAttributeCode()];
             }
         }
     }
     return $data;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:30,代码来源:Attributes.php

示例4: _toHtml

 /**
  * @return string
  */
 protected function _toHtml()
 {
     //store id is store view id
     $storeId = $this->_getStoreId();
     $websiteId = $this->_storeManager->getStore($storeId)->getWebsiteId();
     //customer group id
     $customerGroupId = $this->_getCustomerGroupId();
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->_productFactory->create();
     $product->setStoreId($storeId);
     $specials = $product->getResourceCollection()->addPriceDataFieldFilter('%s < %s', array('final_price', 'price'))->addPriceData($customerGroupId, $websiteId)->addAttributeToSelect(array('name', 'short_description', 'description', 'price', 'thumbnail', 'special_price', 'special_to_date', 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp'), 'left')->addAttributeToSort('name', 'asc');
     $newUrl = $this->_urlBuilder->getUrl('rss/catalog/special/store_id/' . $storeId);
     $title = __('%1 - Special Products', $this->_storeManager->getStore()->getFrontendName());
     $lang = $this->_scopeConfig->getValue('general/locale/code', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     /** @var $rssObj \Magento\Rss\Model\Rss */
     $rssObj = $this->_rssFactory->create();
     $rssObj->_addHeader(array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8', 'language' => $lang));
     $results = array();
     /*
     using resource iterator to load the data one by one
     instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
     */
     $this->_resourceIterator->walk($specials->getSelect(), array(array($this, 'addSpecialXmlCallback')), array('rssObj' => $rssObj, 'results' => &$results));
     if (sizeof($results) > 0) {
         foreach ($results as $result) {
             // render a row for RSS feed
             $product->setData($result);
             $html = sprintf('<table><tr>' . '<td><a href="%s"><img src="%s" alt="" border="0" align="left" height="75" width="75" /></a></td>' . '<td style="text-decoration:none;">%s', $product->getProductUrl(), $this->_imageHelper->init($product, 'thumbnail')->resize(75, 75), $this->_outputHelper->productAttribute($product, $product->getDescription(), 'description'));
             // add price data if needed
             if ($product->getAllowedPriceInRss()) {
                 if ($this->_catalogData->canApplyMsrp($product)) {
                     $html .= '<br/><a href="' . $product->getProductUrl() . '">' . __('Click for price') . '</a>';
                 } else {
                     $special = '';
                     if ($result['use_special']) {
                         $special = '<br />' . __('Special Expires On: %1', $this->formatDate($result['special_to_date'], \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM));
                     }
                     $html .= sprintf('<p>%s %s%s</p>', __('Price: %1', $this->_priceCurrency->convertAndFormat($result['price'])), __('Special Price: %1', $this->_priceCurrency->convertAndFormat($result['final_price'])), $special);
                 }
             }
             $html .= '</td></tr></table>';
             $rssObj->_addEntry(array('title' => $product->getName(), 'link' => $product->getProductUrl(), 'description' => $html));
         }
     }
     return $rssObj->createRssXml();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:49,代码来源:Special.php

示例5: getEntryData

 /**
  * @param \Magento\Catalog\Model\Product $item
  * @return array
  */
 protected function getEntryData(\Magento\Catalog\Model\Product $item)
 {
     $description = '
         <table><tr>
             <td><a href="%s"><img src="%s" alt="" border="0" align="left" height="75" width="75" /></a></td>
             <td style="text-decoration:none;">%s %s</td>
         </tr></table>
     ';
     $specialPrice = '';
     if ($item->getAllowedPriceInRss()) {
         if ($this->msrpHelper->canApplyMsrp($item)) {
             $specialPrice = '<br/><a href="' . $item->getProductUrl() . '">' . __('Click for price') . '</a>';
         } else {
             $special = '';
             if ($item->getUseSpecial()) {
                 $special = '<br />' . __('Special Expires On: %1', $this->formatDate($item->getSpecialToDate(), \IntlDateFormatter::MEDIUM));
             }
             $specialPrice = sprintf('<p>%s %s%s</p>', __('Price: %1', $this->priceCurrency->convertAndFormat($item->getPrice())), __('Special Price: %1', $this->priceCurrency->convertAndFormat($item->getFinalPrice())), $special);
         }
     }
     $description = sprintf($description, $item->getProductUrl(), $this->imageHelper->init($item, 'rss_thumbnail')->getUrl(), $this->outputHelper->productAttribute($item, $item->getDescription(), 'description'), $specialPrice);
     return ['title' => $item->getName(), 'link' => $item->getProductUrl(), 'description' => $description];
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:27,代码来源:Special.php

示例6: _formatPrice

 /**
  * Format price base on store convert price method
  *
  * @param float $price
  * @return string
  */
 protected function _formatPrice($price)
 {
     return $this->priceCurrency->convertAndFormat($price, true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->_quote->getStore());
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:10,代码来源:Review.php

示例7: getProductPrice

 /**
  * Get product price including store convertion rate
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param null|string $format
  * @return float|string
  * @deprecated
  */
 public function getProductPrice($product, $format = null)
 {
     try {
         $value = $product->getPrice();
         $value = $format ? $this->priceCurrency->convertAndFormat($value) : $this->priceCurrency->convert($value);
     } catch (\Exception $e) {
         $value = $e->getMessage();
     }
     return $value;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:18,代码来源:Data.php

示例8: convertPrice

 /**
  * @param float $price
  * @param bool $format
  * @return float
  */
 public function convertPrice($price, $format = true)
 {
     return $format ? $this->priceCurrency->convertAndFormat($price) : $this->priceCurrency->convert($price);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:9,代码来源:Data.php

示例9: convertPrice

 /**
  * Convert prices for template
  *
  * @param float $amount
  * @param bool $format
  * @return float
  */
 public function convertPrice($amount, $format = false)
 {
     return $format ? $this->priceCurrency->convertAndFormat($amount) : $this->priceCurrency->convert($amount);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:Renderer.php

示例10: getShippingPrice

 /**
  * Get Shipping Price
  *
  * @return float
  */
 public function getShippingPrice()
 {
     return $this->priceCurrency->convertAndFormat($this->shippingRate->getPrice());
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:9,代码来源:Price.php

示例11: 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

示例12: 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

示例13: convertAndFormatCurrency

 /**
  * Convert and format price value
  *
  * @param float $amount
  * @param bool $includeContainer
  * @param int $precision
  * @return string
  */
 public function convertAndFormatCurrency($amount, $includeContainer = true, $precision = PriceCurrencyInterface::DEFAULT_PRECISION)
 {
     return $this->priceCurrency->convertAndFormat($amount, $includeContainer, $precision);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:AbstractAdjustment.php

示例14: formatPrice

 /**
  * Convert price from default currency to current currency
  *
  * @param float $price
  * @return float
  */
 public function formatPrice($price)
 {
     return $this->priceCurrency->convertAndFormat($price, true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->getQuote()->getStore());
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:10,代码来源:Shipping.php

示例15: formatCurrency

 /**
  * Format and convert currency using current store option
  *
  * @param   float $value
  * @param   bool $includeContainer
  * @return  string
  */
 public function formatCurrency($value, $includeContainer = true)
 {
     return $this->_priceCurrency->convertAndFormat($value, $includeContainer);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:11,代码来源:Data.php


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