Print Invoice & Delivery Notes for WooCommerce by Tyche Software: How to modify templates. (WCDN)

Поділитися
Вставка
  • Опубліковано 30 вер 2024
  • This video describes how to create 3 separate templates for the the Print Invoice & Delivery Notes for WooCommerce by Tyche Software. This plugin is very similar to an earlier plugin called WCDN (Woocommerce Delivery Notes) Print Delivery Notes. It seems that a lot of plugins with this functionality are based on the original WCDN plugin, so this method might work for other plugins as well.

КОМЕНТАРІ • 2

  • @matizilber
    @matizilber Рік тому

    Great video! Do yo know if its possible to add the payment date to the delivery note?

    • @davidjoughin7775
      @davidjoughin7775  Рік тому

      Yes, you can do that. I am not really a programmer, so I am not the best person to help you with this, but I can give you a hint. The hardest part is finding out how the information is stored and how to get it out of the database. You can do that like this:
      $Your_variable_name = get_post_meta($order->id);
      You can then print out the payment date with this line using echo or print, or whatever:
      echo $Your-variable_name ["_paid_date"][0];
      If you want the proper way to do it, you can find this in the plugin FAQ section. (I think the key missing piece of information is that the 'your_meta_field_name' is the ["_paid_date"][0] that I referenced above):
      How can I add some more fields to the order info section?
      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 );
      I hope that helps.