本文整理汇总了PHP中Magento\Framework\Pricing\PriceCurrencyInterface类的典型用法代码示例。如果您正苦于以下问题:PHP PriceCurrencyInterface类的具体用法?PHP PriceCurrencyInterface怎么用?PHP PriceCurrencyInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PriceCurrencyInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testPrepareDataSource
public function testPrepareDataSource()
{
$itemName = 'itemName';
$oldItemValue = 'oldItemValue';
$newItemValue = 'newItemValue';
$dataSource = ['data' => ['items' => [[$itemName => $oldItemValue]]]];
$this->priceFormatterMock->expects($this->once())->method('format')->with($oldItemValue, false)->willReturn($newItemValue);
$this->model->setData('name', $itemName);
$dataSource = $this->model->prepareDataSource($dataSource);
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:PriceTest.php
示例17: testGetMinimalPrice
public function testGetMinimalPrice()
{
$expectedResult = 5;
$this->saleableInterfaceMock->expects($this->once())->method('getPrice')->will($this->returnValue($expectedResult));
$this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->will($this->returnArgument(0));
$this->bundleCalculatorMock->expects($this->once())->method('getMinRegularAmount')->with($expectedResult, $this->saleableInterfaceMock)->will($this->returnValue($expectedResult));
$result = $this->regularPrice->getMinimalPrice();
$this->assertEquals($expectedResult, $result, 'Incorrect amount');
//Calling a second time, should use cached value
$result = $this->regularPrice->getMinimalPrice();
$this->assertEquals($expectedResult, $result, 'Incorrect amount the second time');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:BundleRegularPriceTest.php
示例18: collect
/**
* @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$allowedAmount = $order->getShippingAmount() - $order->getShippingRefunded();
$baseAllowedAmount = $order->getBaseShippingAmount() - $order->getBaseShippingRefunded();
$orderShippingAmount = $order->getShippingAmount();
$orderBaseShippingAmount = $order->getBaseShippingAmount();
$orderShippingInclTax = $order->getShippingInclTax();
$orderBaseShippingInclTax = $order->getBaseShippingInclTax();
$shippingAmount = $baseShippingAmount = $shippingInclTax = $baseShippingInclTax = 0;
/**
* Check if shipping amount was specified (from invoice or another source).
* Using has magic method to allow setting 0 as shipping amount.
*/
if ($creditmemo->hasBaseShippingAmount()) {
$baseShippingAmount = $this->priceCurrency->round($creditmemo->getBaseShippingAmount());
/*
* Rounded allowed shipping refund amount is the highest acceptable shipping refund amount.
* Shipping refund amount shouldn't cause errors, if it doesn't exceed that limit.
* Note: ($x < $y + 0.0001) means ($x <= $y) for floats
*/
if ($baseShippingAmount < $this->priceCurrency->round($baseAllowedAmount) + 0.0001) {
$ratio = 0;
if ($orderBaseShippingAmount > 0) {
$ratio = $baseShippingAmount / $orderBaseShippingAmount;
}
/*
* Shipping refund amount should be equated to allowed refund amount,
* if it exceeds that limit.
* Note: ($x > $y - 0.0001) means ($x >= $y) for floats
*/
if ($baseShippingAmount > $baseAllowedAmount - 0.0001) {
$shippingAmount = $allowedAmount;
$baseShippingAmount = $baseAllowedAmount;
} else {
$shippingAmount = $this->priceCurrency->round($orderShippingAmount * $ratio);
}
$shippingInclTax = $this->priceCurrency->round($orderShippingInclTax * $ratio);
$baseShippingInclTax = $this->priceCurrency->round($orderBaseShippingInclTax * $ratio);
} else {
$baseAllowedAmount = $order->getBaseCurrency()->format($baseAllowedAmount, null, false);
throw new \Magento\Framework\Exception\LocalizedException(__('Maximum shipping amount allowed to refund is: %1', $baseAllowedAmount));
}
} else {
$shippingAmount = $allowedAmount;
$baseShippingAmount = $baseAllowedAmount;
$allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded();
$baseAllowedTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded();
$shippingInclTax = $this->priceCurrency->round($allowedAmount + $allowedTaxAmount);
$baseShippingInclTax = $this->priceCurrency->round($baseAllowedAmount + $baseAllowedTaxAmount);
}
$creditmemo->setShippingAmount($shippingAmount);
$creditmemo->setBaseShippingAmount($baseShippingAmount);
$creditmemo->setShippingInclTax($shippingInclTax);
$creditmemo->setBaseShippingInclTax($baseShippingInclTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $shippingAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseShippingAmount);
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:64,代码来源:Shipping.php
示例19: renderRangeLabel
/**
* Prepare text of range label
*
* @param float|string $fromPrice
* @param float|string $toPrice
* @return float|\Magento\Framework\Phrase
*/
public function renderRangeLabel($fromPrice, $toPrice)
{
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
$priceInterval = $this->scopeConfig->getValue(self::XML_PATH_ONE_PRICE_INTERVAL, ScopeInterface::SCOPE_STORE);
if ($toPrice === '') {
return __('%1 and above', $formattedFromPrice);
} elseif ($fromPrice == $toPrice && $priceInterval) {
return $formattedFromPrice;
} else {
if ($fromPrice != $toPrice) {
$toPrice -= 0.01;
}
return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:Render.php
示例20: testGetValue
public function testGetValue()
{
$this->priceInfoMock->expects($this->once())->method('getPrice')->with($this->equalTo('regular_price'))->will($this->returnValue($this->regularPrice));
$this->regularPrice->expects($this->once())->method('getValue')->will($this->returnValue(100));
$this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue(null));
$this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue(3));
$this->productMock->expects($this->once())->method('getResource')->will($this->returnValue($this->productResourceMock));
$this->productResourceMock->expects($this->once())->method('getAttribute')->with($this->equalTo('group_price'))->will($this->returnValue($this->attributeMock));
$this->attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($this->backendMock));
$this->backendMock->expects($this->once())->method('afterLoad')->with($this->equalTo($this->productMock))->will($this->returnValue($this->backendMock));
$this->priceCurrencyMock->expects($this->never())->method('convertAndRound');
$this->productMock->expects($this->once())->method('getData')->with($this->equalTo('group_price'), $this->equalTo(null))->will($this->returnValue([['cust_group' => 3, 'website_price' => 80]]));
$this->assertEquals(20, $this->groupPrice->getValue());
$this->assertEquals(20, $this->groupPrice->getValue());
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:GroupPriceTest.php
注:本文中的Magento\Framework\Pricing\PriceCurrencyInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论