I'm using a custom module which already hides a payment method based off the quote grand total and a variable defined in the backend. But I need to also do another check, which will see if the product in the session quote contains a certain attribute and then show/hide the payment method.
This is what the file that determines this currently looks like:
class Pay4Later extends \Magento\Payment\Model\Method\AbstractMethod {
/**
* Payment code
*
* @var string
*/
protected $_code = 'pay4later';
/**
* Availability option
*
* @var bool
*/
protected $_isOffline = true;
protected $_isInitializeNeeded = true;
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null){
$required_cart = round(($this->getConfigData('min_loan')/90)*100);
if($quote && $quote->getBaseGrandTotal() > $required_cart) {
return true;
} else {
return false;
}
}
public function getConfigPaymentAction()
{
return ($this->getConfigData('order_status') == 'pending_payment')? null : parent::getConfigPaymentAction();
} }
I've tried to dump the $quote
variable, but nothing happens.