本文整理汇总了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;
}
示例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);
}
}
示例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());
}
示例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;
}
示例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);
}