Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Delivery date on packing slip

  • Resolved Saikoh

    (@saikoh)


    Hi guys,

    First of all: love your plugin! Very nice!

    I am also using the YITh delivery date plugin, where customers can select their delivery date. I want to show this date on the packaging slip. Is this possible?

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Ewout

    (@pomegranate)

    Thanks for the compliments! Yes, you should be able to get the delivery date on the invoice. This is probably stored as a custom field, more information about getting custom fields is in our documentation: Displaying a custom field.
    If you’re not sure of the field name for this custom field, check out this guide: Finding WooCommerce Custom Fields

    It’s possible that the YITH plugin stores it as a ‘timestamp’, which means that you may need to convert it to a human readable format before displaying, and it’s also possible that the developers have added some shorthand functions that you can use to display the date in the correct format, so I do recommend to contact YITH with this question too. If you refer them to the above link, they should certainly be able to help.

    Good luck & happy selling!

    Hi Ewout,

    Thanks a bunch! I will try this our 😉

    Have a great day.

    Awesome, added the extra field in the functions.php file and works like a charm. 10/10 for you!

    Plugin Author Ewout

    (@pomegranate)

    Thanks! If you can spare a minute, I’d really appreciate a review here: https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/#new-post

    Happy selling and have a fantastic day!

    Hello Guys,

    I’m also using the YITh delivery date plugin and also want to add the delivery date to the invoice. I tried to add the following code to my template-functions.php:

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_delivery_date', 10, 2 );
    function wpo_wcpdf_delivery_date ($template_type, $order) {
        if ($template_type == 'packing-slip') {
            $document = wcpdf_get_document( $template_type, $order );
            ?>
             
    <tr class="delivery-date">
                 
    <th>Delivery Date:</th>
     
                 
    <td><?php $document->custom_field('ywcdd_order_delivery_date'); ?></td>
     
            </tr>
     
            <?php
        }
    }

    However the delivery date is not being added with the invoice. Can you guys help me?

    Thanks!

    Plugin Support kluver

    (@kluver)

    Hi @northbase,

    You wrapped the whole function in an if statement that checks if the template type is ‘packing slip’.

    Turn

    if ($template_type == 'packing-slip') {

    into

    if ($template_type == 'invoice') {

    and you should be good to go!

    • This reply was modified 1 year, 1 month ago by kluver.
    northbase

    (@northbase)

    Hi @kluver,

    Thanks for the reply.

    I changed the code but it’s not working yet…
    Do i also need to add some code in de invoice.php file?

    Thanks!

    Plugin Author Ewout

    (@pomegranate)

    No, you shouldn’t need to change anything in invoice.php. Perhaps try Code Snippets instead of template-functions.php (to make sure it’s applied correctly), that also makes your changes independent of plugin/template updates (so you can switch back to the Simple template again).
    Here’s an example without the document check altogether:

    
    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 );
        ?>      
        <tr class="delivery-date">
            <th>Delivery Date:</th>
            <td><?php $document->custom_field('ywcdd_order_delivery_date'); ?></td>
        </tr>
        <?php
    }
    
    northbase

    (@northbase)

    Thanks Ewout it’s working!
    Only the date format is not correct. now it is 2018-11-17 but it needs to be 17-11-2018.
    Is this possible?

    Thanks

    Plugin Author Ewout

    (@pomegranate)

    Yes, that’s possible. Change this line:

    
    <td><?php $document->custom_field('ywcdd_order_delivery_date'); ?></td>
    

    to:

    
    <td><?php echo date_i18n( 'd-m-Y', $document->get_custom_field('ywcdd_order_delivery_date') ); ?></td>
    

    Hello,

    I have the same problem, I have used following code and it’s resolved:

    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 );
    ?>
    <tr class=”delivery-date”>
    <th>Delivery Date:</th>
    <td><?php echo date_i18n( ‘d-m-Y’, $document->get_custom_field(‘ywcdd_order_delivery_date’) ); ?></td>
    </tr>
    <?php
    }

    But now, I am getting following error:
    Notice: A non well formed numeric value
    encountered in
    /home/crudoco/public_html/crudokitchencom/wpincludes/functions.php on line 114
    Notice: A non well formed numeric value
    encountered in
    /home/crudoco/public_html/crudokitchencom/wpincludes/functions.php on line 116
    Notice: A non well formed numeric value
    encountered in
    /home/crudoco/public_html/crudokitchencom/wpincludes/functions.php on line 118
    Notice: A non well formed numeric value
    encountered in
    /home/crudoco/public_html/crudokitchencom/wpincludes/functions.php on line 119

    Would you please help me?

    Thanks!
    Ajay

    • This reply was modified 8 months, 1 week ago by ajaycoolk.
    Plugin Author Ewout

    (@pomegranate)

    I see that you also opened your own thread, I’ll answer this in there 🙂

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Delivery date on packing slip’ is closed to new replies.