Disable specific shipping methods in Express Checkout modals
Remove specific shipping methods from the Express Checkout modal.
Certain shipping methods, like Pick up from store, might require additional customer input, such as the pickup address. These aren’t suitable for Express Checkout wallets, which don’t provide a way to customize the payment modal.
If you use this kind of shipping method, you can disable it for Express Checkout using a module customization.
Create a new module
Create a new module with the following directory structure. Replace Vendor with your preferred vendor name.
Inside registration.php, register your module with Magento.
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_StripeCustomizations',
__DIR__
);
Inside the relevant part of the product, define the module and set up dependencies to ensure it loads after the Stripe module.
Inside the relevant part of the product, define the following plugin:
Inside the relevant part of the product, create the an afterMethod interceptor:
<?php
namespace Vendor\StripeCustomizations\Plugin\Payments;
class ECEResponse
{
/**
* After plugin for getShippingRatesForQuoteShippingAddress method.
*
* @param $subject
* @param array $result
* @return array
*/
public function afterGetShippingRatesForQuoteShippingAddress($subject, array $result)
{
$idToRemove = "store_pickup";
return array_filter($result, function ($shippingRate) use ($idToRemove) {
return $shippingRate['id'] !== $idToRemove;
});
}
}
Enable the module:
php bin/magento module:enable Vendor_StripeCustomizations
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
