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


PHP PriceCurrencyInterface::convert方法代码示例

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


在下文中一共展示了PriceCurrencyInterface::convert方法的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: collect

 /**
  * Collect recurring item parameters and copy to the address items
  *
  * @param \Magento\Sales\Model\Quote\Address $address
  * @return $this
  */
 public function collect(\Magento\Sales\Model\Quote\Address $address)
 {
     parent::collect($address);
     $items = $this->_getAddressItems($address);
     foreach ($items as $item) {
         if ($item->getProduct()->getIsRecurring()) {
             $paymentData = $item->getProduct()->getRecurringPayment();
             if (!empty($paymentData[$this->_paymentDataKey])) {
                 $item->setData($this->_itemRowTotalKey, $this->priceCurrency->convert($paymentData[$this->_paymentDataKey], $address->getQuote()->getStore()));
                 $this->_afterCollectSuccess($address, $item);
             }
         }
     }
     return $this;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:21,代码来源:AbstractRecurring.php

示例3: getConvertedPrice

 /**
  * Get item price converted to quote currency
  * @return float
  */
 public function getConvertedPrice()
 {
     $price = $this->_getData('converted_price');
     if ($price === null) {
         $price = $this->priceCurrency->convert($this->getPrice(), $this->getStore());
         $this->setData('converted_price', $price);
     }
     return $price;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:AbstractItem.php

示例4: _convertPrice

 /**
  * Convert price from default currency to current currency
  *
  * @param float $price
  * @param bool $round
  * @return float
  */
 protected function _convertPrice($price, $round = false)
 {
     if (empty($price)) {
         return 0;
     }
     $price = $this->priceCurrency->convert($price);
     if ($round) {
         $price = $this->priceCurrency->round($price);
     }
     return $price;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:18,代码来源:Configurable.php

示例5: getAmount

 /**
  * Obtain amount
  *
  * @param SaleableInterface $saleableItem
  * @return float
  */
 protected function getAmount(SaleableInterface $saleableItem)
 {
     $weeeTaxAmount = 0;
     $attributes = $this->weeeHelper->getProductWeeeAttributes($saleableItem, null, null, null, true, false);
     if ($attributes != null) {
         foreach ($attributes as $attribute) {
             $weeeTaxAmount += $attribute->getData('tax_amount');
         }
     }
     $weeeTaxAmount = $this->priceCurrency->convert($weeeTaxAmount);
     return $weeeTaxAmount;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:TaxAdjustment.php

示例6: process

 /**
  * Calculate item fixed tax and prepare information for discount and regular taxation
  *
  * @param   \Magento\Quote\Model\Quote\Address $address
  * @param   \Magento\Quote\Model\Quote\Address\Total $total
  * @param   \Magento\Quote\Model\Quote\Item\AbstractItem $item
  * @return  void|$this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function process(\Magento\Quote\Model\Quote\Address $address, \Magento\Quote\Model\Quote\Address\Total $total, $item)
 {
     $attributes = $this->weeeData->getProductWeeeAttributes($item->getProduct(), $address, $address->getQuote()->getBillingAddress(), $this->_store->getWebsiteId());
     $productTaxes = [];
     $totalValueInclTax = 0;
     $baseTotalValueInclTax = 0;
     $totalRowValueInclTax = 0;
     $baseTotalRowValueInclTax = 0;
     $totalValueExclTax = 0;
     $baseTotalValueExclTax = 0;
     $totalRowValueExclTax = 0;
     $baseTotalRowValueExclTax = 0;
     $associatedTaxables = $item->getAssociatedTaxables();
     if (!$associatedTaxables) {
         $associatedTaxables = [];
     } else {
         // remove existing weee associated taxables
         foreach ($associatedTaxables as $iTaxable => $taxable) {
             if ($taxable[CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TYPE] == self::ITEM_TYPE) {
                 unset($associatedTaxables[$iTaxable]);
             }
         }
     }
     foreach ($attributes as $key => $attribute) {
         $title = $attribute->getName();
         $baseValueExclTax = $baseValueInclTax = $attribute->getAmount();
         $valueExclTax = $valueInclTax = $this->priceCurrency->round($this->priceCurrency->convert($baseValueExclTax, $this->_store));
         $rowValueInclTax = $rowValueExclTax = $this->priceCurrency->round($valueInclTax * $item->getTotalQty());
         $baseRowValueInclTax = $this->priceCurrency->round($baseValueInclTax * $item->getTotalQty());
         $baseRowValueExclTax = $baseRowValueInclTax;
         $totalValueInclTax += $valueInclTax;
         $baseTotalValueInclTax += $baseValueInclTax;
         $totalRowValueInclTax += $rowValueInclTax;
         $baseTotalRowValueInclTax += $baseRowValueInclTax;
         $totalValueExclTax += $valueExclTax;
         $baseTotalValueExclTax += $baseValueExclTax;
         $totalRowValueExclTax += $rowValueExclTax;
         $baseTotalRowValueExclTax += $baseRowValueExclTax;
         $productTaxes[] = ['title' => $title, 'base_amount' => $baseValueExclTax, 'amount' => $valueExclTax, 'row_amount' => $rowValueExclTax, 'base_row_amount' => $baseRowValueExclTax, 'base_amount_incl_tax' => $baseValueInclTax, 'amount_incl_tax' => $valueInclTax, 'row_amount_incl_tax' => $rowValueInclTax, 'base_row_amount_incl_tax' => $baseRowValueInclTax];
         if ($this->weeeData->isTaxable($this->_store)) {
             $weeeItemCode = self::ITEM_CODE_WEEE_PREFIX . $this->getNextIncrement();
             $weeeItemCode .= '-' . $title;
             $associatedTaxables[] = [CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TYPE => self::ITEM_TYPE, CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_CODE => $weeeItemCode, CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_UNIT_PRICE => $valueExclTax, CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE => $baseValueExclTax, CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_QUANTITY => $item->getTotalQty(), CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID => $item->getProduct()->getTaxClassId()];
             $this->weeeCodeToItemMap[$weeeItemCode] = $item;
         }
     }
     $item->setAssociatedTaxables($associatedTaxables);
     $item->setWeeeTaxAppliedAmount($totalValueExclTax)->setBaseWeeeTaxAppliedAmount($baseTotalValueExclTax)->setWeeeTaxAppliedRowAmount($totalRowValueExclTax)->setBaseWeeeTaxAppliedRowAmnt($baseTotalRowValueExclTax);
     $item->setWeeeTaxAppliedAmountInclTax($totalValueInclTax)->setBaseWeeeTaxAppliedAmountInclTax($baseTotalValueInclTax)->setWeeeTaxAppliedRowAmountInclTax($totalRowValueInclTax)->setBaseWeeeTaxAppliedRowAmntInclTax($baseTotalRowValueInclTax);
     $this->processTotalAmount($total, $totalRowValueExclTax, $baseTotalRowValueExclTax, $totalRowValueInclTax, $baseTotalRowValueInclTax);
     $this->weeeData->setApplied($item, array_merge($this->weeeData->getApplied($item), $productTaxes));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:62,代码来源:Weee.php

示例7: getJsonConfig

 /**
  * Get JSON encoded configuration array which can be used for JS dynamic
  * price calculation depending on product options
  *
  * @return string
  */
 public function getJsonConfig()
 {
     /* @var $product \Magento\Catalog\Model\Product */
     $product = $this->getProduct();
     if (!$this->hasOptions()) {
         $config = ['productId' => $product->getId(), 'priceFormat' => $this->_localeFormat->getPriceFormat()];
         return $this->_jsonEncoder->encode($config);
     }
     $tierPrices = [];
     $tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
     foreach ($tierPricesList as $tierPrice) {
         $tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
     }
     $config = ['productId' => $product->getId(), 'priceFormat' => $this->_localeFormat->getPriceFormat(), 'prices' => ['oldPrice' => ['amount' => $this->priceCurrency->convert($product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue()), 'adjustments' => []], 'basePrice' => ['amount' => $this->priceCurrency->convert($product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount()), 'adjustments' => []], 'finalPrice' => ['amount' => $this->priceCurrency->convert($product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()), 'adjustments' => []]], 'idSuffix' => '_clone', 'tierPrices' => $tierPrices];
     $responseObject = new \Magento\Framework\DataObject();
     $this->_eventManager->dispatch('catalog_product_view_config', ['response_object' => $responseObject]);
     if (is_array($responseObject->getAdditionalOptions())) {
         foreach ($responseObject->getAdditionalOptions() as $option => $value) {
             $config[$option] = $value;
         }
     }
     return $this->_jsonEncoder->encode($config);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:View.php

示例8: processShippingAmount

 /**
  * Apply discounts to shipping amount
  *
  * @param Address $address
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function processShippingAmount(Address $address)
 {
     $shippingAmount = $address->getShippingAmountForDiscount();
     if ($shippingAmount !== null) {
         $baseShippingAmount = $address->getBaseShippingAmountForDiscount();
     } else {
         $shippingAmount = $address->getShippingAmount();
         $baseShippingAmount = $address->getBaseShippingAmount();
     }
     $quote = $address->getQuote();
     $appliedRuleIds = [];
     foreach ($this->_getRules() as $rule) {
         /* @var \Magento\SalesRule\Model\Rule $rule */
         if (!$rule->getApplyToShipping() || !$this->validatorUtility->canProcessRule($rule, $address)) {
             continue;
         }
         $discountAmount = 0;
         $baseDiscountAmount = 0;
         $rulePercent = min(100, $rule->getDiscountAmount());
         switch ($rule->getSimpleAction()) {
             case \Magento\SalesRule\Model\Rule::TO_PERCENT_ACTION:
                 $rulePercent = max(0, 100 - $rule->getDiscountAmount());
                 // break is intentionally omitted
             // break is intentionally omitted
             case \Magento\SalesRule\Model\Rule::BY_PERCENT_ACTION:
                 $discountAmount = ($shippingAmount - $address->getShippingDiscountAmount()) * $rulePercent / 100;
                 $baseDiscountAmount = ($baseShippingAmount - $address->getBaseShippingDiscountAmount()) * $rulePercent / 100;
                 $discountPercent = min(100, $address->getShippingDiscountPercent() + $rulePercent);
                 $address->setShippingDiscountPercent($discountPercent);
                 break;
             case \Magento\SalesRule\Model\Rule::TO_FIXED_ACTION:
                 $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $quote->getStore());
                 $discountAmount = $shippingAmount - $quoteAmount;
                 $baseDiscountAmount = $baseShippingAmount - $rule->getDiscountAmount();
                 break;
             case \Magento\SalesRule\Model\Rule::BY_FIXED_ACTION:
                 $quoteAmount = $this->priceCurrency->convert($rule->getDiscountAmount(), $quote->getStore());
                 $discountAmount = $quoteAmount;
                 $baseDiscountAmount = $rule->getDiscountAmount();
                 break;
             case \Magento\SalesRule\Model\Rule::CART_FIXED_ACTION:
                 $cartRules = $address->getCartFixedRules();
                 if (!isset($cartRules[$rule->getId()])) {
                     $cartRules[$rule->getId()] = $rule->getDiscountAmount();
                 }
                 if ($cartRules[$rule->getId()] > 0) {
                     $quoteAmount = $this->priceCurrency->convert($cartRules[$rule->getId()], $quote->getStore());
                     $discountAmount = min($shippingAmount - $address->getShippingDiscountAmount(), $quoteAmount);
                     $baseDiscountAmount = min($baseShippingAmount - $address->getBaseShippingDiscountAmount(), $cartRules[$rule->getId()]);
                     $cartRules[$rule->getId()] -= $baseDiscountAmount;
                 }
                 $address->setCartFixedRules($cartRules);
                 break;
         }
         $discountAmount = min($address->getShippingDiscountAmount() + $discountAmount, $shippingAmount);
         $baseDiscountAmount = min($address->getBaseShippingDiscountAmount() + $baseDiscountAmount, $baseShippingAmount);
         $address->setShippingDiscountAmount($discountAmount);
         $address->setBaseShippingDiscountAmount($baseDiscountAmount);
         $appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
         $this->rulesApplier->maintainAddressCouponCode($address, $rule, $this->getCouponCode());
         $this->rulesApplier->addDiscountDescription($address, $rule);
         if ($rule->getStopRulesProcessing()) {
             break;
         }
     }
     $address->setAppliedRuleIds($this->validatorUtility->mergeIds($address->getAppliedRuleIds(), $appliedRuleIds));
     $quote->setAppliedRuleIds($this->validatorUtility->mergeIds($quote->getAppliedRuleIds(), $appliedRuleIds));
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:76,代码来源:Validator.php

示例9: getAmount

 /**
  * Obtain amount
  *
  * @param SaleableInterface $saleableItem
  * @return float
  */
 protected function getAmount(SaleableInterface $saleableItem)
 {
     $weeeAmount = $this->weeeHelper->getAmountExclTax($saleableItem);
     $weeeAmount = $this->priceCurrency->convert($weeeAmount);
     return $weeeAmount;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Adjustment.php

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

示例11: collect


//.........这里部分代码省略.........
     $addressWeight = $address->getWeight();
     $freeMethodWeight = $address->getFreeMethodWeight();
     $addressQty = 0;
     foreach ($items as $item) {
         /**
          * Skip if this item is virtual
          */
         if ($item->getProduct()->isVirtual()) {
             continue;
         }
         /**
          * Children weight we calculate for parent
          */
         if ($item->getParentItem()) {
             continue;
         }
         if ($item->getHasChildren() && $item->isShipSeparately()) {
             foreach ($item->getChildren() as $child) {
                 if ($child->getProduct()->isVirtual()) {
                     continue;
                 }
                 $addressQty += $child->getTotalQty();
                 if (!$item->getProduct()->getWeightType()) {
                     $itemWeight = $child->getWeight();
                     $itemQty = $child->getTotalQty();
                     $rowWeight = $itemWeight * $itemQty;
                     $addressWeight += $rowWeight;
                     if ($freeAddress || $child->getFreeShipping() === true) {
                         $rowWeight = 0;
                     } elseif (is_numeric($child->getFreeShipping())) {
                         $freeQty = $child->getFreeShipping();
                         if ($itemQty > $freeQty) {
                             $rowWeight = $itemWeight * ($itemQty - $freeQty);
                         } else {
                             $rowWeight = 0;
                         }
                     }
                     $freeMethodWeight += $rowWeight;
                     $item->setRowWeight($rowWeight);
                 }
             }
             if ($item->getProduct()->getWeightType()) {
                 $itemWeight = $item->getWeight();
                 $rowWeight = $itemWeight * $item->getQty();
                 $addressWeight += $rowWeight;
                 if ($freeAddress || $item->getFreeShipping() === true) {
                     $rowWeight = 0;
                 } elseif (is_numeric($item->getFreeShipping())) {
                     $freeQty = $item->getFreeShipping();
                     if ($item->getQty() > $freeQty) {
                         $rowWeight = $itemWeight * ($item->getQty() - $freeQty);
                     } else {
                         $rowWeight = 0;
                     }
                 }
                 $freeMethodWeight += $rowWeight;
                 $item->setRowWeight($rowWeight);
             }
         } else {
             if (!$item->getProduct()->isVirtual()) {
                 $addressQty += $item->getQty();
             }
             $itemWeight = $item->getWeight();
             $rowWeight = $itemWeight * $item->getQty();
             $addressWeight += $rowWeight;
             if ($freeAddress || $item->getFreeShipping() === true) {
                 $rowWeight = 0;
             } elseif (is_numeric($item->getFreeShipping())) {
                 $freeQty = $item->getFreeShipping();
                 if ($item->getQty() > $freeQty) {
                     $rowWeight = $itemWeight * ($item->getQty() - $freeQty);
                 } else {
                     $rowWeight = 0;
                 }
             }
             $freeMethodWeight += $rowWeight;
             $item->setRowWeight($rowWeight);
         }
     }
     if (isset($addressQty)) {
         $address->setItemQty($addressQty);
     }
     $address->setWeight($addressWeight);
     $address->setFreeMethodWeight($freeMethodWeight);
     $address->collectShippingRates();
     $this->_setAmount(0)->_setBaseAmount(0);
     if ($method) {
         foreach ($address->getAllShippingRates() as $rate) {
             if ($rate->getCode() == $method) {
                 $amountPrice = $this->priceCurrency->convert($rate->getPrice(), $address->getQuote()->getStore());
                 $this->_setAmount($amountPrice);
                 $this->_setBaseAmount($rate->getPrice());
                 $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
                 $address->setShippingDescription(trim($shippingDescription, ' -'));
                 break;
             }
         }
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:101,代码来源:Shipping.php

示例12: _setAttributePrice

 /**
  * Custom setter for 'price' attribute
  *
  * @param Entry $entry
  * @param Product $product
  * @param mixed $value Fload price value
  * @param string $name Google Content attribute name
  * @return Entry
  */
 protected function _setAttributePrice($entry, $product, $value, $name = 'price')
 {
     $store = $this->_storeManager->getStore($product->getStoreId());
     $price = $this->priceCurrency->convert($value, $store);
     return $this->_setAttribute($entry, $name, self::ATTRIBUTE_TYPE_FLOAT, sprintf('%.2f', $this->priceCurrency->round($price)), $store->getDefaultCurrencyCode());
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:15,代码来源:Price.php

示例13: convertPrice

 /**
  * Convert price
  *
  * @param float $value
  * @param bool $format
  * @return float
  */
 public function convertPrice($value, $format = true)
 {
     return $format ? $this->priceCurrency->convertAndFormat($value, true, PriceCurrencyInterface::DEFAULT_PRECISION, $this->getStore()) : $this->priceCurrency->convert($value, $this->getStore());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:AbstractCreate.php

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

示例15: getJsonConfig

 /**
  * Returns JSON encoded config to be used in JS scripts
  *
  * @return string
  * 
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function getJsonConfig()
 {
     /** @var \Magento\Bundle\Model\Option[] $optionsArray */
     $optionsArray = $this->getOptions();
     $options = array();
     $selected = array();
     $currentProduct = $this->getProduct();
     if ($preConfiguredFlag = $currentProduct->hasPreconfiguredValues()) {
         $preConfiguredValues = $currentProduct->getPreconfiguredValues();
         $defaultValues = array();
     }
     $position = 0;
     foreach ($optionsArray as $optionItem) {
         /* @var $optionItem \Magento\Bundle\Model\Option */
         if (!$optionItem->getSelections()) {
             continue;
         }
         $optionId = $optionItem->getId();
         $option = array('selections' => array(), 'title' => $optionItem->getTitle(), 'isMulti' => in_array($optionItem->getType(), array('multi', 'checkbox')), 'position' => $position++);
         $selectionCount = count($optionItem->getSelections());
         foreach ($optionItem->getSelections() as $selectionItem) {
             /* @var $selectionItem \Magento\Catalog\Model\Product */
             $selectionId = $selectionItem->getSelectionId();
             $qty = !($selectionItem->getSelectionQty() * 1) ? '1' : $selectionItem->getSelectionQty() * 1;
             // recalculate currency
             $tierPrices = $selectionItem->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE)->getTierPriceList();
             foreach ($tierPrices as &$tierPriceInfo) {
                 /** @var \Magento\Framework\Pricing\Amount\Base $price */
                 $price = $tierPriceInfo['price'];
                 $priceBaseAmount = $price->getBaseAmount();
                 $priceValue = $price->getValue();
                 $bundleProductPrice = $this->_productPrice->create();
                 $priceBaseAmount = $bundleProductPrice->getLowestPrice($currentProduct, $priceBaseAmount);
                 $priceValue = $bundleProductPrice->getLowestPrice($currentProduct, $priceValue);
                 $tierPriceInfo['price'] = $this->priceCurrency->convert($this->_taxData->displayPriceIncludingTax() ? $priceValue : $priceBaseAmount);
                 $tierPriceInfo['exclTaxPrice'] = $this->priceCurrency->convert($priceBaseAmount);
                 $tierPriceInfo['inclTaxPrice'] = $this->priceCurrency->convert($priceValue);
             }
             // break the reference with the last element
             $canApplyMAP = false;
             $bundleOptionPriceAmount = $currentProduct->getPriceInfo()->getPrice('bundle_option')->getOptionSelectionAmount($selectionItem);
             $priceInclTax = $bundleOptionPriceAmount->getValue();
             $priceExclTax = $bundleOptionPriceAmount->getBaseAmount();
             $selection = array('qty' => $qty, 'customQty' => $selectionItem->getSelectionCanChangeQty(), 'inclTaxPrice' => $this->priceCurrency->convert($priceInclTax), 'exclTaxPrice' => $this->priceCurrency->convert($priceExclTax), 'priceType' => $selectionItem->getSelectionPriceType(), 'tierPrice' => $tierPrices, 'name' => $selectionItem->getName(), 'plusDisposition' => 0, 'minusDisposition' => 0, 'canApplyMAP' => $canApplyMAP);
             $selection['price'] = $this->_taxData->displayPriceIncludingTax() ? $selection['inclTaxPrice'] : $selection['exclTaxPrice'];
             $responseObject = new \Magento\Framework\Object();
             $args = array('response_object' => $responseObject, 'selection' => $selectionItem);
             $this->_eventManager->dispatch('bundle_product_view_config', $args);
             if (is_array($responseObject->getAdditionalOptions())) {
                 foreach ($responseObject->getAdditionalOptions() as $index => $value) {
                     $selection[$index] = $value;
                 }
             }
             $option['selections'][$selectionId] = $selection;
             if (($selectionItem->getIsDefault() || $selectionCount == 1 && $optionItem->getRequired()) && $selectionItem->isSalable()) {
                 $selected[$optionId][] = $selectionId;
             }
         }
         $options[$optionId] = $option;
         // Add attribute default value (if set)
         if ($preConfiguredFlag) {
             $configValue = $preConfiguredValues->getData('bundle_option/' . $optionId);
             if ($configValue) {
                 $defaultValues[$optionId] = $configValue;
             }
         }
     }
     $isFixedPrice = $this->getProduct()->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED;
     $productAmount = $currentProduct->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)->getAmount();
     $baseProductAmount = $currentProduct->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\RegularPrice::PRICE_CODE)->getAmount();
     $config = array('options' => $options, 'selected' => $selected, 'bundleId' => $currentProduct->getId(), 'priceFormat' => $this->_localeFormat->getPriceFormat(), 'basePrice' => $this->priceCurrency->convert($baseProductAmount->getValue()), 'finalBasePriceInclTax' => $isFixedPrice ? $this->priceCurrency->convert($productAmount->getValue()) : 0, 'finalBasePriceExclTax' => $isFixedPrice ? $this->priceCurrency->convert($productAmount->getBaseAmount()) : 0, 'priceType' => $currentProduct->getPriceType(), 'specialPrice' => $currentProduct->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\SpecialPrice::PRICE_CODE)->getValue(), 'includeTax' => $this->_taxData->priceIncludesTax() ? 'true' : 'false', 'isFixedPrice' => $isFixedPrice);
     $config['finalPrice'] = $this->_taxData->displayPriceIncludingTax() ? $config['finalBasePriceInclTax'] : $config['finalBasePriceExclTax'];
     if ($preConfiguredFlag && !empty($defaultValues)) {
         $config['defaultValues'] = $defaultValues;
     }
     return $this->jsonEncoder->encode($config);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:86,代码来源:Bundle.php


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