Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/691c51200f18faa8fb9c66ae37cd90e2 to your computer and use it in GitHub Desktop.
Save ipokkel/691c51200f18faa8fb9c66ae37cd90e2 to your computer and use it in GitHub Desktop.
Remove payment plans from an Addon Package checkout.
<?php
/**
* This recipe removes payment plans from the PMPro checkout page if
* checkout is for an Addon Package.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function remove_payment_plans_for_addon_package() {
global $pmpro_pages, $post;
// Is payment plans and addon packages active?
if ( ! function_exists( 'pmpropp_get_plan' ) || ! function_exists( 'pmproap_hasAccess')) {
return;
}
// Are we on checkout for an Addon Package?
if ( isset( $_REQUEST['ap'] ) && ! empty( $_REQUEST['ap'] ) && ( is_page( $pmpro_pages['checkout'] ) || strpos( $post->post_content, '[pmpro_checkout' ) !== false ) ) {
?>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#pmpropp_select_payment_plan").remove();
});
</script>
<?php
}
}
add_action( 'wp_footer', 'remove_payment_plans_for_addon_package' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment