{"id":16755966,"date":"2023-05-22T01:24:53","date_gmt":"2023-05-22T01:24:53","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/hide-paypal-button-when-no-shipping-available\/"},"modified":"2023-05-22T01:24:53","modified_gmt":"2023-05-22T01:24:53","slug":"hide-paypal-button-when-no-shipping-available","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/hide-paypal-button-when-no-shipping-available\/","title":{"rendered":"hide paypal button when no shipping available"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">HI all , Below code hides the order button on checkout page when there are no available shipping methods. But unfortuntely unable to hide the paypal button in your plugin please suggest how to hide paypal button at checkout .<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>This code works for me. It hides the \"checkout\" button on checkout page if there are no available shipping methods. Goes into your child theme's functions.php.\n\n\/\/Hide checkout button if no shipping is available\nadd_filter('woocommerce_order_button_html', 'hide_checkout_button__no_shipping_html' );\nfunction hide_checkout_button__no_shipping_html( $button ) {\n\n    $package_counts = array();\n    $packages = WC()-&gt;shipping-&gt;get_packages();\n    foreach( $packages as $key =&gt; $pkg ) {\n        $package_counts&#091; $key ] = count( $pkg&#091; 'rates' ] );\n    }\n\n    if( in_array( 0, $package_counts ) ) { \/\/no available shipping method\n        $button = '';\n    }<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-16755966","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16755966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16755966\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16755966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}