Created
November 8, 2024 12:49
-
-
Save xlplugins/57347d70c9f85bf12c680a4f8c23575b to your computer and use it in GitHub Desktop.
Payment Metadata stripe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fkwcs_filter_wc_stripe_payment_metadata($metadata, $order) | |
{ | |
/** | |
* Get order data | |
*/ | |
$order_data = $order->get_data(); | |
$metadata[__('Customer Name', 'funnelkit-stripe-woo-payment-gateway')] = sanitize_text_field($order_data['billing']['first_name'] . ' ' . $order_data['billing']['last_name']); | |
$metadata[__('Customer Phone', 'funnelkit-stripe-woo-payment-gateway')] = sanitize_text_field($order_data['billing']['phone']); | |
$metadata[__('Total Tax', 'funnelkit-stripe-woo-payment-gateway')] = sanitize_text_field($order_data['total_tax']); | |
/** | |
* List products purchased | |
*/ | |
$count = 1; | |
foreach ($order->get_items() as $item_id => $line_item) { | |
$item_data = $line_item->get_data(); | |
$product = $line_item->get_product(); | |
$product_name = $product->get_name(); | |
$product_sku = $product->get_sku(); | |
$item_quantity = $line_item->get_quantity(); | |
$item_total = $line_item->get_total(); | |
$metadata['Line Item ' . $count] = 'Product name: ' . $product_name . ' | SKU: ' . $product_sku . ' | Quantity: ' . $item_quantity . ' | Item total: ' . number_format($item_total, 2); | |
$count += 1; | |
} | |
return $metadata; | |
} | |
add_filter('fkwcs_payment_metadata', 'fkwcs_filter_wc_stripe_payment_metadata', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment