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


PHP Data::currency方法代码示例

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


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

示例1: testCurrency

 public function testCurrency()
 {
     $price = 10.0;
     $priceHtml = '<span class="price">$10.00</span>';
     $this->assertEquals($priceHtml, $this->_helper->currency($price));
     $this->assertEquals($priceHtml, $this->_helper->formatCurrency($price));
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: getJsonConfig

 /**
  * Get JSON encoded configuration array which can be used for JS dynamic
  * price calculation depending on product options
  *
  * @return string
  */
 public function getJsonConfig()
 {
     $config = array();
     if (!$this->hasOptions()) {
         return $this->_jsonEncoder->encode($config);
     }
     $customerId = $this->getCustomerId();
     /* @var $product \Magento\Catalog\Model\Product */
     $product = $this->getProduct();
     $defaultTax = $this->taxCalculationService->getDefaultCalculatedRate($product->getTaxClassId(), $customerId);
     $currentTax = $this->taxCalculationService->getCalculatedRate($product->getTaxClassId(), $customerId);
     $tierPrices = array();
     $tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
     foreach ($tierPricesList as $tierPrice) {
         $tierPrices[] = $this->_coreData->currency($tierPrice['price']->getValue(), false, false);
     }
     $config = array('productId' => $product->getId(), 'priceFormat' => $this->_localeFormat->getPriceFormat(), 'includeTax' => $this->_taxData->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => $this->_taxData->displayPriceIncludingTax(), 'showBothPrices' => $this->_taxData->displayBothPrices(), 'productPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('final_price')->getValue(), false, false), 'productOldPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(), false, false), 'inclTaxPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue(), false, false), 'exclTaxPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount(), false, false), 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'idSuffix' => '_clone', 'oldPlusDisposition' => 0, 'plusDisposition' => 0, 'plusDispositionTax' => 0, 'oldMinusDisposition' => 0, 'minusDisposition' => 0, 'tierPrices' => $tierPrices);
     $responseObject = new \Magento\Framework\Object();
     $this->_eventManager->dispatch('catalog_product_view_config', array('response_object' => $responseObject));
     if (is_array($responseObject->getAdditionalOptions())) {
         foreach ($responseObject->getAdditionalOptions() as $option => $value) {
             $config[$option] = $value;
         }
     }
     return $this->_jsonEncoder->encode($config);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:32,代码来源:View.php

示例3: getCards

 /**
  * Retrieve credit cards info
  *
  * @return array
  */
 public function getCards()
 {
     $cardsData = $this->getMethod()->getCardsStorage()->getCards();
     $cards = array();
     if (is_array($cardsData)) {
         foreach ($cardsData as $cardInfo) {
             $data = array();
             if ($cardInfo->getProcessedAmount()) {
                 $amount = $this->_coreData->currency($cardInfo->getProcessedAmount(), true, false);
                 $data[__('Processed Amount')] = $amount;
             }
             if ($cardInfo->getBalanceOnCard() && is_numeric($cardInfo->getBalanceOnCard())) {
                 $balance = $this->_coreData->currency($cardInfo->getBalanceOnCard(), true, false);
                 $data[__('Remaining Balance')] = $balance;
             }
             $cardInfo->setMethodInstance($this->getInfo()->getMethodInstance());
             $this->setCardInfoObject($cardInfo);
             $cards[] = array_merge($this->getSpecificInformation(), $data);
             $this->unsCardInfoObject();
             $this->_paymentSpecificInformation = null;
         }
     }
     if ($this->getInfo()->getCcType() && $this->_isCheckoutProgressBlockFlag) {
         $cards[] = $this->getSpecificInformation();
     }
     return $cards;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:32,代码来源:Cc.php

示例4: _getPriceConfiguration

 /**
  * Get price configuration
  *
  * @param \Magento\Catalog\Model\Product\Option\Value|\Magento\Catalog\Model\Product\Option $option
  * @return array
  */
 protected function _getPriceConfiguration($option)
 {
     $data = array();
     $data['price'] = $this->_coreData->currency($option->getPrice(true), false, false);
     $data['oldPrice'] = $this->_coreData->currency($option->getPrice(false), false, false);
     $data['priceValue'] = $option->getPrice(false);
     $data['type'] = $option->getPriceType();
     $data['exclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price'], false);
     $data['inclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price'], true);
     return $data;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Options.php

示例5: getLinksConfig

 /**
  * Get links price config
  *
  * @return array
  */
 protected function getLinksConfig()
 {
     $finalPrice = $this->getProduct()->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE);
     $linksConfig = [];
     foreach ($this->getLinks() as $link) {
         $amount = $finalPrice->getCustomAmount($link->getPrice());
         $price = $this->coreData->currency($link->getPrice(), false, false);
         $linksConfig[$link->getId()] = ['price' => $price, 'oldPrice' => $price, 'inclTaxPrice' => $this->coreData->currency($amount->getValue(), false, false), 'exclTaxPrice' => $this->coreData->currency($amount->getBaseAmount(), false, false)];
     }
     return $linksConfig;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Links.php

示例6: getBundleOptions

 /**
  * Get bundled selections (slections-products collection)
  *
  * Returns array of options objects.
  * Each option object will contain array of selections objects
  *
  * @param ItemInterface $item
  * @return array
  */
 public function getBundleOptions(ItemInterface $item)
 {
     $options = array();
     $product = $item->getProduct();
     /** @var \Magento\Bundle\Model\Product\Type $typeInstance */
     $typeInstance = $product->getTypeInstance();
     // get bundle options
     $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
     $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
     if ($bundleOptionsIds) {
         /** @var \Magento\Bundle\Model\Resource\Option\Collection $optionsCollection */
         $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
         // get and add bundle selections collection
         $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
         $bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
         if (!empty($bundleSelectionIds)) {
             $selectionsCollection = $typeInstance->getSelectionsByIds($bundleSelectionIds, $product);
             $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
             foreach ($bundleOptions as $bundleOption) {
                 if ($bundleOption->getSelections()) {
                     $option = array('label' => $bundleOption->getTitle(), 'value' => array());
                     $bundleSelections = $bundleOption->getSelections();
                     foreach ($bundleSelections as $bundleSelection) {
                         $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                         if ($qty) {
                             $option['value'][] = $qty . ' x ' . $this->_escaper->escapeHtml($bundleSelection->getName()) . ' ' . $this->_coreData->currency($this->getSelectionFinalPrice($item, $bundleSelection));
                         }
                     }
                     if ($option['value']) {
                         $options[] = $option;
                     }
                 }
             }
         }
     }
     return $options;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:46,代码来源:Configuration.php


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