Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save femiyb/38f943d6630a343c455b9dbdd730048a to your computer and use it in GitHub Desktop.
Save femiyb/38f943d6630a343c455b9dbdd730048a to your computer and use it in GitHub Desktop.
PMPro - Change "Discount Code" Text Example on Checkout Page
<?php // Do Not Copy This Line
/**
* This recipe will help you change text on the checkout paid in PMPro
* 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/
*/
// paste content from below this line
function pmproc_change_my_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Do you have a discount code?':
$translated_text = __( 'Do you have a membership code?', 'pmpro' );
break;
case 'Click here to enter your discount code':
$translated_text = __( 'Click here to enter your membership code', 'pmpro' );
break;
case 'You have selected the <strong>%s</strong> membership level.':
$translated_text = __( '<strong>%s</strong> has been selected.', 'pmpro' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'pmproc_change_my_text', 20, 3 );
// Only change this text on the on the checkout page
function do_gettext_for_pmpro_checkout() {
global $pmpro_pages;
if ( ! is_page( $pmpro_pages['checkout'] ) ) {
return;
} else {
add_filter( 'gettext', 'pmproc_change_my_text', 20, 3 );
}
}
add_action( 'wp', 'do_gettext_for_pmpro_checkout' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment