Skip to content

Instantly share code, notes, and snippets.

@WPprodigy
Created July 28, 2018 19:17
Show Gist options
  • Save WPprodigy/5c541f215755f7507e3a5847f65050ad to your computer and use it in GitHub Desktop.
Save WPprodigy/5c541f215755f7507e3a5847f65050ad to your computer and use it in GitHub Desktop.
Hide "Cash on Delivery" on the order-pay page, and hide "PayPal Standard" on the main checkout page.
<?php
/**
* Hide "Cash on Delivery" on the order-pay page, and hide PayPal on the main checkout page.
*/
function wc_ninja_conditional_gateways_for_order_pay( $available_gateways ) {
if ( is_wc_endpoint_url( 'order-pay' ) ) {
unset( $available_gateways['cod'] );
} else {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'wc_ninja_conditional_gateways_for_order_pay' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment