skip to Main Content

Im trying to add the Delivery Date from the YITH Delivery Date plugin to display on a custom invoice template.

In my woocommercepdfCustomtemplate-functions.php I added the following action as per the documentation https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/creating-a-custom-pdf-template/:

<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
add_action( ‘wpo_wcpdf_after_order_data’, ‘wpo_wcpdf_delivery_date’, 10, 2); 
    function wpo_wcpdf_delivery_date($template_type, $order) { 
    $document = wcpdf_get_document($template_type, $order);
    print_r($document);
?>
<tr class=”delivery-date”>
    <th>Delivery Date:</th>
    <td><?php echo date_i18n( 'd M Y', strtotime( $document->get_custom_field('ywcdd_order_delivery_date') ) ); ?></td>
</tr>
<?php
}
?>

On the invoice.php I am calling the action/hook like this:

<?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>

The result, nothing is appearing on the invoice PDF to do with the delivery date, would anyone know what’s going on?

Also this article is exactly what I’m trying to achieve https://wordpress.org/support/topic/urgent-delivery-date-on-invoice-help-please/

(WooCommerce Version 4.5.1 | WordPress Version 5.4.4)

2

Answers


  1. Chosen as BEST ANSWER

    If anyone is having the same issue instead of <?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?> use <?php echo ywcdd_get_delivery_info( $order ); ?>


  2. add_action( 'wc_pip_after_customer_addresses', 'action_after_customer_addresses', 10, 4 );
    function action_after_customer_addresses( $type, $action, $document, $order ) {
       $document = wcpdf_get_document($type, $order);
        if(  $document )
            ?>
    <tr class=”delivery-date”>
        <th>Delivery Date:</th>
        <td><?php echo date( 'd M Y', strtotime( $document->get_custom_field('ywcdd_order_delivery_date') ) ); ?></td>
    </tr>
    <?php
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search