ZeroTotal.php 832 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Model\Checks;
  7. use Magento\Payment\Model\MethodInterface;
  8. use Magento\Quote\Model\Quote;
  9. /**
  10. * Checks that order total is meaningful
  11. *
  12. * @api
  13. * @since 100.0.2
  14. */
  15. class ZeroTotal implements SpecificationInterface
  16. {
  17. /**
  18. * Check whether payment method is applicable to quote
  19. * Purposed to allow use in controllers some logic that was implemented in blocks only before
  20. *
  21. * @param MethodInterface $paymentMethod
  22. * @param \Magento\Quote\Model\Quote $quote
  23. * @return bool
  24. */
  25. public function isApplicable(MethodInterface $paymentMethod, Quote $quote)
  26. {
  27. return !($quote->getBaseGrandTotal() < 0.0001 && $paymentMethod->getCode() != 'free');
  28. }
  29. }