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


PHP Data::getConfig方法代码示例

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


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

示例1: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @return \Magento\Framework\Gdata\Gshopping\Entry
  */
 public function convertAttribute($product, $entry)
 {
     $entry->cleanTaxes();
     if ($this->_taxData->getConfig()->priceIncludesTax()) {
         return $entry;
     }
     $calc = $this->calculation;
     $customerTaxClass = $calc->getDefaultCustomerTaxClass($product->getStoreId());
     $rates = $calc->getRatesByCustomerAndProductTaxClasses($customerTaxClass, $product->getTaxClassId());
     $targetCountry = $this->_config->getTargetCountry($product->getStoreId());
     $ratesTotal = 0;
     foreach ($rates as $rate) {
         if ($targetCountry == $rate['country']) {
             $regions = $this->_parseRegions($rate['state'], $rate['postcode']);
             $ratesTotal += count($regions);
             if ($ratesTotal > self::RATES_MAX) {
                 throw new \Magento\Framework\Model\Exception(__("Google shopping only supports %1 tax rates per product", self::RATES_MAX));
             }
             foreach ($regions as $region) {
                 $entry->addTax(array('tax_rate' => $rate['value'] * 100, 'tax_country' => empty($rate['country']) ? '*' : $rate['country'], 'tax_region' => $region));
             }
         }
     }
     return $entry;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:32,代码来源:Tax.php

示例2: _getAmountData

 /**
  * Calculate amount for order
  * @param \Magento\Sales\Model\Order $order
  * @return array
  * @throws \Exception
  */
 protected function _getAmountData(Order $order)
 {
     // if tax is included - need add to request only total amount
     if ($this->_taxData->getConfig()->priceIncludesTax()) {
         return $this->getTaxableAmount($order);
     } else {
         return $this->getNonTaxableAmount($order);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Request.php

示例3: testSetAmountWithIncludedTax

 /**
  * @covers \Magento\Paypal\Model\Hostedpro\Request::setAmount()
  */
 public function testSetAmountWithIncludedTax()
 {
     /** @var \Magento\Tax\Model\Config  $config */
     $config = $this->helper->getObject('Magento\\Tax\\Model\\Config');
     $config->setPriceIncludesTax(true);
     $this->taxData = $this->helper->getObject('Magento\\Tax\\Helper\\Data', ['taxConfig' => $config]);
     $this->_model = $this->helper->getObject('Magento\\Paypal\\Model\\Hostedpro\\Request', ['localeResolver' => $this->localeResolverMock, 'taxData' => $this->taxData]);
     static::assertTrue($this->taxData->getConfig()->priceIncludesTax());
     $amount = 19.65;
     $expectation = ['amount' => $amount, 'subtotal' => $amount];
     $payment = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $payment->expects(static::once())->method('getBaseAmountAuthorized')->willReturn($amount);
     $order->expects(static::once())->method('getPayment')->willReturn($payment);
     $this->_model->setAmount($order);
     static::assertEquals($expectation, $this->_model->getData());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:RequestTest.php

示例4: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @return \Magento\Framework\Gdata\Gshopping\Entry
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function convertAttribute($product, $entry)
 {
     $entry->cleanTaxes();
     if ($this->_taxData->getConfig()->priceIncludesTax()) {
         return $entry;
     }
     $defaultCustomerTaxClassId = $this->_getDefaultCustomerTaxClassId($product->getStoreId());
     $rates = $this->_taxRateManagement->getRatesByCustomerAndProductTaxClassId($defaultCustomerTaxClassId, $product->getTaxClassId());
     $targetCountry = $this->_config->getTargetCountry($product->getStoreId());
     $ratesTotal = 0;
     foreach ($rates as $rate) {
         $countryId = $rate->getTaxCountryId();
         $postcode = $rate->getTaxPostcode();
         if ($targetCountry == $countryId) {
             $regions = $this->_getRegionsByRegionId($rate->getTaxRegionId(), $postcode);
             $ratesTotal += count($regions);
             if ($ratesTotal > self::RATES_MAX) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('Google shopping only supports %1 tax rates per product', self::RATES_MAX));
             }
             foreach ($regions as $region) {
                 $adjustments = $product->getPriceInfo()->getAdjustments();
                 if (array_key_exists('tax', $adjustments)) {
                     $taxIncluded = true;
                 } else {
                     $taxIncluded = false;
                 }
                 $quoteDetailsItemDataArray = ['code' => $product->getSku(), 'type' => 'product', 'tax_class_key' => [TaxClassKeyInterface::KEY_TYPE => TaxClassKeyInterface::TYPE_ID, TaxClassKeyInterface::KEY_VALUE => $product->getTaxClassId()], 'unit_price' => $product->getPrice(), 'quantity' => 1, 'tax_included' => $taxIncluded, 'short_description' => $product->getName()];
                 $billingAddressDataArray = ['country_id' => $countryId, 'region' => ['region_id' => $rate->getTaxRegionId()], 'postcode' => $postcode];
                 $shippingAddressDataArray = ['country_id' => $countryId, 'region' => ['region_id' => $rate->getTaxRegionId()], 'postcode' => $postcode];
                 $quoteDetailsDataArray = ['billing_address' => $billingAddressDataArray, 'shipping_address' => $shippingAddressDataArray, 'customer_tax_class_key' => [TaxClassKeyInterface::KEY_TYPE => TaxClassKeyInterface::TYPE_ID, TaxClassKeyInterface::KEY_VALUE => $defaultCustomerTaxClassId], 'items' => [$quoteDetailsItemDataArray]];
                 $quoteDetailsObject = $this->_quoteDetailsFactory->create();
                 $this->dataObjectHelper->populateWithArray($quoteDetailsObject, $quoteDetailsDataArray, '\\Magento\\Tax\\Api\\Data\\QuoteDetailsInterface');
                 $taxDetails = $this->_taxCalculationService->calculateTax($quoteDetailsObject, $product->getStoreId());
                 $taxRate = $taxDetails->getTaxAmount() / $taxDetails->getSubtotal() * 100;
                 $entry->addTax(['tax_rate' => $taxRate, 'tax_country' => $countryId, 'tax_region' => $region]);
             }
         }
     }
     return $entry;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:48,代码来源:Tax.php

示例5: _setRedirectUrl

 /**
  * Create payment redirect url
  * @param bool|null $button
  * @param string $token
  * @return void
  */
 protected function _setRedirectUrl($button, $token)
 {
     $this->_redirectUrl = $button && !$this->_taxData->getConfig()->priceIncludesTax() ? $this->_config->getExpressCheckoutStartUrl($token) : $this->_config->getPayPalBasicStartUrl($token);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:Checkout.php


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