private function getProductTaxClassId() { $proxyOrder = $this->proxyItem->getProxyOrder(); $itemTaxRate = $this->proxyItem->getTaxRate(); $isOrderHasTax = $this->proxyItem->getProxyOrder()->hasTax(); $hasRatesForCountry = $this->taxHelper->hasRatesForCountry($this->quote->getShippingAddress()->getCountryId()); $calculationBasedOnOrigin = $this->taxHelper->isCalculationBasedOnOrigin($this->quote->getStore()); if ($proxyOrder->isTaxModeNone() || $proxyOrder->isTaxModeChannel() && $itemTaxRate <= 0 || $proxyOrder->isTaxModeMagento() && !$hasRatesForCountry && !$calculationBasedOnOrigin || $proxyOrder->isTaxModeMixed() && $itemTaxRate <= 0 && $isOrderHasTax) { return \Ess\M2ePro\Model\Magento\Product::TAX_CLASS_ID_NONE; } if ($proxyOrder->isTaxModeMagento() || $itemTaxRate <= 0 || $itemTaxRate == $this->getProductTaxRate()) { return $this->getProduct()->getTaxClassId(); } // Create tax rule according to channel tax rate // --------------------------------------- /** @var $taxRuleBuilder \Ess\M2ePro\Model\Magento\Tax\Rule\Builder */ $taxRuleBuilder = $this->modelFactory->getObject('Magento\\Tax\\Rule\\Builder'); $taxRuleBuilder->buildTaxRule($itemTaxRate, $this->quote->getShippingAddress()->getCountryId(), $this->quote->getCustomerTaxClassId()); $taxRule = $taxRuleBuilder->getRule(); $productTaxClasses = $taxRule->getProductTaxClasses(); // --------------------------------------- return array_shift($productTaxClasses); }