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


PHP Pricing\PriceCurrencyInterface类代码示例

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


在下文中一共展示了PriceCurrencyInterface类的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: testCurrencyByStore

 /**
  * @param string $amount
  * @param string $store
  * @param bool $format
  * @param bool $includeContainer
  * @param string $result
  * @dataProvider currencyByStoreDataProvider
  */
 public function testCurrencyByStore($amount, $store, $format, $includeContainer, $result)
 {
     if ($format) {
         $this->priceCurrencyMock->expects($this->once())->method('convertAndFormat')->with($amount, $includeContainer, PriceCurrencyInterface::DEFAULT_PRECISION, $store)->will($this->returnValue($result));
     } else {
         $this->priceCurrencyMock->expects($this->once())->method('convert')->with($amount, $store)->will($this->returnValue($result));
     }
     $helper = $this->getHelper(['priceCurrency' => $this->priceCurrencyMock]);
     $this->assertEquals($result, $helper->currencyByStore($amount, $store, $format, $includeContainer));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:DataTest.php

示例3: setUp

 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->coreRegistry = $this->getMockBuilder('\\Magento\\Framework\\Registry')->disableOriginalConstructor()->setMethods(['registry'])->getMock();
     $this->orderTaxService = $this->getMockBuilder('\\Magento\\Tax\\Service\\V1\\OrderTaxService')->disableOriginalConstructor()->setMethods(['getOrderTaxDetails'])->getMock();
     $this->priceCurrency = $this->getMockBuilder('Magento\\Framework\\Pricing\\PriceCurrencyInterface')->getMock();
     $this->priceCurrency->expects($this->any())->method('round')->will($this->returnCallback(function ($argument) {
         return round($argument, 2);
     }));
     $this->taxHelper = $objectManager->getObject('Magento\\Tax\\Helper\\Data', ['coreRegistry' => $this->coreRegistry, 'orderTaxService' => $this->orderTaxService, 'priceCurrency' => $this->priceCurrency]);
     $this->orderTaxDetailsBuilder = $objectManager->getObject('Magento\\Tax\\Service\\V1\\Data\\OrderTaxDetailsBuilder');
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:12,代码来源:DataTest.php

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

示例5: prepareOrder

 /**
  * Prepare order data for refund
  *
  * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
  * @return void
  */
 protected function prepareOrder(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
 {
     $order = $creditmemo->getOrder();
     $baseOrderRefund = $this->priceCurrency->round($order->getBaseTotalRefunded() + $creditmemo->getBaseGrandTotal());
     $orderRefund = $this->priceCurrency->round($order->getTotalRefunded() + $creditmemo->getGrandTotal());
     $order->setBaseTotalRefunded($baseOrderRefund);
     $order->setTotalRefunded($orderRefund);
     $order->setBaseSubtotalRefunded($order->getBaseSubtotalRefunded() + $creditmemo->getBaseSubtotal());
     $order->setSubtotalRefunded($order->getSubtotalRefunded() + $creditmemo->getSubtotal());
     $order->setBaseTaxRefunded($order->getBaseTaxRefunded() + $creditmemo->getBaseTaxAmount());
     $order->setTaxRefunded($order->getTaxRefunded() + $creditmemo->getTaxAmount());
     $order->setBaseDiscountTaxCompensationRefunded($order->getBaseDiscountTaxCompensationRefunded() + $creditmemo->getBaseDiscountTaxCompensationAmount());
     $order->setDiscountTaxCompensationRefunded($order->getDiscountTaxCompensationRefunded() + $creditmemo->getDiscountTaxCompensationAmount());
     $order->setBaseShippingRefunded($order->getBaseShippingRefunded() + $creditmemo->getBaseShippingAmount());
     $order->setShippingRefunded($order->getShippingRefunded() + $creditmemo->getShippingAmount());
     $order->setBaseShippingTaxRefunded($order->getBaseShippingTaxRefunded() + $creditmemo->getBaseShippingTaxAmount());
     $order->setShippingTaxRefunded($order->getShippingTaxRefunded() + $creditmemo->getShippingTaxAmount());
     $order->setAdjustmentPositive($order->getAdjustmentPositive() + $creditmemo->getAdjustmentPositive());
     $order->setBaseAdjustmentPositive($order->getBaseAdjustmentPositive() + $creditmemo->getBaseAdjustmentPositive());
     $order->setAdjustmentNegative($order->getAdjustmentNegative() + $creditmemo->getAdjustmentNegative());
     $order->setBaseAdjustmentNegative($order->getBaseAdjustmentNegative() + $creditmemo->getBaseAdjustmentNegative());
     $order->setDiscountRefunded($order->getDiscountRefunded() + $creditmemo->getDiscountAmount());
     $order->setBaseDiscountRefunded($order->getBaseDiscountRefunded() + $creditmemo->getBaseDiscountAmount());
     if ($creditmemo->getDoTransaction()) {
         $order->setTotalOnlineRefunded($order->getTotalOnlineRefunded() + $creditmemo->getGrandTotal());
         $order->setBaseTotalOnlineRefunded($order->getBaseTotalOnlineRefunded() + $creditmemo->getBaseGrandTotal());
     } else {
         $order->setTotalOfflineRefunded($order->getTotalOfflineRefunded() + $creditmemo->getGrandTotal());
         $order->setBaseTotalOfflineRefunded($order->getBaseTotalOfflineRefunded() + $creditmemo->getBaseGrandTotal());
     }
     $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() - $creditmemo->getBaseCost());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:Refund.php

示例6: aroundGet

 /**
  * MOBI-486: Add partial payment data to totals are requested with REST API.
  * MOBI-489: Add partial payment configuration to totals extension attributes.
  *
  * @param \Magento\Quote\Model\Cart\CartTotalRepository $subject
  * @param \Closure $proceed
  * @param $cartId
  * @return \Magento\Quote\Api\Data\TotalsInterface
  */
 public function aroundGet(\Magento\Quote\Model\Cart\CartTotalRepository $subject, \Closure $proceed, $cartId)
 {
     /** @var \Magento\Quote\Model\Cart\Totals $result */
     $result = $proceed($cartId);
     /* Get partial method configuration */
     $isPartialEnabled = $this->_hlpCfg->getWalletPartialEnabled();
     if ($isPartialEnabled) {
         //            $partialMaxPercent = $this->_hlpCfg->getWalletPartialPercent();
         //            /** @var \Magento\Quote\Api\Data\TotalExtensionInterface $exts */
         //            $exts = $this->_factTotalExt->create();
         //            /** @var \Praxigento\Wallet\Api\Data\Config\Payment\Method $extData */
         //            $extData = new \Praxigento\Wallet\Api\Data\Config\Payment\Method();
         //            $extData->setPartialMaxPercent($partialMaxPercent);
         //            $extData->setIsPartialEnabled($isPartialEnabled);
         //            $exts->setPraxigentoWalletPaymentConfig($extData);
         //            $result->setExtensionAttributes($exts);
         /* get partial data from repository */
         /** @var \Praxigento\Wallet\Data\Entity\Partial\Quote $found */
         $found = $this->_repoPartialQuote->getById($cartId);
         if ($found) {
             $basePartial = $found->getBasePartialAmount();
             $basePartial = $this->_hlpPriceCurrency->round($basePartial);
             /* add current partial total to segment */
             $segments = $result->getTotalSegments();
             /** @var \Magento\Quote\Api\Data\TotalSegmentInterface $seg */
             $seg = $this->_manObj->create(\Magento\Quote\Api\Data\TotalSegmentInterface::class);
             $seg->setCode(self::TOTAL_SEGMENT);
             $seg->setValue($basePartial);
             $segments[self::TOTAL_SEGMENT] = $seg;
             $result->setTotalSegments($segments);
         }
     }
     return $result;
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_wallet,代码行数:43,代码来源:CartTotalRepository.php

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

示例8: filter

 /**
  * Filter value
  *
  * @param float $value
  * @return string
  */
 public function filter($value)
 {
     $value = $this->_localeFormat->getNumber($value);
     $value = $this->priceCurrency->round($this->_rate * $value);
     $value = sprintf("%f", $value);
     return $this->_currency->toCurrency($value);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Filter.php

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

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

示例11: testGetCustomAmount

 public function testGetCustomAmount()
 {
     $exclude = false;
     $amount = 21.0;
     $convertedValue = 30.25;
     $customAmount = 42.0;
     $this->priceCurrencyMock->expects($this->any())->method('convertAndRound')->with($amount)->will($this->returnValue($convertedValue));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($convertedValue, $this->saleableItemMock, $exclude)->will($this->returnValue($customAmount));
     $this->assertEquals($customAmount, $this->price->getCustomAmount($amount, $exclude));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:AbstractPriceTest.php

示例12: getShippingAmount

 /**
  * Get credit memo shipping amount depend on configuration settings
  *
  * @return float
  */
 public function getShippingAmount()
 {
     $source = $this->getSource();
     if ($this->_taxConfig->displaySalesShippingInclTax($source->getOrder()->getStoreId())) {
         $shipping = $source->getBaseShippingInclTax();
     } else {
         $shipping = $source->getBaseShippingAmount();
     }
     return $this->priceCurrency->round($shipping) * 1;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Adjustments.php

示例13: testGetValue

 /**
  * @param bool $isValidInterval
  * @param float $specialPrice
  * @param float|bool $specialPriceValue
  *
  * @dataProvider specialPriceDataProvider
  */
 public function testGetValue($isValidInterval, $specialPrice, $specialPriceValue)
 {
     $expected = 56.34;
     $specialPriceModel = $this->objectManager->getObject('Magento\\Catalog\\Pricing\\Price\\SpecialPrice', ['saleableItem' => $this->prepareSaleableItem($specialPrice), 'localeDate' => $this->prepareLocaleDate($isValidInterval), 'priceCurrency' => $this->priceCurrencyMock]);
     if ($isValidInterval) {
         $this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->with($specialPriceValue)->will($this->returnValue($expected));
     } else {
         $expected = $specialPriceValue;
     }
     $this->assertSame($expected, $specialPriceModel->getValue());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:SpecialPriceTest.php

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

示例15: testGetLinkAmount

 public function testGetLinkAmount()
 {
     $amount = 100;
     $convertedAmount = 50;
     $this->linkMock->expects($this->once())->method('getPrice')->will($this->returnValue($amount));
     $this->linkMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->saleableItemMock));
     $this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->with($amount)->will($this->returnValue($convertedAmount));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($convertedAmount, $this->equalTo($this->saleableItemMock))->will($this->returnValue($convertedAmount));
     $result = $this->linkPrice->getLinkAmount($this->linkMock);
     $this->assertEquals($convertedAmount, $result);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:LinkPriceTest.php


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