WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Print Invoice & Delivery Note
[resolved] [Plugin: WooCommerce Print Invoices & Delivery Notes] Custom Fields (8 posts)

  1. joeleade
    Member
    Posted 1 year ago #

    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,

    Joel

    http://wordpress.org/extend/plugins/woocommerce-delivery-notes/

  2. piffpaffpuff
    Member
    Plugin Author

    Posted 1 year ago #

    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; ?>
  3. joeleade
    Member
    Posted 1 year ago #

    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.

    Cheers!

  4. ashokrane
    Member
    Posted 1 year ago #

    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?

  5. piffpaffpuff
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. Amit
    Member
    Posted 1 year ago #

    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];
    Cheers.

  7. Mjolnir_68
    Member
    Posted 1 year ago #

    Hi,

    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?

  8. johno69
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic