Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created January 11, 2021 09:55
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/8b75842bfa42e713702419224ba4a49d to your computer and use it in GitHub Desktop.
Save ipokkel/8b75842bfa42e713702419224ba4a49d to your computer and use it in GitHub Desktop.
This recipe changes the order of some Add Ons on the checkout page by unhooking them and hooking them in at a different hook available on the checkout page. #pmpro #paid-memberships-pro #hooks #priority
<?php
/**
* This recipe changes the order of Add Ons on the checkout page.
*
* 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 load_pmpro_donations_after_pricing_fields() {
if ( has_action( 'pmpro_checkout_after_level_cost', 'pmprodon_pmpro_checkout_after_level_cost' ) ) {
remove_action( 'pmpro_checkout_after_level_cost', 'pmprodon_pmpro_checkout_after_level_cost' );
add_action( 'pmpro_checkout_after_pricing_fields', 'pmprodon_pmpro_checkout_after_level_cost' );
}
}
add_action( 'init', 'load_pmpro_donations_after_pricing_fields' );
function load_pmpro_auto_renew_checkbox_after_level_cost() {
if ( has_action( 'pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15 ) ) {
remove_action( 'pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15 );
add_action( 'pmpro_checkout_after_user_fields', 'pmproarc_pmpro_checkout_boxes', 15 );
}
}
add_action( 'init', 'load_pmpro_auto_renew_checkbox_after_level_cost' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment