I have added a custom checkout field to my WooCommerce web site. I have added and enabled Stripe plugin, as payment gateway… Is there a way to have this custom fields value sent as data to Stripe payment gateway?
I have searched everywhere but couldn’t find anything.
You can use wc_stripe_payment_metadata
dedicated filter hook to add (pass) some custom meta data to Stripe gateway, this way:
add_filter( 'wc_stripe_payment_metadata', 'stripe_payment_metadata_filter_callback', 10, 3 );
function stripe_payment_metadata_filter_callback( $metadata, $order, $prepared_source ) {
// Here below define your custom field meta key (as it's saved in wp_postmeta DB table)
$metadata="custom_meta_key";
$metadata[ __( 'Custom Label Text (or meta key)', 'woocommerce-gateway-stripe' ) ] = $order->get_meta($meta_key);
return $metadata;
}
Code goes in functions.php file of your active child theme (or active theme). It should work.
Related threads:
- WooCommerce Stripe official documentation – Filter Hooks section
- WooCommerce Stripe: Add Custom MetaData (April 2018)
- Send Variation options to stripe as metadata with WooCommerce (May 2018)