/** * Determine method availability based on quote amount and config data * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { $avail = parent::isAvailable($quote); if ($avail === false) { return false; } if ($quote === null) { return false; } /** @var \Magento\Quote\Model\Quote $quote */ if ($quote->hasVirtualItems()) { return false; } if ($this->getConfigData('billing_shipping_address_identical') && !$this->compareAddresses($quote)) { return false; } $currencies = explode(',', $this->getConfigData('currency')); if (!in_array($quote->getQuoteCurrencyCode(), $currencies)) { return false; } if (strlen($this->getConfigData('shippingcountry'))) { $countries = explode(',', $this->getConfigData('shippingcountry')); if (!in_array($quote->getShippingAddress()->getCountry(), $countries)) { return false; } } $billingAddress = $quote->getBillingAddress(); if (strlen($billingAddress->getCompany())) { return true; } if (!strlen($billingAddress->getVatId())) { return false; } return true; }
/** * Determine method availability based on quote amount and config data * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { $avail = parent::isAvailable($quote); if ($avail === false) { return false; } if ($quote === null) { return false; } $allowedGroup = $this->getConfigData('allowed_group'); if (!strlen($allowedGroup)) { return false; } return $this->getConfigData('allowed_group') == $quote->getCustomer()->getGroupId(); }
/** * Determine method availability based on quote amount and config data * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { $avail = parent::isAvailable($quote); if ($avail === false) { return false; } if ($quote === null) { return false; } if ($this->getConfigData('provider') == 'ratepay') { return $this->_isAvailableRatePay($quote); } elseif ($this->getConfigData('provider') == 'payolution') { return $this->_isAvailablePayolution($quote); } return true; }