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


PHP Data::isEnabled方法代码示例

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


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

示例1: execute

 /**
  * Change default JavaScript templates for options rendering
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(\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)) {
                 $calcPrice = $this->getWhichCalcPriceToUse($product->getStoreId());
                 $options['optionTemplate'] = '<%- data.label %>' . '<% if (data.' . $calcPrice . '.value) { %>' . ' +<%- data.' . $calcPrice . '.formatted %>' . '<% } %>';
             }
             foreach ($this->weeeData->getWeeeAttributesForBundle($product) as $weeeAttributes) {
                 foreach ($weeeAttributes as $weeeAttribute) {
                     if (!preg_match('/' . $weeeAttribute->getCode() . '/', $options['optionTemplate'])) {
                         $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice' . $weeeAttribute->getCode() . ') { %%>' . '  (' . $weeeAttribute->getName() . ': <%%- data.weeePrice' . $weeeAttribute->getCode() . '.formatted %%>)' . '<%% } %%>');
                     }
                 }
             }
             if ($this->weeeData->geDisplayExlDescIncl($product->getStoreId())) {
                 $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice) { %%>' . '<%%- data.weeePrice.formatted %%>' . '<%% } %%>');
             }
         }
     }
     $response->setAdditionalOptions($options);
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:38,代码来源:UpdateProductOptionsObserver.php

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

示例3: collect

 /**
  * Collect Weee amounts for the quote / order
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
  * @param \Magento\Quote\Model\Quote\Address\Total $total
  * @return $this
  */
 public function collect(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)
 {
     AbstractTotal::collect($quote, $shippingAssignment, $total);
     $this->_store = $quote->getStore();
     if (!$this->weeeData->isEnabled($this->_store)) {
         return $this;
     }
     $address = $shippingAssignment->getShipping()->getAddress();
     $items = $shippingAssignment->getItems();
     if (!count($items)) {
         return $this;
     }
     $this->weeeTotalExclTax = 0;
     $this->weeeBaseTotalExclTax = 0;
     foreach ($items as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $this->resetItemData($item);
         if ($item->getHasChildren() && $item->isChildrenCalculated()) {
             foreach ($item->getChildren() as $child) {
                 $this->resetItemData($child);
                 $this->process($address, $total, $child);
             }
             $this->recalculateParent($item);
         } else {
             $this->process($address, $total, $item);
         }
     }
     $total->setWeeeCodeToItemMap($this->weeeCodeToItemMap);
     $total->setWeeeTotalExclTax($this->weeeTotalExclTax);
     $total->setWeeeBaseTotalExclTax($this->weeeBaseTotalExclTax);
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:42,代码来源:Weee.php

示例4: collect

 /**
  * Collect Weee amounts for the quote / order
  *
  * @param   \Magento\Quote\Model\Quote\Address $address
  * @return  $this
  */
 public function collect(\Magento\Quote\Model\Quote\Address $address)
 {
     AbstractTotal::collect($address);
     $this->_store = $address->getQuote()->getStore();
     if (!$this->weeeData->isEnabled($this->_store)) {
         return $this;
     }
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $this->weeeTotalExclTax = 0;
     $this->weeeBaseTotalExclTax = 0;
     foreach ($items as $item) {
         if ($item->getParentItemId()) {
             continue;
         }
         $this->_resetItemData($item);
         if ($item->getHasChildren() && $item->isChildrenCalculated()) {
             foreach ($item->getChildren() as $child) {
                 $this->_resetItemData($child);
                 $this->_process($address, $child);
             }
             $this->_recalculateParent($item);
         } else {
             $this->_process($address, $item);
         }
     }
     $address->setWeeeCodeToItemMap($this->weeeCodeToItemMap);
     $address->setWeeeTotalExclTax($this->weeeTotalExclTax);
     $address->setWeeeBaseTotalExclTax($this->weeeBaseTotalExclTax);
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:39,代码来源:Weee.php

示例5: 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 $customerAddress Address */
         $address = $observer->getCustomerAddress();
         // Check if the address is either the default billing, shipping, or both
         if ($address->getIsPrimaryBilling() || $address->getIsDefaultBilling()) {
             $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]);
         }
         if ($address->getIsPrimaryShipping() || $address->getIsDefaultShipping()) {
             $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegionId() : null, 'postcode' => $address->getPostcode()]);
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:AfterAddressSave.php

示例6: execute

 /**
  * 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 execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->weeeData->isEnabled()) {
         $priceConfigObj = $observer->getData('configObj');
         try {
             /** @var \Magento\Catalog\Model\Product $product */
             $product = $this->registry->registry('current_product');
             $weeeAttributesForBundle = $this->weeeData->getWeeeAttributesForBundle($product);
             $priceConfig = $this->recurConfigAndInsertWeeePrice($priceConfigObj->getConfig(), 'prices', $this->getWhichCalcPriceToUse($product->getStoreId(), $weeeAttributesForBundle), $weeeAttributesForBundle);
             $priceConfigObj->setConfig($priceConfig);
         } catch (\Exception $e) {
             return $this;
         }
     }
     return $this;
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:23,代码来源:GetPriceConfigurationObserver.php

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

