Skip to content

Instantly share code, notes, and snippets.

@LaxusCroco
Last active December 18, 2024 22:34
Show Gist options
  • Save LaxusCroco/e64d1fc2c61666573c35fee6f9bc1de5 to your computer and use it in GitHub Desktop.
Save LaxusCroco/e64d1fc2c61666573c35fee6f9bc1de5 to your computer and use it in GitHub Desktop.
This code sets the payment name to the value of the Text form field
<?php
add_action(
'jet-form-builder/gateways/before-create',
function ( $request ) {
if (
// execute this action only when paying through Stripe
! is_a(
$request,
\Jet_FB_Stripe_Gateway\Compatibility\Jet_Form_Builder\Actions\Create_Checkout_Session::class
) ||
// You must have JetFormBuilder >= 3.1
! function_exists( 'jet_fb_context' )
) {
return;
}
// where 'text_field_name' - form field name
$value = jet_fb_context()->get_value( 'text_field_name' );
$request->set_payment_name( \Jet_Form_Builder\Classes\Tools::to_string( $value ) );
}
);
@moxet
Copy link

moxet commented Jul 13, 2024

Thank you Laxus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment