Helper/Cart.php
public function hasProductRestrictions($quote = null)
    {

        $toggleCheckout = $this->configHelper->getToggleCheckout();

        if (!$toggleCheckout || !$toggleCheckout->active) {
            return false;
        }

        // get configured Product model getters that can restrict Bolt checkout usage
        $productRestrictionMethods = $toggleCheckout->productRestrictionMethods ?: [];

        // get configured Quote Item getters that can restrict Bolt checkout usage
        $itemRestrictionMethods = $toggleCheckout->itemRestrictionMethods ?: [];

        if (!$productRestrictionMethods && !$itemRestrictionMethods) {
            return false;
        }

        /** @var Quote $quote */
        $quote = $quote ?: $this->checkoutSession->getQuote();
        foreach ($quote->getAllVisibleItems() as $item) {
            // call every method on item, if returns true, do restrict
            foreach ($itemRestrictionMethods as $method) {
                if ($item->$method()) {
                    return true;
                }
            }
            // Non empty check to avoid unnecessary model load
            if ($productRestrictionMethods) {
                // get item product
                $product = $this->productFactory->create()->load($item->getProductId());
                // call every method on product, if returns true, do restrict
                foreach ($productRestrictionMethods as $method) {
                    if ($product->$method()) {
                        return true;
                    }
                }
            }
        }

        // no restrictions
        return false;
    }
public function hasProductRestrictions($quote = null)
    {

        $toggleCheckout = $this->configHelper->getToggleCheckout();

        if (!$toggleCheckout || !$toggleCheckout->active) {
            return false;
        }

        // get configured Product model getters that can restrict Bolt checkout usage
        $productRestrictionMethods = $toggleCheckout->productRestrictionMethods ?: [];

        // get configured Quote Item getters that can restrict Bolt checkout usage
        $itemRestrictionMethods = $toggleCheckout->itemRestrictionMethods ?: [];

        if (!$productRestrictionMethods && !$itemRestrictionMethods) {
            return false;
        }

        /** @var Quote $quote */
        $quote = $quote ?: $this->checkoutSession->getQuote();
        foreach ($quote->getAllVisibleItems() as $item) {
            // call every method on item, if returns true, do restrict
            foreach ($itemRestrictionMethods as $method) {
                if ($item->$method()) {
                    return true;
                }
            }
            // Non empty check to avoid unnecessary model load
            if ($productRestrictionMethods) {
                // get item product
                $product = $this->productFactory->create()->load($item->getProductId());
                // call every method on product, if returns true, do restrict
                foreach ($productRestrictionMethods as $method) {
                    if ($product->$method()) {
                        return true;
                    }
                }
            }
        }

        // no restrictions
        return false;
    }
public function hasProductRestrictions ( $ quote = null ) { $ toggleCheckout = $ this -> configHelper -> getToggleCheckout ( ) ; if ( ! $ toggleCheckout || ! $ toggleCheckout -> active ) { return false ; } // get configured Product model getters that can restrict Bolt checkout usage $ productRestrictionMethods = $ toggleCheckout -> productRestrictionMethods ? : [ ] ; // get configured Quote Item getters that can restrict Bolt checkout usage $ itemRestrictionMethods = $ toggleCheckout -> itemRestrictionMethods ? : [ ] ; if ( ! $ productRestrictionMethods && ! $ itemRestrictionMethods ) { return false ; } /** @var Quote $quote */ $ quote = $ quote ? : $ this -> checkoutSession -> getQuote ( ) ; foreach ( $ quote -> getAllVisibleItems ( ) as $ item ) { // call every method on item, if returns true, do restrict foreach ( $ itemRestrictionMethods as $ method ) { if ( $ item -> $ method ( ) ) { return true ; } } // Non empty check to avoid unnecessary model load if ( $ productRestrictionMethods ) { // get item product $ product = $ this -> productFactory -> create ( ) -> load ( $ item -> getProductId ( ) ) ; // call every method on product, if returns true, do restrict foreach ( $ productRestrictionMethods as $ method ) { if ( $ product -> $ method ( ) ) { return true ; } } } } // no restrictions return false ; }
Check the cart items for properties that are a restriction to Bolt checkout.
Properties are checked with getters specified in configuration.

@param Quote|null $quote
@return bool
Check the cart items for properties that are a restriction to Bolt checkout . Properties are checked with getters specified in configuration .