Support » Plugin: WooCommerce Print Invoice & Delivery Notes » [Plugin: WooCommerce Print Invoices & Delivery Notes] Custom Fields

  • Resolved joeleade


    Hi Guys,

    Great plugin! Hopefully this isn’t too difficult a question.

    I’m using custom fields to capture additional shipping information for a client, which ideally will appear on the invoice and delivery docket.

    Do you know if it’s possible to include custom/meta fields, and if so, can you point me in the right direction please?

    I’ve been able to get so far as adding the below code to “print.php”
    <h3><?php _e( 'Leave Safe Spot', 'woocommerce-delivery-notes' ); ?></h3><?php echo wcdn_shipping_leave_safe_spot(); ?>

    and this code to “woocommerce-delivery-notes-print.php”
    * Return shipping leave safe spot
    * @since 1.0
    * @global $wcdn->print
    * @return string shipping leave safe spot
    if ( ! function_exists( 'wcdn_shipping_leave_safe_spot' ) ) {
    function wcdn_shipping_leave_safe_spot() {
    global $wcdn;
    return $wcdn->print->get_order()->order_custom_fields['Leave Safe Spot'];

    but all that appears under the heading “Leave Safe Spot” in both the invoice and delivery note is “Array”.

    I am a novice at PHP so apologies if this is an obvious error.

    Thanks in advance,


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


    this is more of a woocommerce question because $wcdn->print->get_order()just returns the order instance that was created by woocommerce. maybe your custom fields aren’t saved as desired, or you are actually saving an array? i don’t know, but your code is right.

    <?php $wcdn->print->get_order()->order_custom_fields; ?>

    Thanks Chabis. At least I know that one part of it’s correct. I’ll look into what’s going on with my custom field then post my findings.


    Plugin Author Vishal Kothari


    Is there a way that I can add custom fields by using some hooks from another plugin?
    For example, I have a Order Delivery Date plugin. One of my clients wants that the Delivery Date should be visible on the Invoice & packing list.

    I did manage to show the field by adding the above code for the field. But I was wondering if there is a better way like using a hook to add custom field so I can prevent changing the plugin code?

    Plugin Contributor piffpaffpuff


    no there aren’t any hooks but it’s a nice input. i’ve added it to the feature wishes.

    but besides that you can overwrite any template function with your own. for the list of functions look at woocommerce-delivery-notes.php starting at line 160. every function with function_exists can be overwritten in your functions.php.

    Hi their solved problem for me,
    I am also looking for the same. And I am gone through your code and it also shows me Array.
    So what I have done that used,
    return $wcdn->print->get_order()->order_custom_fields[‘Leave Safe Spot’][0];




    I’m trying to do the same thing, but also struggling with my edits. I’d like the delivery notes to include a custom field that I’ve called “afhentning_dag”.

    I’ve added to /wp-content/plugins/woocommerce-delivery-notes/woocommerce-delivery-notes.php the following:

    * Show custom field for pickup-time.
    if ( !function_exists( ‘wcdn_get_order_afhentning_dag’ ) ) {
    function wcdn_afhentning_dag() {
    global $wcdn;
    echo $wcdn->print->get_order()->afhentning_dag;

    I’ve added to /wp-content/themes/MyTheme/woocommerce/print/print-delivery-note.php:

    <h3><?php echo wcdn_get_order_custom_field(‘afhentning_dag’);?></h3>

    Nothing apears in the print – any suggestions as to where I’m getting this wrong?



    How can we add the product ID and payment method to the delivery note?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: WooCommerce Print Invoices & Delivery Notes] Custom Fields’ is closed to new replies.