I want to remove the selected Payment Method on page reload (or) load in checkout page(FrontEnd).

  • How about disable from admin area? – Adarsh Khatri Nov 1 '18 at 5:47
  • Please describe your question. – Payal Patel Nov 1 '18 at 5:47
  • Please explain what you're trying to do? – Haim Nov 1 '18 at 5:53
  • use javascript to hide selected payment method on page load – B.K Nov 1 '18 at 5:57
  • But , its throws Cannot read property 'push' of undefined – Mano M Nov 1 '18 at 6:16
 // Remove selected payment method on page onload
            initialize: function () {
                var deferred = $.Deferred();

                //Remove selected payment method from quote
                //Remove selected payment method from localstorage
                //Refresh payment section

                var self = this;

try this code.

add events.xml in Vendor\Module\etc\

<event name="payment_method_is_active">
    <observer name="hide-payment-method" instance="Vendor\Module\Observer\Paymentactive" />

and in Paymentactive.php observer add this code.

public function execute(\Magento\Framework\Event\Observer $observer) {

    $method = $observer->getEvent()->getMethodInstance();
    $result = $observer->getEvent()->getResult();
    $paymentCode = $method->getCode();
    if ($paymentCode == 'your_method_code') {
        return $result->setData('is_available', false); //hide method

    return $result->setData('is_available', true);


Hope this will help you.

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.