0

This question already has an answer here:

I want to hide cash on delivery payment method for a specific product.

How can I do this?

marked as duplicate by Siarhey Uchukhlebau, Piyush, Manoj Deswal, Jai, liyakat Apr 9 '18 at 9:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

You could use this and add a condition for checking product's SKU using the quote like this:

    use \Magento\Checkout\Model\Session as CheckoutSession;

    /** @var CheckoutSession */
        protected $checkoutSession;

        /**
         * @param CheckoutSession $checkoutSession
         */
        public function __construct(CheckoutSession $checkoutSession) {
            $this->checkoutSession = $checkoutSession;
        }

        public function afterIsAvailable(Cashondelivery $subject, $result) {
    -------------
            /** @var \Magento\Quote\Model\Quote  */
            $quote = $this->checkoutSession->getQuote();
$products = $quote->getAllItems();
-----------------------
        }

check for sku and return false

  • it is not working, Checkout stops when using this module. – Vinod Kumar Apr 9 '18 at 9:15
  • public function afterIsAvailable(Cashondelivery $subject, $result) {} it is not working – Vinod Kumar Apr 9 '18 at 9:56

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