/** * @param Quote|\Magento\Quote\Api\Data\CartInterface $quote * * @return bool */ protected function _isAvailableRatePay($quote) { $dob = $quote->getCustomer()->getDob(); $minAge = (int) $this->getConfigData('min_age'); if ($minAge <= 0) { $this->_logger->debug(__METHOD__ . ':warning min-age not set for ratepay'); return false; } //we only need to check the dob if it's set. Else we ask for dob on payment selection page. if ($dob) { $dobObject = new \DateTime($dob); $currentYear = date('Y'); $currentMonth = date('m'); $currentDay = date('d'); $ageCheckDate = $currentYear - $minAge . '-' . $currentMonth . '-' . $currentDay; $ageCheckObject = new \DateTime($ageCheckDate); if ($ageCheckObject < $dobObject) { return false; } } 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; } } if (strlen($this->getConfigData('max_basket_size'))) { if ($quote->getItemsQty() > $this->getConfigData('max_basket_size')) { return false; } } if (strlen($this->getConfigData('min_basket_size'))) { if ($quote->getItemsQty() < $this->getConfigData('min_basket_size')) { return false; } } return parent::isAvailable($quote); }