Forked from dparker1005/my_pmpro_stripe_checkout_session_parameters_subscription_description.php
Last active
February 5, 2025 13:14
-
-
Save JarrydLong/c9678a468ba2a0b99b56eb082025d1ee to your computer and use it in GitHub Desktop.
Updates the payment description in Stripe when purchasing a subscription using Stripe Checkout.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) { | |
$user = get_userdata( $morder->user_id ); | |
$email = empty( $user->user_email ) ? '' : $user->user_email; | |
$description = "Order #" . $morder->code . ", " . trim( $morder->billing->name ) . " (" . $email . ") - ".$morder->membership_level->name; | |
if ( $checkout_session_params['mode'] === 'subscription' ) { | |
$checkout_session_params['subscription_data']['description'] = $description; | |
} else { | |
$checkout_session_params['payment_intent_data']['description'] = $description; | |
} | |
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