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


PHP Helper\Data类代码示例

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


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

示例1: execute

 /**
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(Observer $observer)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->weeeHelper->isEnabled()) {
         /** @var \Magento\Customer\Model\Data\Customer $customer */
         $customer = $observer->getData('customer');
         /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
         $addresses = $customer->getAddresses();
         if (isset($addresses)) {
             $defaultShippingFound = false;
             $defaultBillingFound = false;
             foreach ($addresses as $address) {
                 if ($address->isDefaultBilling()) {
                     $defaultBillingFound = true;
                     $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($address->isDefaultShipping()) {
                     $defaultShippingFound = true;
                     $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($defaultShippingFound && $defaultBillingFound) {
                     break;
                 }
             }
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:31,代码来源:CustomerLoggedIn.php

示例2: getWhichCalcPriceToUse

 /**
  * Returns which product price to use as a basis for the Weee's final price
  *
  * @param  int|null $storeId
  * @return string
  */
 protected function getWhichCalcPriceToUse($storeId = null)
 {
     $calcPrice = 'finalPrice';
     if ($this->weeeData->geDisplayExcl($storeId) || $this->weeeData->geDisplayExlDescIncl($storeId) || $this->taxData->priceIncludesTax() && $this->taxData->displayPriceExcludingTax()) {
         $calcPrice = 'basePrice';
     }
     return $calcPrice;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:14,代码来源:UpdateProductOptionsObserver.php

示例3: getTotalsForDisplay

 /**
  * Check if weee total amount should be included
  * array(
  *  $index => array(
  *      'amount'   => $amount,
  *      'label'    => $label,
  *      'font_size'=> $font_size
  *  )
  * )
  * @return array
  */
 public function getTotalsForDisplay()
 {
     /** @var $items \Magento\Sales\Model\Order\Item[] */
     $items = $this->getSource()->getAllItems();
     $store = $this->getSource()->getStore();
     $weeeTotal = $this->_weeeData->getTotalAmounts($items, $store);
     // If we have no Weee, check if we still need to display it
     if (!$weeeTotal && !filter_var($this->getDisplayZero(), FILTER_VALIDATE_BOOLEAN)) {
         return [];
     }
     // Display the Weee total amount
     $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
     $totals = [['amount' => $this->getOrder()->formatPriceTxt($weeeTotal), 'label' => __($this->getTitle()) . ':', 'font_size' => $fontSize]];
     return $totals;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:26,代码来源:Weee.php

示例4: getPriceConfiguration

 /**
  * Modify the options config for the front end to resemble the weee final price
  *
  * @param   \Magento\Framework\Event\Observer $observer
  * @return  $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_weeeData->isEnabled()) {
         $priceConfigObj = $observer->getData('configObj');
         $priceConfig = $priceConfigObj->getConfig();
         try {
             if (is_array($priceConfig)) {
                 foreach ($priceConfig as $keyConfigs => $configs) {
                     if (is_array($configs)) {
                         foreach ($configs as $keyConfig => $config) {
                             $calcPrice = 'finalPrice';
                             if ($this->_taxData->priceIncludesTax() && $this->_taxData->displayPriceExcludingTax()) {
                                 $calcPrice = 'basePrice';
                             }
                             if (array_key_exists('prices', $configs)) {
                                 $priceConfig[$keyConfigs]['prices']['weeePrice'] = ['amount' => $configs['prices'][$calcPrice]['amount']];
                             } else {
                                 foreach ($configs as $keyConfig => $config) {
                                     $priceConfig[$keyConfigs][$keyConfig]['prices']['weeePrice'] = ['amount' => $config['prices'][$calcPrice]['amount']];
                                 }
                             }
                         }
                     }
                 }
             }
             $priceConfigObj->setConfig($priceConfig);
         } catch (Exception $e) {
             return $this;
         }
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:39,代码来源:Observer.php

示例5: updateProductOptions

 /**
  * Change default JavaScript templates for options rendering
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function updateProductOptions(\Magento\Framework\Event\Observer $observer)
 {
     $response = $observer->getEvent()->getResponseObject();
     $options = $response->getAdditionalOptions();
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->_registry->registry('current_product');
     if (!$product) {
         return $this;
     }
     if ($this->_weeeData->isEnabled() && !$this->_weeeData->geDisplayIncl($product->getStoreId()) && !$this->_weeeData->geDisplayExcl($product->getStoreId())) {
         // only do processing on bundle product
         if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
             if (!array_key_exists('optionTemplate', $options)) {
                 $options['optionTemplate'] = '<%- data.label %>' . '<% if (data.finalPrice.value) { %>' . ' +<%- data.finalPrice.formatted %>' . '<% } %>';
             }
             foreach ($this->_weeeData->getWeeAttributesForBundle($product) as $weeAttribute) {
                 $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice' . $weeAttribute->getCode() . ') { %%>' . '  (' . $weeAttribute->getName() . ':<%%= data.weeePrice' . $weeAttribute->getCode() . '.formatted %%>)' . '<%% } %%>');
             }
             if ($this->_weeeData->geDisplayExlDescIncl($product->getStoreId())) {
                 $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice) { %%>' . '<%%= data.weeePrice.formatted %%>' . '<%% } %%>');
             }
         }
     }
     $response->setAdditionalOptions($options);
     return $this;
 }
开发者ID:Coplex,项目名称:magento2,代码行数:32,代码来源:Observer.php

示例6: updateBundleProductOptions

 /**
  * Process bundle options selection for prepare view json
  *
  * @param   \Magento\Framework\Event\Observer $observer
  * @return  $this
  */
 public function updateBundleProductOptions(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->_weeeData->isEnabled()) {
         return $this;
     }
     $response = $observer->getEvent()->getResponseObject();
     $selection = $observer->getEvent()->getSelection();
     $options = $response->getAdditionalOptions();
     $_product = $this->_registry->registry('current_product');
     $typeDynamic = \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes\Extend::DYNAMIC;
     if (!$_product || $_product->getPriceType() != $typeDynamic) {
         return $this;
     }
     $amount = $this->_weeeData->getAmount($selection);
     $attributes = $this->_weeeData->getProductWeeeAttributes($_product, null, null, null, $this->_weeeData->isTaxable());
     $amountInclTaxes = $this->_weeeData->getAmountInclTaxes($attributes);
     $taxes = $amountInclTaxes - $amount;
     $options['plusDisposition'] = $amount;
     $options['plusDispositionTax'] = $taxes < 0 ? 0 : $taxes;
     // Exclude Weee amount from excluding tax amount
     if (!$this->_weeeData->typeOfDisplay(array(0, 1, 4))) {
         $options['exclDisposition'] = true;
     }
     $response->setAdditionalOptions($options);
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:32,代码来源:Observer.php

示例7: testAfterAddressSave

 public function testAfterAddressSave()
 {
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->weeeHelperMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setIsPrimaryBilling(true);
     $address->setIsPrimaryShipping(true);
     $address->setCountryId(1);
     $address->setData('postcode', 11111);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->observerMock->expects($this->once())->method('getCustomerAddress')->willReturn($address);
     $this->session->afterAddressSave($this->observerMock);
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:SessionTest.php

示例8: initTotals

 /**
  * Create the weee ("FPT") totals summary
  *
  * @return $this
  */
 public function initTotals()
 {
     /** @var $items \Magento\Sales\Model\Order\Item[] */
     $items = $this->getSource()->getAllItems();
     $store = $this->getSource()->getStore();
     $weeeTotal = $this->weeeData->getTotalAmounts($items, $store);
     if ($weeeTotal) {
         // Add our total information to the set of other totals
         $total = new \Magento\Framework\DataObject(['code' => $this->getNameInLayout(), 'label' => __('FPT'), 'value' => $weeeTotal]);
         if ($this->getBeforeCondition()) {
             $this->getParentBlock()->addTotalBefore($total, $this->getBeforeCondition());
         } else {
             $this->getParentBlock()->addTotal($total, $this->getAfterCondition());
         }
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:Totals.php

示例9: testExecute

 public function testExecute()
 {
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->weeeHelperMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock();
     $this->observerMock->expects($this->once())->method('getData')->with('customer')->willReturn($customerMock);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setCountryId(1);
     $address->setPostCode(11111);
     $addresses = [$address];
     $customerMock->expects($this->once())->method('getAddresses')->willReturn($addresses);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->session->execute($this->observerMock);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:18,代码来源:CustomerLoggedInTest.php

示例10: getWhichCalcPriceToUse

 /**
  * Returns which product price to use as a basis for the Weee's final price
  *
  * @param  int|null $storeId
  * @param  array|null $weeeAttributesForBundle
  * @return string
  */
 protected function getWhichCalcPriceToUse($storeId = null, $weeeAttributesForBundle = null)
 {
     $calcPrice = 'finalPrice';
     if (!empty($weeeAttributesForBundle)) {
         if ($this->weeeData->isDisplayExcl($storeId) || $this->weeeData->isDisplayExclDescIncl($storeId) || $this->taxData->priceIncludesTax() && $this->taxData->displayPriceExcludingTax()) {
             $calcPrice = 'basePrice';
         }
     }
     return $calcPrice;
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:17,代码来源:GetPriceConfigurationObserver.php

示例11: fetch

 /**
  * Fetch the Weee total amount for display in totals block when building the initial quote
  *
  * @param   \Magento\Sales\Model\Quote\Address $address
  * @return  $this
  */
 public function fetch(\Magento\Sales\Model\Quote\Address $address)
 {
     /** @var $items \Magento\Sales\Model\Order\Item[] */
     $items = $this->_getAddressItems($address);
     $store = $address->getQuote()->getStore();
     $weeeTotal = $this->_weeeData->getTotalAmounts($items, $store);
     if ($weeeTotal) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => __('FPT'), 'value' => $weeeTotal, 'area' => null));
     }
     return $this;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:17,代码来源:Weee.php

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

示例13: _resetItemData

 /**
  * Reset information about FPT for shopping cart item
  *
  * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
  * @return  void
  */
 protected function _resetItemData($item)
 {
     $this->weeeData->setApplied($item, array());
     $item->setBaseWeeeTaxDisposition(0);
     $item->setWeeeTaxDisposition(0);
     $item->setBaseWeeeTaxRowDisposition(0);
     $item->setWeeeTaxRowDisposition(0);
     $item->setBaseWeeeTaxAppliedAmount(0);
     $item->setBaseWeeeTaxAppliedRowAmnt(0);
     $item->setWeeeTaxAppliedAmount(0);
     $item->setWeeeTaxAppliedRowAmount(0);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Weee.php

示例14: testGetBaseTotalAmounts

 public function testGetBaseTotalAmounts()
 {
     $item1BaseWeee = 4;
     $item2BaseWeee = 3;
     $expected = $item1BaseWeee + $item2BaseWeee;
     $itemProductSimple1 = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Item', ['getBaseWeeeTaxAppliedRowAmount'], [], '', false);
     $itemProductSimple2 = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Item', ['getBaseWeeeTaxAppliedRowAmount'], [], '', false);
     $items = [$itemProductSimple1, $itemProductSimple2];
     $itemProductSimple1->expects($this->any())->method('getBaseWeeeTaxAppliedRowAmount')->willReturn($item1BaseWeee);
     $itemProductSimple2->expects($this->any())->method('getBaseWeeeTaxAppliedRowAmount')->willReturn($item2BaseWeee);
     $this->assertEquals($expected, $this->helperData->getBaseTotalAmounts($items));
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:12,代码来源:DataTest.php

示例15: resetItemData

 /**
  * Reset information about Tax and Wee on FPT for shopping cart item
  *
  * @param   \Magento\Quote\Model\Quote\Item\AbstractItem $item
  * @return  void
  */
 protected function resetItemData($item)
 {
     $this->weeeData->setApplied($item, []);
     $item->setAssociatedTaxables([]);
     $item->setBaseWeeeTaxDisposition(0);
     $item->setWeeeTaxDisposition(0);
     $item->setBaseWeeeTaxRowDisposition(0);
     $item->setWeeeTaxRowDisposition(0);
     $item->setBaseWeeeTaxAppliedAmount(0);
     $item->setBaseWeeeTaxAppliedRowAmnt(0);
     $item->setWeeeTaxAppliedAmount(0);
     $item->setWeeeTaxAppliedRowAmount(0);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Weee.php


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