Plugin Contributor
dwpriv
(@dwpriv)
Where are you trying to display the payment data? Can you share your full code snippet, please?
Hi,
I’m trying to display on invoice.
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_my_custom_field', 10, 2 );
function wpo_wcpdf_my_custom_field ($document_type, $order) {
if ( $document_type == 'invoice' ) {
?>
<tr class="due-date">
<th>Due Date:</th>
<td><?php
$payment_data = $order->get_meta('_pp_payment_data', true);
// Here i want to Show from array filed name next_payment_date
?>
</td></tr>
<?php }}?>
Plugin Contributor
dwpriv
(@dwpriv)
Thanks for the information
Try this snippet
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_my_custom_field', 10, 2 );
function wpo_wcpdf_my_custom_field ($document_type, $order) {
if ( $document_type == 'invoice' ) {
?>
<tr class="due-date">
<th>Due Date:</th>
<td>
<?php
$payment_data = $order->get_meta('_pp_payment_data', true);
if ( ! empty( $payment_data ) ) {
foreach( $payment_data as $id => $data ) {
if ( $data == 'next_payment_date' ) {
echo $data;
}
}
}
?>
</td>
</tr>
<?php }
}
Hi,
Sorry for late reply.
The code is not working.
Can can you please help me to show this date correctly.
The plugin deleveloper sayed this– It stores under post meta_key named “_next_payment_date” and “_actual_payments_date”.
thank you
-
This reply was modified 1 year, 11 months ago by
devworlds.
Plugin Contributor
dwpriv
(@dwpriv)
@devworlds try replacing the snippet with this one
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_my_custom_field', 10, 2 );
function wpo_wcpdf_my_custom_field ($document_type, $order) {
if ( $document_type == 'invoice' ) {
?>
<tr class="due-date">
<th>Due Date:</th>
<td>
<?php
$payment_data = $order->get_meta('_pp_payment_data', true);
if ( ! empty( $payment_data ) ) {
foreach( $payment_data as $id => $data ) {
if ( $data == '_next_payment_date' ) {
echo $data;
}
}
}
?>
</td>
</tr>
<?php }
}
Plugin Contributor
dwpriv
(@dwpriv)
@devworlds my apologies for the late response! I thought I had replied to this before.
Is the meta data located in the items post data or the order post data? You can try this edit
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_my_custom_field', 10, 2 );
function wpo_wcpdf_my_custom_field ($document_type, $order) {
if ( $document_type == 'invoice' ) {
?>
<tr class="due-date">
<th>Due Date:</th>
<td>
<?php
$payment_data = $order->get_meta('_pp_payment_data', true);
if ( ! empty( $payment_data ) && ! empty( $order->get_meta( '_next_payment_date' ) ) ) {
echo $order->get_meta( '_next_payment_date' );
}
?>
</td>
</tr>
<?php }
}