I want to remove the selected Payment Method on page reload (or) load in checkout page(FrontEnd).
-
How about disable from admin area?– Adarsh KhatriCommented Nov 1, 2018 at 5:47
-
Please describe your question.– Payal PatelCommented Nov 1, 2018 at 5:47
-
Please explain what you're trying to do?– HaimCommented Nov 1, 2018 at 5:53
-
use javascript to hide selected payment method on page load– B.KCommented Nov 1, 2018 at 5:57
-
But , its throws Cannot read property 'push' of undefined– Mahi MCommented Nov 1, 2018 at 6:16
|
Show 1 more comment
2 Answers
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" />
</event>
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.
// Remove selected payment method on page onload
initialize: function () {
var deferred = $.Deferred();
//Remove selected payment method from quote
quote.setPaymentMethod(null);
//Remove selected payment method from localstorage
checkoutData.setSelectedPaymentMethod(null);
//Refresh payment section
getPaymentInformation(deferred);
var self = this;
this._super();
},
-
Do you know how to remove loader when selecting payment method? Commented Jan 17, 2020 at 7:26