Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SpecificationPlugin.php
Go to the documentation of this file.
1 <?php
7 
11 use Magento\Paypal\Model\Billing\AgreementFactory;
13 
18 {
22  private $agreementFactory;
23 
27  public function __construct(AgreementFactory $agreementFactory)
28  {
29  $this->agreementFactory = $agreementFactory;
30  }
31 
43  public function afterIsApplicable(
44  SpecificationInterface $specification,
45  $result,
46  MethodInterface $paymentMethod,
48  ) {
49  if (!$result) {
50  return false;
51  }
52 
53  if ($paymentMethod->getCode() == Config::METHOD_BILLING_AGREEMENT) {
54  if ($quote->getCustomerId()) {
55  $availableBA = $this->agreementFactory->create()->getAvailableCustomerBillingAgreements(
56  $quote->getCustomerId()
57  );
58 
59  return count($availableBA) > 0;
60  }
61 
62  return false;
63  }
64 
65  return true;
66  }
67 }
$quote
afterIsApplicable(SpecificationInterface $specification, $result, MethodInterface $paymentMethod, Quote $quote)