• Resolved techtone

    (@techtoned)


    Hi,

    I tried roughly all the plugins that I could find to print invoice, delivery notes etc.

    But, even though the Organization Number is present in the order, it doesn’t show up when trying to print with these plugins.

    Just wanted to check if it is related to the checkout plugin, so I can try to get in touch with those plugins support.

    For example, I was using this plugin https://www.ads-software.com/plugins/woocommerce-delivery-notes/

    But now it doesn’t work.

    And this is what they have in the help section of the plugin:

    Use the wcdn_order_info_fields filter hook. It returns all the fields as array. Read the WooCommerce documentation to learn how you get custom checkout and order fields. Tip: To get custom meta field values you will most probably need the get_post_meta( $order->get_id(), 'your_meta_field_name', true); function and of course the your_meta_field_name.

    An example that adds a 'VAT' and 'Customer Number' field to the end of the list. Paste the code in the functions.php file of your theme:
    function example_custom_order_fields( $fields, $order ) {
    $new_fields = array();

    if( get_post_meta( $order->get_id(), 'your_meta_field_name', true ) ) {
    $new_fields['your_meta_field_name'] = array(
    'label' => 'VAT',
    'value' => get_post_meta( $order->get_id(), 'your_meta_field_name', true )
    );
    }

    if( get_post_meta( $order->get_id(), 'your_meta_field_name', true ) ) {
    $new_fields['your_meta_field_name'] = array(
    'label' => 'Customer Number',
    'value' => get_post_meta( $order->get_id(), 'your_meta_field_name', true )
    );
    }

    return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );

    Wanted to be sure if their premium version would work?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author The Generation

    (@thegeneration)

    Hi,

    We haven’t used this plugin before, but judging from the example, the following code should work:


    function add_company_registration_number_to_wcdn( $fields, $wc_order ) { $new_fields = array(); $reg_nr = $wc_order->get_meta( '_svea_co_company_reg_number' ); if( ! empty( $reg_nr ) ) { $new_fields['company_reg_number'] = array( 'label' => 'Company Registration Number', 'value' => $reg_nr, ); } return array_merge( $fields, $new_fields ); } add_filter( 'wcdn_order_info_fields', 'add_company_registration_number_to_wcdn', 10, 2 );

    It’s important to note that this code should be placed in a child theme’s functions.php file or another location that won’t be overwritten during updates. This ensures that your customizations remain intact when the theme or plugins are updated.

    Best regards

    Thread Starter techtone

    (@techtoned)

    This worked! Thanks. Any recommendation for such features? Which ones did you used?

    I mean, to prevent future issues, is there any plugin out there that can be used with Svea Checkout?

    Plugin Author The Generation

    (@thegeneration)

    Hi,

    Since “company_reg_number” is a custom field and not present in the WooCommerce default checkout there won’t be any plug’n’play solution if the plugin creators

    However by adding the fields as in the example above it should work just fine and we have no preferences or recommendations regarding any other plugins for that functionality.

    Best regards

    Thread Starter techtone

    (@techtoned)

    Right. Thanks a bunch.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.