當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。