Ok, here is the code that I came up with and this seems to work. I do wonder though, the payment amount is just the order total. I do not see a way to get the actual payment amount, isn’t it possible a customers payment is different than the payment amount. If anyone has any ideas maybe they can share. But this code is works. I also am setting the time zone of the date paid so I can easily see that, you can change it to what you want.
function payment_info_custom_order_fields( $fields, $order ) {
$new_fields = array();
// Add the Transaction ID field
$new_fields['_transaction_id'] = array(
'label' => 'Transaction ID:',
'value' => $order->get_transaction_id(),
);
// Add the Date Paid field with the desired format 'Month day, year'
$date_paid = $order->get_date_paid();
if ( $date_paid ) {
// Convert the date to Eastern Time (ET)
$date_paid_object = new DateTime( $date_paid, new DateTimeZone( 'UTC' ) );
$date_paid_object->setTimezone( new DateTimeZone( 'America/New_York' ) );
$date_paid_formatted = $date_paid_object->format( 'F j, Y' );
} else {
$date_paid_formatted = '';
}
$new_fields['_date_paid'] = array(
'label' => 'Date Paid:',
'value' => $date_paid_formatted,
);
// Add the Payment Amount field
$new_fields['_payment_amount'] = array(
'label' => 'Payment Amount:',
'value' => wc_price( $order->get_total() ), // Get the order total as payment amount and format it as a price.
);
return array_merge( $fields, $new_fields );
}
add_filter( 'wcdn_order_info_fields', 'payment_info_custom_order_fields', 10, 2 );
-
This reply was modified 1 year, 4 months ago by radial.
-
This reply was modified 1 year, 4 months ago by radial.