2

In addition of Magento 2: How to show/hide payment method on basis of amount

Below code i have

namespace Vendor\Module\Model;

class Express extends \Magento\Paypal\Model\Express {

    public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) {
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();

        $quote = $_objectManager->get('Magento\Checkout\Model\Cart');
        $quoteitems = $quote->getQuote()->getData();

        echo "<pre>";
        print_r($quoteitems);
        exit;
    }
}

Output

Array

(
    [is_checkout_cart] => 1
    [store_id] => 1
    [remote_ip] => ::1
    [x_forwarded_for] => 
)

It's not giving my any Cart related information, Items, Base Total, Grand Total, etc..

Also referred http://www.ibnab.com/en/blog/magento-2/magento-2-useful-snippets-for-frontend-developers also not working

If i put any kind of Constructor it's not allowing me to do so.

1

You can try with below code,

<?php
namespace Vendor\Module\Model;

use Magento\Quote\Model\Quote\Item;
use Magento\Quote\Api\CartItemRepositoryInterface as QuoteItemRepository;


class Express extends \Magento\Paypal\Model\Express 
{

    public function __construct(
        \Magento\Checkout\Model\Session $checkoutSession,
        QuoteItemRepository $quoteItemRepository
    ) {
        $this->checkoutSession = $checkoutSession;
        $this->quoteItemRepository = $quoteItemRepository;
    }

    public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
    {
       echo "<pre>";print_r($quote->debug());

        //return $result;
    }
}
  • Not getting $quoteId it's Blank – Ankit Shah Oct 7 '16 at 6:33
  • Hi @Rakesh any advise?? – Ankit Shah Oct 10 '16 at 1:09
  • Try with updated answer. – Rakesh Jesadiya Oct 10 '16 at 4:51
  • It's not showing anything. Only blank page. – Ankit Shah Oct 10 '16 at 6:03
  • Have you checked $quote->getStoreId() to display anything? – Rakesh Jesadiya Oct 10 '16 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.