• Resolved devworlds

    (@devworlds)


    Hi,

    I want to show one order meta array name.

    order meta key name is– payment_data

    payment_data array like this– a:18:{s:10:”product_id”;i:1467;s:11:”product_qty”;i:1;s:16:”activate_payment”;s:4:”auto”;s:22:”charge_shipping_during”;s:15:”initial-payment”;s:12:”down_payment”;d:0;s:10:”base_price”;N;s:17:”next_payment_date”;s:19:”2024-05-01 00:00:00″;s:23:”next_installment_amount”;d:75.01500000000001;s:20:”total_payable_amount”;d:450.09000000000003;}

    I want to show next_payment_date how can i show it?

    thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor dwpriv

    (@dwpriv)

    Where are you trying to display the payment data? Can you share your full code snippet, please?

    Thread Starter devworlds

    (@devworlds)

    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 }
    }

    Thread Starter devworlds

    (@devworlds)

    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 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 }
    }
    Thread Starter devworlds

    (@devworlds)

    Hi,

    Still it coming white.

    thank you

    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 }
    }

    Thread Starter devworlds

    (@devworlds)

    Thanks

    • This reply was modified 10 months, 2 weeks ago by devworlds.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Meta_key Array value’ is closed to new replies.