Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created January 11, 2020 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/7835142b09f8a8a3502b70f9c36ac3b5 to your computer and use it in GitHub Desktop.
Save joshfeck/7835142b09f8a8a3502b70f9c36ac3b5 to your computer and use it in GitHub Desktop.
Custom Stripe Elements description field
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__EEG_Stripe_Onsite__doDirectPaymentWithPaymentIntents__payment_intent_data',
'stripe_elements_cf_order_desc', 10, 4
);
function stripe_elements_cf_order_desc(
$stripe_data,
$payment,
$transaction,
$billing_info
) {
if ($transaction instanceof EEI_Transaction) {
$primary_registrant = $transaction->primary_registration();
if ($primary_registrant instanceof EE_Registration) {
$event = $primary_registrant->event_obj();
if ($event instanceof EEI_Event) {
$desc = $event->name();
$desc .= ' | cost code: ' . get_post_meta($event->id(), 'cost_code', true);
$stripe_data['description'] = $desc;
}
}
}
return $stripe_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment