• Resolved ajaycoolk

    (@ajaycoolk)


    Hello,

    I have used YITH Delivery date plugin to capture delivery dates. I want to show this on invoices & packing slips. I have used following code:

    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

    I am using PHP 7.2

    Would you please help me?

    Thanks!
    Ajay

    • This topic was modified 5 years, 8 months ago by ajaycoolk.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    It looks like the YITH plugin stores the date as a timestamp string, but date_18n() only accepts an integer as timestamp.
    try this instead:

    
    <?php echo date_i18n( 'd-m-Y', intval( $document->get_custom_field('ywcdd_order_delivery_date') ) ); ?>
    
    Thread Starter ajaycoolk

    (@ajaycoolk)

    @pomegranate Thank you so much for prompt reply. I can see the date format is changed perfectly. However, now it’s not taking the actual delivery date, instead, it is showing as 01-01-1970. Would you please suggest what should I do now?

    Thank you in advance.

    Plugin Contributor Ewout

    (@pomegranate)

    I’m afraid that’s something you will need to ask YITH support, as I don’t know exactly how this data is stored. If it’s showing 01-01-1970 it means it’s not reading any value (0 = the beginning of computer dates = 1970).

    Thread Starter ajaycoolk

    (@ajaycoolk)

    But if I following line it is showing the exact date:
    <td><?php $document->custom_field(‘ywcdd_order_delivery_date’); ?></td>

    It’s giving error only when I use –
    <td><?php echo date_i18n( ‘d M Y’, $document->get_custom_field(‘ywcdd_order_delivery_date’) ); ?></td>

    Does this mean it is not supporting the date format code?

    Plugin Contributor Ewout

    (@pomegranate)

    I think it means that YITH doesn’t store this as a time stamp but as a formatted date. Try this instead:

    
    <?php echo date_i18n( 'd M Y', strtotime( $document->get_custom_field('ywcdd_order_delivery_date') ) ); ?>
    
    Thread Starter ajaycoolk

    (@ajaycoolk)

    Awesome….and that works!!!!
    Thank you so much for prompt help ??

    Plugin Contributor Ewout

    (@pomegranate)

    Very glad to hear that, @ajaycoolk! If you can spare a minute we always appreciate a review here on www.ads-software.com: https://www.ads-software.com/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/#new-post

    Thanks in advance and happy selling!
    Ewout

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Urgent** Delivery date on Invoice – help please’ is closed to new replies.