Skip to content

[Bug in code] magento2-hyva-compatibility-braintree: The $quote can be null you should check it.

The $quote can be null, so you should check for this condition.

paypal/magento2-hyva-compatibility-braintree:1.0.0

vendor/hyva-themes/magento2-hyva-checkout-braintree/Model/VaultPayment.php: 18

   public function isAvailable(CartInterface $quote = null): bool
    {
        if ($quote->getCustomerIsGuest()) {
            return false;
        }

        return parent::isAvailable($quote);
    }

Patch for fix:

Index: vendor/hyva-themes/magento2-hyva-checkout-braintree/Model/VaultPayment.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/hyva-themes/magento2-hyva-checkout-braintree/Model/VaultPayment.php b/vendor/hyva-themes/magento2-hyva-checkout-braintree/Model/VaultPayment.php
--- a/vendor/hyva-themes/magento2-hyva-checkout-braintree/Model/VaultPayment.php	
+++ b/vendor/hyva-themes/magento2-hyva-checkout-braintree/Model/VaultPayment.php	(date 1714131667033)
@@ -17,7 +17,7 @@
      */
     public function isAvailable(CartInterface $quote = null): bool
     {
-        if ($quote->getCustomerIsGuest()) {
+        if ($quote && $quote->getCustomerIsGuest()) {
             return false;
         }
 
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information