Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created April 8, 2025 05:46
Show Gist options
  • Save ipokkel/0c5ae240125f9cd5191547be3551f11e to your computer and use it in GitHub Desktop.
Save ipokkel/0c5ae240125f9cd5191547be3551f11e to your computer and use it in GitHub Desktop.
Show the checkout price above the submit button on the PMPro Checkout page.
<?php
/**
* Display the price of the level before the submit button.
*
* 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 my_pmpro_price_before_submit() {
// Get checkout level object.
if ( function_exists( 'pmpro_getLevelAtCheckout' ) ) {
$pmpro_level = pmpro_getLevelAtCheckout();
} else {
global $pmpro_level;
}
// Get level cost.
$level_cost = pmpro_getLevelCost( $pmpro_level, false, true );
// Display level cost.
if ( ! empty( $level_cost ) ) {
echo '<strong>Total Price:</strong> ' . esc_html( $level_cost );
}
}
add_action( 'pmpro_checkout_before_submit_button', 'my_pmpro_price_before_submit' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment