[ad_1]
Hi @preetindersodhi
How to fix this issue?
As with most custom business cases, you can use the provided filters from WooCommerce to achieve the desired functionality.
If you want to hide PayPal as a payment option if there are no shipping methods then you can add some simple PHP that filters it based on the shipping method availability.
Example:
add_filter('woocommerce_available_payment_gateways', function($gateways){
if(is_checkout()){
$packages = WC()->shipping()->get_packages();
$has_methods = array_reduce($packages, function($has_methods, $package){
if(!$has_methods){
return !empty($package['rates']);
}
return $has_methods;
}, false);
if(!$has_methods){
unset($gateways['ppcp']);
}
}
return $gateways;
});Kind Regards
