Last active
October 12, 2021 08:55
-
-
Save creativeartbd/cee015adc1ca2838ee644e12ab83f9d7 to your computer and use it in GitHub Desktop.
WP Crowdfunding - Change stripe payment description text
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
<?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