示例8: aroundExecute

    /**
     * @param \Magento\Framework\App\ActionInterface $subject
     * @param callable $proceed
     * @param \Magento\Framework\App\RequestInterface $request
     * @return mixed
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function aroundExecute(
        \Magento\Framework\App\ActionInterface $subject,
        \Closure $proceed,
        \Magento\Framework\App\RequestInterface $request
    ) {
        if (!$this->weeeHelper->isEnabled() ||
            !$this->customerSession->isLoggedIn() ||
            !$this->moduleManager->isEnabled('Magento_PageCache') ||
            !$this->cacheConfig->isEnabled()) {
            return $proceed($request);
        }

        $basedOn = $this->taxHelper->getTaxBasedOn();
        if ($basedOn != 'shipping' && $basedOn != 'billing') {
            return $proceed($request);
        }

        $weeeTaxRegion = $this->getWeeeTaxRegion($basedOn);
        $websiteId = $this->storeManager->getStore()->getWebsiteId();
        $countryId = $weeeTaxRegion['countryId'];
        $regionId = $weeeTaxRegion['regionId'];

        if (!$countryId && !$regionId) {
            // country and region does not exist
            return $proceed($request);
        } else if ($countryId && !$regionId) {
            // country exist and region does not exist
            $regionId = 0;
            $exist = $this->weeeTax->isWeeeInLocation(
                $countryId,
                $regionId,
                $websiteId
            );
        } else {
            // country and region exist
            $exist = $this->weeeTax->isWeeeInLocation(
                $countryId,
                $regionId,
                $websiteId
            );
            if (!$exist) {
                // just check the country for weee
                $regionId = 0;
                $exist = $this->weeeTax->isWeeeInLocation(
                    $countryId,
                    $regionId,
                    $websiteId
                );
            }
        }

        if ($exist) {
            $this->httpContext->setValue(
                'weee_tax_region',
                ['countryId' => $countryId, 'regionId' => $regionId],
                0
            );
        }
        return $proceed($request);
    }
开发者ID:nblair,项目名称:magescotch,代码行数:70,代码来源:ContextPlugin.php

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

示例10: getBaseFinalRowDisplayPriceExclTax

 /**
  * Get base final row display price excluding tax, this will add Weee amount to rowTotal
  *
  * @return float
  */
 public function getBaseFinalRowDisplayPriceExclTax()
 {
     $baseRowTotalExclTax = $this->getItem()->getBaseRowTotal();
     if (!$this->weeeHelper->isEnabled()) {
         return $baseRowTotalExclTax;
     }
     return $baseRowTotalExclTax + $this->getItem()->getBaseWeeeTaxAppliedRowAmnt();
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:13,代码来源:Renderer.php

示例11: isIncludedInDisplayPrice

 /**
  * Define if adjustment is included in display price
  *
  * @return bool
  */
 public function isIncludedInDisplayPrice()
 {
     if ($this->taxHelper->displayPriceExcludingTax()) {
         return false;
     }
     if ($this->weeeHelper->isEnabled() == true && $this->weeeHelper->isTaxable() == true && $this->weeeHelper->typeOfDisplay([\Magento\Weee\Model\Tax::DISPLAY_EXCL]) == false) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:TaxAdjustment.php

示例12: getUnitDisplayPriceExclTax

 /**
  * Get display price for unit price excluding tax. The Weee amount will be added to unit price
  * depending on Weee display setting
  *
  * @param \Magento\Quote\Model\Quote\Item $item
  * @return float
  */
 private function getUnitDisplayPriceExclTax($item)
 {
     $priceExclTax = $item->getCalculationPrice();
     if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
         return $priceExclTax;
     }
     if ($this->getIncludeWeeeFlag()) {
         return $priceExclTax + $item->getWeeeTaxAppliedAmount();
     }
     return $priceExclTax;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:ItemObserver.php

示例13: execute

 /**
  * Change default JavaScript templates for options rendering
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(\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 the Weee module is enabled, then only do processing on bundle products
     if ($this->weeeData->isEnabled() && $product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
         if ($this->taxData->priceIncludesTax() && $this->taxData->displayPriceExcludingTax()) {
             // the Tax module might have set up a default, but we will re-decide which calcPrice field to use
             unset($options['optionTemplate']);
         }
         if (!array_key_exists('optionTemplate', $options)) {
             $calcPrice = $this->getWhichCalcPriceToUse($product->getStoreId());
             $options['optionTemplate'] = '<%- data.label %>' . '<% if (data.' . $calcPrice . '.value) { %>' . ' +<%- data.' . $calcPrice . '.formatted %>' . '<% } %>';
         }
         if (!$this->weeeData->isDisplayIncl($product->getStoreId()) && !$this->weeeData->isDisplayExcl($product->getStoreId())) {
             // we need to display the individual Weee amounts
             foreach ($this->weeeData->getWeeeAttributesForBundle($product) as $weeeAttributes) {
                 foreach ($weeeAttributes as $weeeAttribute) {
                     if (!preg_match('/' . $weeeAttribute->getCode() . '/', $options['optionTemplate'])) {
                         $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice' . $weeeAttribute->getCode() . ') { %%>' . '  (' . $weeeAttribute->getName() . ': <%%- data.weeePrice' . $weeeAttribute->getCode() . '.formatted %%>)' . '<%% } %%>');
                     }
                 }
             }
         }
         if ($this->weeeData->isDisplayExclDescIncl($product->getStoreId())) {
             $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice) { %%>' . '<%%- data.weeePrice.formatted %%>' . '<%% } %%>');
         }
     }
     $response->setAdditionalOptions($options);
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:43,代码来源:UpdateProductOptionsObserver.php

示例14: getPriceConfiguration

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

示例15: isWeeeEnabled

 /**
  * Check if fixed taxes are used in system
  *
  * @return  bool
  */
 public function isWeeeEnabled()
 {
     return $this->weeeHelper->isEnabled($this->storeManager->getStore()->getId());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:WeeeConfigProvider.php


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