Skip to content

Instantly share code, notes, and snippets.

@creativeartbd
Last active October 12, 2021 08:55
Show Gist options
  • Save creativeartbd/cee015adc1ca2838ee644e12ab83f9d7 to your computer and use it in GitHub Desktop.
Save creativeartbd/cee015adc1ca2838ee644e12ab83f9d7 to your computer and use it in GitHub Desktop.
WP Crowdfunding - Change stripe payment description text
<?php
add_filter( 'wc_stripe_generate_payment_request', 'change_stripe_payment_description', 10, 2 );
function change_stripe_payment_description( $post_data, $order ) {
// Get the order number
$order = wc_get_order( $order->get_order_number() );
// Get the order iterms
$items = $order->get_items();
// Check if it's crowdfunding produ ct
$is_crowdfunding = get_post_meta( $order->get_order_number(), 'is_crowdfunding_order', true );
// If it's crowdfunding product
if( $is_crowdfunding ) {
$product_name = '';
$customer_name = ucwords( $post_data['metadata']['customer_name'] );
foreach ( $items as $item ) {
$product_name .= $item->get_name();
}
// Change the description
$post_data['description'] = $product_name . ' | ' . $customer_name . ' | ' . 'Order ' . $order->get_order_number();
return $post_data;
}
return $post_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment