Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dwanjuki/de5356fd28ee9775bc0c0409063726fb to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/de5356fd28ee9775bc0c0409063726fb to your computer and use it in GitHub Desktop.
Change/Tranlate text strings for some level checkout pages
<?php
/**
* Change/Tranlate text strings for some level checkout pages
*
* 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_run_gettext_on_specific_level_checkout_pages() {
$levels_to_translate = array( 1, 2, 3, 7 );
$pmpro_level = pmpro_getLevelAtCheckout();
if ( in_array( $pmpro_level->id, $levels_to_translate ) ) {
add_filter( 'gettext', 'my_pmpro_gettext_filter_specific_level_checkout_pages', 10, 3 );
}
}
add_action( 'pmpro_checkout_preheader', 'my_pmpro_run_gettext_on_specific_level_checkout_pages' );
function my_pmpro_gettext_filter_specific_level_checkout_pages( $translated, $text, $domain ) {
switch ( $domain ) {
case 'paid-memberships-pro':
switch ( $text ) {
case 'You have selected the %s membership level.':
$translated = 'Ha seleccionado el nivel de membresía %s.';
break;
}
break;
}
return $translated;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment