How to do Magento 2 payment method based on customer group in frontend checkout page .
Iam checking condition for Remaining Amount
But i want customer group also , if
Customer group=4 then only its should display
if($creditdata->getRemainingAmount()<$paymentamount)
return false;
else
return true;
Thanks in advance.
This is my code ....
<?php
namespace Ced\CreditLimit\Model;
class CreditPaymentHide extends \Ced\CreditLimit\Model\CreditPayment
{
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$checkoutdata = $objectManager->create('Magento\Checkout\Model\Cart');
$customer = $objectManager->create('Magento\Customer\Model\Session');
if(!$objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('b2bextension/credit_limit/enable')){
return false;
}
if($customer->isLoggedIn())
{
$creditdata = $objectManager->create('Ced\CreditLimit\Model\CreditLimit')->load($customer->getCustomerId(),'customer_id');
$discountTotal =0;
foreach ($checkoutdata->getQuote()->getAllItems() as $item){
$discountTotal += $item->getDiscountAmount();
}
$total = $checkoutdata->getQuote()->getBaseGrandTotal();
$paymentamount = $total-$discountTotal;
if($creditdata->getRemainingAmount()<$paymentamount)
return false;
else
return true;
}
else{
return false;
}
}
}