Send Product Data To Stripe

There might be times when you want more than just the basic order information sent to Stripe. The following code snippet provided by one of our users Alex will send the product data. 

//add order details to Stripe payment metadata
function filter_wcv_sc_payment_metadata( $metadata, $order, $source ) {
$order_data = $order->get_data();
$metadata['Total Tax Charged'] = $order_data['total_tax'];
$metadata['Total Shipping Charged'] = $order_data['shipping_total'];
$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();
$item_quantity = $line_item->get_quantity();
$item_total = $line_item->get_total();
$metadata['Line Item '.$count] = 'Product name: '.$product_name.' | Quantity: '.$item_quantity.' | Item total: '. number_format( $item_total, 2 );
$count += 1;
}
return $metadata;
}
add_filter( 'wcv_sc_payment_metadata', 'filter_wcv_sc_payment_metadata', 10, 3 );

Need help?

If you have a question or run into any issues, we’re here to help.

Was this article helpful?

Related Articles

Contents

Need Support?

Can't find the answer you're looking for?
Contact Support
Complete Your Purchase