Frage

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

How can I do this?

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top