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