How to extract dates
-
Hi,
I’d like to extract the booking dates because I need it in my invoice.php (made with WooCommerce PDF Invoices & Packing Slips).I’d like to add this type of information :
Delivery date = “booking start_date”Thanks
-
Already tried to open a booking_session in invoice.php but I have an Internal server error when I submit my order
Hello,
Please have a look at the right support forum: http://herownsweetcode.com/easy-booking/topic/get-the-start-and-end-date-for-export/.
Regards,
NatashaOK, it does not work for me, this is my code included in invoice.php :
<?PHP $order = new WC_Order( $order_id );
$items = $order->get_items();if ( $items ) foreach ( $items as $item_id => $item ) {
}?>
<th><?php _e( ‘Date de livraison:’, ‘wpo_wcpdf’ ); ?></th>
<td><?PHP wc_get_order_item_meta( $item_id, ‘_ebs_start_display’, true ); ?>It remains blank on my PDF
-
This reply was modified 9 years, 4 months ago by
maxdass.
Well yes, you’re outside the foreach loop… Try this:
<?php $order = wc_get_order( $order_id ); $items = $order->get_items(); if ( $items ) foreach ( $items as $item_id => $item ) { echo '<th>' . __( 'Date de livraison:', 'wpo_wcpdf' ) . '</th>'; echo '<td>' . wc_get_order_item_meta( $item_id, '_ebs_start_display', true ) . '</td>'; } ?>-
This reply was modified 9 years, 4 months ago by
Ashanna.
Hi thanks but it does not work, I have an “internal server error” when I add this code.
But I’ve tried and the order item meta (including booking dates) are already displayed by the plugin in the generated invoices, why would you want to add them again?
Without the whole code, I can’t help more sorry.
Yes I see that they are already displayed.
I need to add a line outside the table with the delivery date.
And the delivery date is the same as the start_date (booking date).It has to appear in my invoices like this :
CLIENT NAME
BOOKING N°XX
DELIVERY DATEINVOICE TABLE
Many thanks for your help
Ok, I see…
It depends where exactly you want to put this on the invoice, there are multiple action hooks available.
You can try this:
add_action( 'wpo_wcpdf_after_order_data', 'display_booking_date_in_invoice', 10, 2 ); function display_booking_date_in_invoice( $template_type, $order ) { $items = $order->get_items(); if ( $items ) foreach ( $items as $item_id => $item ) { echo '<tr>'; echo '<th>' . __( 'Date de livraison:', 'wpo_wcpdf' ) . '</th>'; echo '<td>' . wc_get_order_item_meta( $item_id, '_ebs_start_display', true ) . '</td>'; echo '</tr>'; } }This will display what you need under the order information.
Please note that booking dates are stored per item, and not per order, which means that if you have several booked items in your order it will display several dates.
Edit: Don’t put the code directly in the invoice.php file but in your theme’s functions.php.
Yes it works !
Now the problem is that I have several dates as you said.
I just added break; and it works.
Even If there is 2 items in my order, my delivery date appears only once.Thanks a lot for your help
-
This reply was modified 9 years, 4 months ago by
The topic ‘How to extract dates’ is closed to new replies.