admin管理员组文章数量:1414614
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.
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.
Share Improve this question edited Sep 2, 2019 at 17:43 LoicTheAztec 3,39117 silver badges24 bronze badges asked Sep 2, 2019 at 9:30 ShadowShadow 571 silver badge7 bronze badges 1- This is probably best answered by looking through the woocommerce Stripe plugin, if you can do that yourself, for the point where it assembles the data sent to Stripe to see if there are any obvious hooks you can use. If not, you can always fork the plugin and add the extra function to your own private copy. – Rup Commented Sep 2, 2019 at 9:36
1 Answer
Reset to default 5You 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)
本文标签: Pass custom Checkout field value to Stripe gateway in WooCommerce
版权声明:本文标题:Pass custom Checkout field value to Stripe gateway in WooCommerce 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745192050a2646955.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论