WooCommerce-将元数据添加到条纹付款中
我正在尝试使用此代码结帐后/结帐时将税收元数据添加到Stripe付款插件中:
/*
* Add "Billing Company" value to Stripe metadata
*/
function filter_wc_stripe_payment_metadata( $metadata, $order, $source ) {
$order_data = $order->get_data();
$order_discount_total = $order_data['discount_total'];
$order_discount_tax = $order_data['discount_tax'];
$order_shipping_total = $order_data['shipping_total'];
$order_shipping_tax = $order_data['shipping_tax'];
$order_total = $order_data['cart_tax'];
$order_total_tax = $order_data['total_tax'];
$metadata[ __( 'Discount Total', 'woocommerce-gateway-stripe' ) ] = $order_discount_total;
$metadata[ __( 'Discount Tax', 'woocommerce-gateway-stripe' ) ] = $order_discount_tax;
$metadata[ __( 'Shipping Total', 'woocommerce-gateway-stripe' ) ] = $order_shipping_total;
$metadata[ __( 'Shipping Tax', 'woocommerce-gateway-stripe' ) ] = $order_shipping_tax;
$metadata[ __( 'Cart Tax', 'woocommerce-gateway-stripe' ) ] = $order_total;
$metadata[ __( 'Total Tax', 'woocommerce-gateway-stripe' ) ] = $order_total_tax;
return $metadata;
}
add_filter( 'wc_stripe_payment_metadata', 'filter_wc_stripe_payment_metadata', 10, 3 );
使用条纹测试模式,此元数据不会出现在元列表中。
从传递到条纹的API重点:
"invoice": null,
"livemode": false,
"metadata": {
"order_key": "wc_order_a7iTmZVNW52cz",
"site_url": "https://xxxx.shop",
"order_id": "2337",
"payment_type": "single",
"customer_email": "[email protected]",
"customer_name": "Customer Name"
},
"on_behalf_of": null,
"order": null,
我缺少什么?
functions.php更改甚至没有出现在WooCommerce中 - >状态 - >条纹日志。 它被正确添加到functions.php中,没有其他内容。谢谢
I'm trying to add tax metadata to the Stripe Payment Plugin after/during checkout with this code:
/*
* Add "Billing Company" value to Stripe metadata
*/
function filter_wc_stripe_payment_metadata( $metadata, $order, $source ) {
$order_data = $order->get_data();
$order_discount_total = $order_data['discount_total'];
$order_discount_tax = $order_data['discount_tax'];
$order_shipping_total = $order_data['shipping_total'];
$order_shipping_tax = $order_data['shipping_tax'];
$order_total = $order_data['cart_tax'];
$order_total_tax = $order_data['total_tax'];
$metadata[ __( 'Discount Total', 'woocommerce-gateway-stripe' ) ] = $order_discount_total;
$metadata[ __( 'Discount Tax', 'woocommerce-gateway-stripe' ) ] = $order_discount_tax;
$metadata[ __( 'Shipping Total', 'woocommerce-gateway-stripe' ) ] = $order_shipping_total;
$metadata[ __( 'Shipping Tax', 'woocommerce-gateway-stripe' ) ] = $order_shipping_tax;
$metadata[ __( 'Cart Tax', 'woocommerce-gateway-stripe' ) ] = $order_total;
$metadata[ __( 'Total Tax', 'woocommerce-gateway-stripe' ) ] = $order_total_tax;
return $metadata;
}
add_filter( 'wc_stripe_payment_metadata', 'filter_wc_stripe_payment_metadata', 10, 3 );
Using Stripe Test Mode, this meta data doesn't appear in the meta list.
From the API-Request that is passed to Stripe:
"invoice": null,
"livemode": false,
"metadata": {
"order_key": "wc_order_a7iTmZVNW52cz",
"site_url": "https://xxxx.shop",
"order_id": "2337",
"payment_type": "single",
"customer_email": "[email protected]",
"customer_name": "Customer Name"
},
"on_behalf_of": null,
"order": null,
What am I missing?
The functions.php change doesn't even appear in the Woocommerce -> Status -> Stripe Logs.
It's properly added into the functions.php, nothing else in it. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)