• 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 Contributor 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!

    Thread Starter Saikoh

    (@saikoh)

    Hi Ewout,

    Thanks a bunch! I will try this our ??

    Have a great day.

    Thread Starter Saikoh

    (@saikoh)

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

    Plugin Contributor Ewout

    (@pomegranate)

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

    Happy selling and have a fantastic day!

    northbase

    (@northbase)

    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 Contributor 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 6 years 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 Contributor 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 Contributor 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 5 years, 8 months ago by ajaycoolk.
    Plugin Contributor 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.