Magento – Can’t remove “Check out with Paypal” Button on cart? [Magento2]

magento2mini-cartpaypal

I'm currently having the issue, that I cannot remove the Checkout with Paypal Button that comes from a Payment Option called Paypal Express Checkout.
In the Magento2 Configuration settings I did set "Display on Product Details Page" to "NO", but it doesn't seem to disable it.

I did clear Cache multiple times and still does not work. I've seen multiple people having this problem.

enter image description here

Best Answer

Take a look:

vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html

<div data-bind="html: getCartParam('extra_actions')"></div>

This button shortcut shows in this part.
The extra_actions cart data comes from:

vendor/magento/module-checkout/CustomerData/Cart.php

public function getSectionData()
{
    ......
    'extra_actions' => $this->layout->createBlock('Magento\Catalog\Block\ShortcutButtons')->toHtml(),
    ......   
}

Navigate to Magento\Catalog\Block\ShortcutButtons class, we will see a Dispatch shortcuts container event: shortcut_buttons_container.
The Paypal module will catch this event to add its button:

vendor/magento/module-paypal/etc/frontend/events.xml

<event name="shortcut_buttons_container">
        <observer name="paypal_shortcuts" instance="Magento\Paypal\Observer\AddPaypalShortcutsObserver"/>
</event>

In this event, it will checks the Paypal Method is available or not. So, the Paypal button will not show if the payment method is disable in Admin.

I did set "Display on Product Details Page" to "NO"

Yes, it will not affect on the minicart.

In this case, I have a suggestion for you. We can disable the paypal_shortcuts event, create the custom one. We can add more config for Paypal in Admin (e.g: Display on Mini Cart - Yes/No) and check this config in the custom event.