• Resolved Adumdurb

    (@adumdurb)


    I’m trying to call the Delivery Date from within my child template for ‘Woocommerce PDF Invoices”.

    Here is the section I wish to add the Delivery Date to:

    <table>
    				<?php do_action( 'wpo_wcpdf_before_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); ?>
    				<?php if ( isset($wpo_wcpdf->settings->template_settings['display_number']) && $wpo_wcpdf->settings->template_settings['display_number'] == 'invoice_number') { ?>
    				<tr class="invoice-number">
    					<th><?php _e( 'Invoice Number:', 'wpo_wcpdf' ); ?></th>
    					<td><?php $wpo_wcpdf->invoice_number(); ?></td>
    				</tr>
    				<?php } ?>
    				<?php if ( isset($wpo_wcpdf->settings->template_settings['display_date']) && $wpo_wcpdf->settings->template_settings['display_date'] == 'invoice_date') { ?>
    				<tr class="invoice-date">
    					<th><?php _e( 'Invoice Date:', 'wpo_wcpdf' ); ?></th>
    					<td><?php $wpo_wcpdf->invoice_date(); ?></td>
    				</tr>
    				<?php } ?>
    				<tr class="order-number">
    					<th><?php _e( 'Order Number:', 'wpo_wcpdf' ); ?></th>
    					<td><?php $wpo_wcpdf->order_number(); ?></td>
    				</tr>
    				<tr class="order-date">
    					<th><?php _e( 'Order Date:', 'wpo_wcpdf' ); ?></th>
    					<td><?php $wpo_wcpdf->order_date(); ?></td>
    				</tr>
    				<tr class="payment-method">
    					<th><?php _e( 'Payment Method:', 'wpo_wcpdf' ); ?></th>
    					<td><?php $wpo_wcpdf->payment_method(); ?></td>
    				</tr>
    				<?php do_action( 'wpo_wcpdf_after_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); ?>
    			</table>

    How should Delivery Date best be referenced?

    Thanks.

    https://wordpress.org/plugins/order-delivery-date-for-woocommerce/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Adumdurb,

    You can add the Delivery Date field to ‘WooCommerce PDF Invoices’ plugin by adding the below code in functions.php of your active child template:

    add_action( ‘wpo_wcpdf_after_order_details’, ‘orddd_lite_plugins_packing_slip’ );
    function orddd_lite_plugins_packing_slip() {
    global $wpo_wcpdf;
    $order_export = $wpo_wcpdf->export;
    $order_obj = $order_export->order;
    $order_id = $order_obj->id;
    $my_order_meta = get_post_custom( $order_id );
    if( array_key_exists( ‘Delivery Date’, $my_order_meta ) ) {
    $order_page_delivery_date = $my_order_meta[‘Delivery Date’];
    if ( $order_page_delivery_date != “” ) {
    echo ‘<p>‘.__( ( ‘Delivery Date’ ), ‘order-delivery-date’ ).’: ‘ . $order_page_delivery_date[0] . ‘</p>’;
    }
    }
    }

    The above code will print the Delivery Date field at the end of the PDF Invoice. I am attaching screenshot for your reference: http://screencast.com/t/yCubePet4n .

    If you want to print the Delivery Date field at the top of the data table in the PDF Invoice like this: http://screencast.com/t/cN1bg3lo than you can use the other hook ‘wpo_wcpdf_before_order_details’ in place of ‘wpo_wcpdf_after_order_details’.

    Please let me know if you have any further query.

    Regards,
    Dhara Kothari.

    Thread Starter Adumdurb

    (@adumdurb)

    Thanks Dhara, this has worked perfectly.

    How could we also add the Delivery Time? The Delivery Time isn’t specified by the customer at checkout, but rather by us. Could we do it using a New custom field?? And then how might we add it to the invoice?

    I’d love to know your thoughts.

    Thanks again,
    Adam

    Hi Adam,

    Yes, you can add the Delivery Time by using a New custom field. Below code will help you to add Delivery Time field in your ‘WooCommerce PDF Invoices’ plugin.

    if ( array_key_exists( ‘Delivery Time’, $my_order_meta ) ) {
    $order_page_delivery_time = $my_order_meta[‘Delivery Time’];
    if ( $order_page_delivery_time != “” ) {
    echo ‘<p>‘.__( ( ‘Delivery Time’ ), ‘order-delivery-date’ ).’: ‘ . $order_page_delivery_time[0] . ‘</p>’;
    }
    }

    The above code will print the Delivery Date field at the end of the PDF Invoice. I am attaching screenshot for your reference: http://screencast.com/t/bxEWBHGV .

    Please note that the custom field name should match with the field name you give in the code. Here we have used ‘Delivery Time’ for both, Custom field and in the above example code.

    If you like your clients to choose Delivery Time by themselves on the checkout page, then we have feature called ‘Time Slot’ present in Time Slot tab in pro version of our plugin.

    You can try our Order Delivery Date Pro version on demo site. Here is a link of our demo site: http://demo.tychesoftwares.com/woocommercepro/wp-admin and this is the front end link: http://demo.tychesoftwares.com/woocommercepro/?page_id=5

    Please let me know if you have any further quires.

    Regards,
    Dhara Kothari.

    Thread Starter Adumdurb

    (@adumdurb)

    Hello again, and thank you for your help.

    I’ve added the code you’ve provided to the PDF template, but it renders the following message instead of the Custom Field:

    Warning: array_key_exists() expects parameter 2 to be array, null given in
    /var/sites/o/domain.com/public_html/wp-content/themes/humbleshopchild/woocommerce/pdf/Domain/invoice.php on line 77

    Please help??

    Hi Adam,

    The error which is coming on your website would come when the patch of code which we have provided yesterday is placed outside the orddd_lite_plugins_packing_slip function. You need to place the code inside this function.

    Below is the entire function including the ‘Delivery Date’ and ‘Delivery Time’ field fix for the PDF invoice. Please remove all yesterday’s code and replace with the below mentioned patch of code in the file.

    add_action( ‘wpo_wcpdf_after_order_details’, ‘orddd_lite_plugins_packing_slip’ );
    function orddd_lite_plugins_packing_slip() {
    global $wpo_wcpdf;
    $order_export = $wpo_wcpdf->export;
    $order_obj = $order_export->order;
    $order_id = $order_obj->id;
    $my_order_meta = get_post_custom( $order_id );
    if( array_key_exists( ‘Delivery Date’, $my_order_meta ) ) {
    $order_page_delivery_date = $my_order_meta[‘Delivery Date’];
    if ( $order_page_delivery_date != “” ) {
    echo ‘<p>’.__( ( ‘Delivery Date’ ), ‘order-delivery-date’ ).’: ‘ . $order_page_delivery_date[0] . ‘</p>’;
    }
    }
    if ( array_key_exists( ‘Delivery Time’, $my_order_meta ) ) {
    $order_page_delivery_time = $my_order_meta[‘Delivery Time’];
    if ( $order_page_delivery_time != “” ) {
    echo ‘<p>’.__( ( ‘Delivery Time’ ), ‘order-delivery-date’ ).’: ‘ . $order_page_delivery_time[0] . ‘</p>’;
    }
    }
    }

    Please let me know if you have any further queries.

    Regards,
    Dhara Kothari.

    Thread Starter Adumdurb

    (@adumdurb)

    Great!

    Thank you very much!!

    How Can I add billing phone number to pdf invoice

    Hi,

    The Billing phone number can be added to pdf invoice of ‘WooCommerce PDF Invoices & Packing Slips’ plugin by adding the following code in the orddd_lite_plugins_packing_slip function of the integration.php file at line number 33 which is present in the ‘order-delivery-date-for-woocommerce’ plugin folder.

    $data = get_post_meta( $order_id );
    $phone_number = $data[‘_billing_phone’][0];
    echo ‘<p>Phone:‘ . $phone_number . ‘</p>’;

    Attaching screenshot for your reference: http://screencast.com/t/DL80ooPto , http://screencast.com/t/0yawcuwrRtL

    The line number is according to the latest version which is 2.1.

    Please let me know whether the provided solution helped you to achieve your requirement.

    Regards,
    Komal Maru.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add Delivery Date to Woocommerce PDF Invoice’ is closed to new replies.