Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dparker1005/9e69961ac7f70b2a3daf1afcd6cc7c14 to your computer and use it in GitHub Desktop.
Save dparker1005/9e69961ac7f70b2a3daf1afcd6cc7c14 to your computer and use it in GitHub Desktop.
Updates the payment description in Stripe when purchasing a subscription using Stripe Checkout.
<?php
/**
* 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.
*/
// Copy from below this line
/**
* Updates the payment description in Stripe when purchasing a subscription using Stripe Checkout.
*/
function my_pmpro_stripe_checkout_session_parameters_subscription_description( $checkout_session_params, $morder ) {
if ( $checkout_session_params['mode'] === 'subscription' ) {
$checkout_session_params['subscription_data']['description'] = $morder->membership_level->name;
} else {
$checkout_session_params['payment_intent_data']['description'] = $morder->membership_level->name;
}
return $checkout_session_params;
}
add_filter( 'pmpro_stripe_checkout_session_parameters', 'my_pmpro_stripe_checkout_session_parameters_subscription_description', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment