Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Adding a data from other plugin

  • I want to add two data from the plugin I am using to the PDF Invoice, the plugin is Checkout Field Editor for WooCommerce which I added viber no. and mobile no.

    Names:

    billing_phone
    billing_viber

    I am not into codes so please help me! Any help would be much appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @ahranalytics

    The easy way is using our Premium Templates extension by adding those custom field names to a custom block.

    Alternatively you can also display those using a code snippet. Please read this documentation page: How to display a custom field

    Thread Starter ahranalytics

    (@ahranalytics)

    @alexmigf

    I am always keen to buy the premiumship but I want to analyze first if this plugin really helps me in terms of technicalities before buying it.

    Thank you though for sending the link for customization, however none of the code is working for me. See my code below:

    add_action( ‘wpo_wcpdf_after_order_data’, ‘wpo_wcpdf_billing_viber’, 10, 2 );
    function wpo_wcpdf_billing_viber ($template_type, $order) {
    if ($template_type == ‘packing-slip’) {
    $document = wcpdf_get_document( $template_type, $order );
    ?>
    <tr class=”billing_viber”>
    <th>Viber:</th>
    <td><?php $document->custom_field(‘billing_viber’); ?></td>
    </tr>
    <?php
    }
    }

    I am trying to put the billing_viber data to the PDF invoice.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @ahranalytics

    Try this instead:

    add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
    	if ( ! empty($order) && $document_type == 'packing-slip' ) {
    		?>
    		<tr class="billing_viber">
    			<th>Viber:</th>
    			<td><?= $order->get_meta('billing_viber'); ?></td>
    		</tr>
    		<?php
    	}
    }, 10, 2 );

    If you never worked with actions/filters, please read this documentation page: How to use filters

    Thread Starter ahranalytics

    (@ahranalytics)

    Hi @alexmigf

    Thanks! Not what I want but I found a way transferring the data to PDF Invoice not in the packing slips.

    Last one before I mark this as resolved, I want to add a phone number as well but it is not working and the phone number I input didnt reflected on the PDF Invoice, see my code:

    
    //Viber
    add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
    	if ( ! empty($order) && $document_type == 'invoice' ) {
    		?>
    		<tr class="billing_viber">
    			<th>Viber:</th>
    			<td><?= $order->get_meta('billing_viber'); ?></td>
    		</tr>
    		<?php
    	}
    }, 10, 2 );
    
    //Phone 
    add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
    	if ( ! empty($order) && $document_type == 'invoice' ) {
    		?>
    		<tr class="billing_phone">
    			<th>Contact no:</th>
    			<td><?= $order->get_meta('billing_phone'); ?></td>
    		</tr>
    		<?php
    	}
    }, 10, 2 );
    
    

    Screenshot:https://imgur.com/TFnare0

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @ahranalytics

    I set it to ‘packing-slip’ because your example here had it.

    I believe the phone meta key is: _billing_phone

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding a data from other plugin’ is closed to new replies.