WooCommerce PDF Invoices & Packing Slips - Version 2.1.1

Version Description

  • Fix: WooCommerce Order Status & Actions Manager emails compatibility
  • Feature: sort orders by invoice number column
  • Tweak: pass document object to title filters
  • Tweak: use title getter in template files (instead of title string)
Download this release

Release Info

Developer pomegranate
Plugin Icon 128x128 WooCommerce PDF Invoices & Packing Slips
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1.0 to 2.1.1

includes/class-wcpdf-admin.php CHANGED
@@ -12,7 +12,6 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Admin' ) ) :
13
 
14
  class Admin {
15
-
16
  function __construct() {
17
  add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) );
18
  add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_invoice_number_column' ), 999 );
@@ -31,6 +30,9 @@ class Admin {
31
 
32
  add_action( 'init', array( $this, 'setup_wizard') );
33
  // add_action( 'wpo_wcpdf_after_pdf', array( $this,'update_pdf_counter' ), 10, 2 );
 
 
 
34
  }
35
 
36
  // display review admin notice after 100 pdf downloads
@@ -441,7 +443,6 @@ class Admin {
441
  }
442
  }
443
 
444
-
445
  /**
446
  * Add invoice number to order search scope
447
  */
@@ -451,7 +452,6 @@ class Admin {
451
  return $custom_fields;
452
  }
453
 
454
-
455
  /**
456
  * Check if this is a shop_order page (edit or list)
457
  */
@@ -463,6 +463,25 @@ class Admin {
463
  return false;
464
  }
465
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  }
467
 
468
  endif; // class_exists
12
  if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Admin' ) ) :
13
 
14
  class Admin {
 
15
  function __construct() {
16
  add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) );
17
  add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_invoice_number_column' ), 999 );
30
 
31
  add_action( 'init', array( $this, 'setup_wizard') );
32
  // add_action( 'wpo_wcpdf_after_pdf', array( $this,'update_pdf_counter' ), 10, 2 );
33
+
34
+ add_filter( 'manage_edit-shop_order_sortable_columns', array( $this, 'invoice_number_column_sortable' ) );
35
+ add_filter( 'pre_get_posts', array( $this, 'sort_by_invoice_number' ) );
36
  }
37
 
38
  // display review admin notice after 100 pdf downloads
443
  }
444
  }
445
 
 
446
  /**
447
  * Add invoice number to order search scope
448
  */
452
  return $custom_fields;
453
  }
454
 
 
455
  /**
456
  * Check if this is a shop_order page (edit or list)
457
  */
463
  return false;
464
  }
465
  }
466
+
467
+ /**
468
+ * Add invoice number to order search scope
469
+ */
470
+ public function invoice_number_column_sortable( $columns ) {
471
+ $columns['pdf_invoice_number'] = 'pdf_invoice_number';
472
+ return $columns;
473
+ }
474
+
475
+ public function sort_by_invoice_number( $query ) {
476
+ if( ! is_admin() )
477
+ return;
478
+ $orderby = $query->get( 'orderby');
479
+ if( 'pdf_invoice_number' == $orderby ) {
480
+ $query->set('meta_key','_wcpdf_invoice_number');
481
+ $query->set('orderby','meta_value_num');
482
+ }
483
+ }
484
+
485
  }
486
 
487
  endif; // class_exists
includes/compatibility/class-wcpdf-compatibility-third-party-plugins.php CHANGED
@@ -146,7 +146,7 @@ class Third_Party_Plugins {
146
  public function wc_order_status_actions_emails ( $emails ) {
147
  // get list of custom statuses from WooCommerce Custom Order Status & Actions
148
  // status slug => status name
149
- $custom_statuses = WC_Custom_Status::get_status_list_names();
150
  // append _email to slug (=email_id) and add to emails list
151
  foreach ($custom_statuses as $status_slug => $status_name) {
152
  $emails[$status_slug.'_email'] = $status_name;
146
  public function wc_order_status_actions_emails ( $emails ) {
147
  // get list of custom statuses from WooCommerce Custom Order Status & Actions
148
  // status slug => status name
149
+ $custom_statuses = \WC_Custom_Status::get_status_list_names();
150
  // append _email to slug (=email_id) and add to emails list
151
  foreach ($custom_statuses as $status_slug => $status_name) {
152
  $emails[$status_slug.'_email'] = $status_name;
includes/documents/abstract-wcpdf-order-document.php CHANGED
@@ -255,7 +255,7 @@ abstract class Order_Document {
255
  }
256
 
257
  public function get_title() {
258
- return apply_filters( "wpo_wcpdf_{$this->slug}_title", $this->title );
259
  }
260
 
261
  /*
255
  }
256
 
257
  public function get_title() {
258
+ return apply_filters( "wpo_wcpdf_{$this->slug}_title", $this->title, $this );
259
  }
260
 
261
  /*
includes/documents/class-wcpdf-invoice.php CHANGED
@@ -1,353 +1,353 @@
1
- <?php
2
- namespace WPO\WC\PDF_Invoices\Documents;
3
-
4
- use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
5
- use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
6
- use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit; // Exit if accessed directly
10
- }
11
-
12
- if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Documents\\Invoice' ) ) :
13
-
14
- /**
15
- * Invoice Document
16
- *
17
- * @class \WPO\WC\PDF_Invoices\Documents\Invoice
18
- * @version 2.0
19
- * @category Class
20
- * @author Ewout Fernhout
21
- */
22
-
23
- class Invoice extends Order_Document_Methods {
24
- /**
25
- * Init/load the order object.
26
- *
27
- * @param int|object|WC_Order $order Order to init.
28
- */
29
- public function __construct( $order = 0 ) {
30
- // set properties
31
- $this->type = 'invoice';
32
- $this->title = __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' );
33
- $this->icon = WPO_WCPDF()->plugin_url() . "/assets/images/invoice.png";
34
-
35
- // Call parent constructor
36
- parent::__construct( $order );
37
- }
38
-
39
- public function get_title() {
40
- // override/not using $this->title to allow for language switching!
41
- return apply_filters( "wpo_wcpdf_{$this->slug}_title", __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' ) );
42
- }
43
-
44
- public function init() {
45
- $this->set_date( current_time( 'timestamp', true ) );
46
- $this->init_number();
47
- }
48
-
49
- public function init_number() {
50
- global $wpdb;
51
- // If a third-party plugin claims to generate invoice numbers, trigger this instead
52
- if ( apply_filters( 'woocommerce_invoice_number_by_plugin', false ) || apply_filters( 'wpo_wcpdf_external_invoice_number_enabled', false, $this ) ) {
53
- $invoice_number = apply_filters( 'woocommerce_generate_invoice_number', null, $this->order );
54
- $invoice_number = apply_filters( 'wpo_wcpdf_external_invoice_number', $invoice_number, $this );
55
- if ( is_numeric($invoice_number) || $invoice_number instanceof Document_Number ) {
56
- $this->set_number( $invoice_number );
57
- } else {
58
- // invoice number is not numeric, treat as formatted
59
- // try to extract meaningful number data
60
- $formatted_number = $invoice_number;
61
- $number = (int) preg_replace('/\D/', '', $invoice_number);
62
- $invoice_number = compact( 'number', 'formatted_number' );
63
- $this->set_number( $invoice_number );
64
- }
65
- return $invoice_number;
66
- }
67
-
68
- $number_store_method = WPO_WCPDF()->settings->get_sequential_number_store_method();
69
- $number_store = new Sequential_Number_Store( 'invoice_number', $number_store_method );
70
- // reset invoice number yearly
71
- if ( isset( $this->settings['reset_number_yearly'] ) ) {
72
- $current_year = date("Y");
73
- $last_number_year = $number_store->get_last_date('Y');
74
- // check if we need to reset
75
- if ( $current_year != $last_number_year ) {
76
- $number_store->set_next( 1 );
77
- }
78
- }
79
-
80
- $invoice_date = $this->get_date();
81
- $invoice_number = $number_store->increment( $this->order_id, $invoice_date->date_i18n( 'Y-m-d H:i:s' ) );
82
-
83
- $this->set_number( $invoice_number );
84
-
85
- return $invoice_number;
86
- }
87
-
88
- public function get_settings() {
89
- $common_settings = WPO_WCPDF()->settings->get_common_document_settings();
90
- $document_settings = get_option( 'wpo_wcpdf_documents_settings_invoice' );
91
- return (array) $document_settings + (array) $common_settings;
92
- }
93
-
94
- public function get_filename( $context = 'download', $args = array() ) {
95
- $order_count = isset($args['order_ids']) ? count($args['order_ids']) : 1;
96
-
97
- $name = _n( 'invoice', 'invoices', $order_count, 'woocommerce-pdf-invoices-packing-slips' );
98
-
99
- if ( $order_count == 1 ) {
100
- if ( isset( $this->settings['display_number'] ) ) {
101
- $suffix = (string) $this->get_number();
102
- } else {
103
- if ( empty( $this->order ) ) {
104
- $order = WCX::get_order ( $order_ids[0] );
105
- $suffix = method_exists( $order, 'get_order_number' ) ? $order->get_order_number() : '';
106
- } else {
107
- $suffix = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
108
- }
109
- }
110
- } else {
111
- $suffix = date('Y-m-d'); // 2020-11-11
112
- }
113
-
114
- $filename = $name . '-' . $suffix . '.pdf';
115
-
116
- // Filter filename
117
- $order_ids = isset($args['order_ids']) ? $args['order_ids'] : array( $this->order_id );
118
- $filename = apply_filters( 'wpo_wcpdf_filename', $filename, $this->get_type(), $order_ids, $context );
119
-
120
- // sanitize filename (after filters to prevent human errors)!
121
- return sanitize_file_name( $filename );
122
- }
123
-
124
-
125
- /**
126
- * Initialise settings
127
- */
128
- public function init_settings() {
129
- // Register settings.
130
- $page = $option_group = $option_name = 'wpo_wcpdf_documents_settings_invoice';
131
-
132
- $settings_fields = array(
133
- array(
134
- 'type' => 'section',
135
- 'id' => 'invoice',
136
- 'title' => '',
137
- 'callback' => 'section',
138
- ),
139
- array(
140
- 'type' => 'setting',
141
- 'id' => 'enabled',
142
- 'title' => __( 'Enable', 'woocommerce-pdf-invoices-packing-slips' ),
143
- 'callback' => 'checkbox',
144
- 'section' => 'invoice',
145
- 'args' => array(
146
- 'option_name' => $option_name,
147
- 'id' => 'enabled',
148
- )
149
- ),
150
- array(
151
- 'type' => 'setting',
152
- 'id' => 'attach_to_email_ids',
153
- 'title' => __( 'Attach to:', 'woocommerce-pdf-invoices-packing-slips' ),
154
- 'callback' => 'multiple_checkboxes',
155
- 'section' => 'invoice',
156
- 'args' => array(
157
- 'option_name' => $option_name,
158
- 'id' => 'attach_to_email_ids',
159
- 'fields' => $this->get_wc_emails(),
160
- 'description' => !is_writable( WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ) ? '<span class="wpo-warning">' . sprintf( __( 'It looks like the temp folder (<code>%s</code>) is not writable, check the permissions for this folder! Without having write access to this folder, the plugin will not be able to email invoices.', 'woocommerce-pdf-invoices-packing-slips' ), WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ).'</span>':'',
161
- )
162
- ),
163
- array(
164
- 'type' => 'setting',
165
- 'id' => 'display_shipping_address',
166
- 'title' => __( 'Display shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
167
- 'callback' => 'checkbox',
168
- 'section' => 'invoice',
169
- 'args' => array(
170
- 'option_name' => $option_name,
171
- 'id' => 'display_shipping_address',
172
- 'description' => __( 'Display shipping address (in addition to the default billing address) if different from billing address', 'woocommerce-pdf-invoices-packing-slips' ),
173
- )
174
- ),
175
- array(
176
- 'type' => 'setting',
177
- 'id' => 'display_email',
178
- 'title' => __( 'Display email address', 'woocommerce-pdf-invoices-packing-slips' ),
179
- 'callback' => 'checkbox',
180
- 'section' => 'invoice',
181
- 'args' => array(
182
- 'option_name' => $option_name,
183
- 'id' => 'display_email',
184
- )
185
- ),
186
- array(
187
- 'type' => 'setting',
188
- 'id' => 'display_phone',
189
- 'title' => __( 'Display phone number', 'woocommerce-pdf-invoices-packing-slips' ),
190
- 'callback' => 'checkbox',
191
- 'section' => 'invoice',
192
- 'args' => array(
193
- 'option_name' => $option_name,
194
- 'id' => 'display_phone',
195
- )
196
- ),
197
- array(
198
- 'type' => 'setting',
199
- 'id' => 'display_date',
200
- 'title' => __( 'Display invoice date', 'woocommerce-pdf-invoices-packing-slips' ),
201
- 'callback' => 'checkbox',
202
- 'section' => 'invoice',
203
- 'args' => array(
204
- 'option_name' => $option_name,
205
- 'id' => 'display_date',
206
- 'value' => 'invoice_date',
207
- )
208
- ),
209
- array(
210
- 'type' => 'setting',
211
- 'id' => 'display_number',
212
- 'title' => __( 'Display invoice number', 'woocommerce-pdf-invoices-packing-slips' ),
213
- 'callback' => 'checkbox',
214
- 'section' => 'invoice',
215
- 'args' => array(
216
- 'option_name' => $option_name,
217
- 'id' => 'display_number',
218
- 'value' => 'invoice_number',
219
- )
220
- ),
221
- array(
222
- 'type' => 'setting',
223
- 'id' => 'next_invoice_number',
224
- 'title' => __( 'Next invoice number (without prefix/suffix etc.)', 'woocommerce-pdf-invoices-packing-slips' ),
225
- 'callback' => 'next_number_edit',
226
- 'section' => 'invoice',
227
- 'args' => array(
228
- 'store' => 'invoice_number',
229
- 'size' => '10',
230
- 'description' => __( 'This is the number that will be used for the next document. By default, numbering starts from 1 and increases for every new document. Note that if you override this and set it lower than the current/highest number, this could create duplicate numbers!', 'woocommerce-pdf-invoices-packing-slips' ),
231
- )
232
- ),
233
- array(
234
- 'type' => 'setting',
235
- 'id' => 'number_format',
236
- 'title' => __( 'Number format', 'woocommerce-pdf-invoices-packing-slips' ),
237
- 'callback' => 'multiple_text_input',
238
- 'section' => 'invoice',
239
- 'args' => array(
240
- 'option_name' => $option_name,
241
- 'id' => 'number_format',
242
- 'fields' => array(
243
- 'prefix' => array(
244
- 'placeholder' => __( 'Prefix' , 'woocommerce-pdf-invoices-packing-slips' ),
245
- 'size' => 20,
246
- 'description' => __( 'to use the invoice year and/or month, use [invoice_year] or [invoice_month] respectively' , 'woocommerce-pdf-invoices-packing-slips' ),
247
- ),
248
- 'suffix' => array(
249
- 'placeholder' => __( 'Suffix' , 'woocommerce-pdf-invoices-packing-slips' ),
250
- 'size' => 20,
251
- 'description' => '',
252
- ),
253
- 'padding' => array(
254
- 'placeholder' => __( 'Padding' , 'woocommerce-pdf-invoices-packing-slips' ),
255
- 'size' => 20,
256
- 'type' => 'number',
257
- 'description' => __( 'enter the number of digits here - enter "6" to display 42 as 000042' , 'woocommerce-pdf-invoices-packing-slips' ),
258
- ),
259
- ),
260
- 'description' => __( 'note: if you have already created a custom invoice number format with a filter, the above settings will be ignored' , 'woocommerce-pdf-invoices-packing-slips' ),
261
- )
262
- ),
263
- array(
264
- 'type' => 'setting',
265
- 'id' => 'reset_number_yearly',
266
- 'title' => __( 'Reset invoice number yearly', 'woocommerce-pdf-invoices-packing-slips' ),
267
- 'callback' => 'checkbox',
268
- 'section' => 'invoice',
269
- 'args' => array(
270
- 'option_name' => $option_name,
271
- 'id' => 'reset_number_yearly',
272
- )
273
- ),
274
- array(
275
- 'type' => 'setting',
276
- 'id' => 'my_account_buttons',
277
- 'title' => __( 'Allow My Account invoice download', 'woocommerce-pdf-invoices-packing-slips' ),
278
- 'callback' => 'select',
279
- 'section' => 'invoice',
280
- 'args' => array(
281
- 'option_name' => $option_name,
282
- 'id' => 'my_account_buttons',
283
- 'options' => array(
284
- 'available' => __( 'Only when an invoice is already created/emailed' , 'woocommerce-pdf-invoices-packing-slips' ),
285
- 'custom' => __( 'Only for specific order statuses (define below)' , 'woocommerce-pdf-invoices-packing-slips' ),
286
- 'always' => __( 'Always' , 'woocommerce-pdf-invoices-packing-slips' ),
287
- 'never' => __( 'Never' , 'woocommerce-pdf-invoices-packing-slips' ),
288
- ),
289
- 'custom' => array(
290
- 'type' => 'multiple_checkboxes',
291
- 'args' => array(
292
- 'option_name' => $option_name,
293
- 'id' => 'my_account_restrict',
294
- 'fields' => $this->get_wc_order_status_list(),
295
- ),
296
- ),
297
- )
298
- ),
299
- array(
300
- 'type' => 'setting',
301
- 'id' => 'invoice_number_column',
302
- 'title' => __( 'Enable invoice number column in the orders list', 'woocommerce-pdf-invoices-packing-slips' ),
303
- 'callback' => 'checkbox',
304
- 'section' => 'invoice',
305
- 'args' => array(
306
- 'option_name' => $option_name,
307
- 'id' => 'invoice_number_column',
308
- )
309
- ),
310
- array(
311
- 'type' => 'setting',
312
- 'id' => 'disable_free',
313
- 'title' => __( 'Disable for free products', 'woocommerce-pdf-invoices-packing-slips' ),
314
- 'callback' => 'checkbox',
315
- 'section' => 'invoice',
316
- 'args' => array(
317
- 'option_name' => $option_name,
318
- 'id' => 'disable_free',
319
- 'description' => __( "Disable automatic creation/attachment when only free products are ordered", 'woocommerce-pdf-invoices-packing-slips' ),
320
- )
321
- ),
322
- );
323
-
324
-
325
- // remove/rename some fields when invoice number is controlled externally
326
- if( apply_filters('woocommerce_invoice_number_by_plugin', false) ) {
327
- $remove_settings = array( 'next_invoice_number', 'number_format', 'reset_number_yearly' );
328
- foreach ($settings_fields as $key => $settings_field) {
329
- if (in_array($settings_field['id'], $remove_settings)) {
330
- unset($settings_fields[$key]);
331
- } elseif ( $settings_field['id'] == 'display_number' ) {
332
- // alternate description for invoice number
333
- $invoice_number_desc = __( 'Invoice numbers are created by a third-party extension.', 'woocommerce-pdf-invoices-packing-slips' );
334
- if ( esc_attr( apply_filters( 'woocommerce_invoice_number_configuration_link', null ) ) ) {
335
- $invoice_number_desc .= ' '.sprintf(__( 'Configure it <a href="%s">here</a>.', 'woocommerce-pdf-invoices-packing-slips' ), $config_link);
336
- }
337
- $settings_fields[$key]['args']['description'] = '<i>'.$invoice_number_desc.'</i>';
338
- }
339
- }
340
- }
341
-
342
- // allow plugins to alter settings fields
343
- $settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_documents_invoice', $settings_fields, $page, $option_group, $option_name );
344
- WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
345
- return;
346
-
347
- }
348
-
349
- }
350
-
351
- endif; // class_exists
352
-
353
  return new Invoice();
1
+ <?php
2
+ namespace WPO\WC\PDF_Invoices\Documents;
3
+
4
+ use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
5
+ use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
6
+ use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly
10
+ }
11
+
12
+ if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Documents\\Invoice' ) ) :
13
+
14
+ /**
15
+ * Invoice Document
16
+ *
17
+ * @class \WPO\WC\PDF_Invoices\Documents\Invoice
18
+ * @version 2.0
19
+ * @category Class
20
+ * @author Ewout Fernhout
21
+ */
22
+
23
+ class Invoice extends Order_Document_Methods {
24
+ /**
25
+ * Init/load the order object.
26
+ *
27
+ * @param int|object|WC_Order $order Order to init.
28
+ */
29
+ public function __construct( $order = 0 ) {
30
+ // set properties
31
+ $this->type = 'invoice';
32
+ $this->title = __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' );
33
+ $this->icon = WPO_WCPDF()->plugin_url() . "/assets/images/invoice.png";
34
+
35
+ // Call parent constructor
36
+ parent::__construct( $order );
37
+ }
38
+
39
+ public function get_title() {
40
+ // override/not using $this->title to allow for language switching!
41
+ return apply_filters( "wpo_wcpdf_{$this->slug}_title", __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' ), $this );
42
+ }
43
+
44
+ public function init() {
45
+ $this->set_date( current_time( 'timestamp', true ) );
46
+ $this->init_number();
47
+ }
48
+
49
+ public function init_number() {
50
+ global $wpdb;
51
+ // If a third-party plugin claims to generate invoice numbers, trigger this instead
52
+ if ( apply_filters( 'woocommerce_invoice_number_by_plugin', false ) || apply_filters( 'wpo_wcpdf_external_invoice_number_enabled', false, $this ) ) {
53
+ $invoice_number = apply_filters( 'woocommerce_generate_invoice_number', null, $this->order );
54
+ $invoice_number = apply_filters( 'wpo_wcpdf_external_invoice_number', $invoice_number, $this );
55
+ if ( is_numeric($invoice_number) || $invoice_number instanceof Document_Number ) {
56
+ $this->set_number( $invoice_number );
57
+ } else {
58
+ // invoice number is not numeric, treat as formatted
59
+ // try to extract meaningful number data
60
+ $formatted_number = $invoice_number;
61
+ $number = (int) preg_replace('/\D/', '', $invoice_number);
62
+ $invoice_number = compact( 'number', 'formatted_number' );
63
+ $this->set_number( $invoice_number );
64
+ }
65
+ return $invoice_number;
66
+ }
67
+
68
+ $number_store_method = WPO_WCPDF()->settings->get_sequential_number_store_method();
69
+ $number_store = new Sequential_Number_Store( 'invoice_number', $number_store_method );
70
+ // reset invoice number yearly
71
+ if ( isset( $this->settings['reset_number_yearly'] ) ) {
72
+ $current_year = date("Y");
73
+ $last_number_year = $number_store->get_last_date('Y');
74
+ // check if we need to reset
75
+ if ( $current_year != $last_number_year ) {
76
+ $number_store->set_next( 1 );
77
+ }
78
+ }
79
+
80
+ $invoice_date = $this->get_date();
81
+ $invoice_number = $number_store->increment( $this->order_id, $invoice_date->date_i18n( 'Y-m-d H:i:s' ) );
82
+
83
+ $this->set_number( $invoice_number );
84
+
85
+ return $invoice_number;
86
+ }
87
+
88
+ public function get_settings() {
89
+ $common_settings = WPO_WCPDF()->settings->get_common_document_settings();
90
+ $document_settings = get_option( 'wpo_wcpdf_documents_settings_invoice' );
91
+ return (array) $document_settings + (array) $common_settings;
92
+ }
93
+
94
+ public function get_filename( $context = 'download', $args = array() ) {
95
+ $order_count = isset($args['order_ids']) ? count($args['order_ids']) : 1;
96
+
97
+ $name = _n( 'invoice', 'invoices', $order_count, 'woocommerce-pdf-invoices-packing-slips' );
98
+
99
+ if ( $order_count == 1 ) {
100
+ if ( isset( $this->settings['display_number'] ) ) {
101
+ $suffix = (string) $this->get_number();
102
+ } else {
103
+ if ( empty( $this->order ) ) {
104
+ $order = WCX::get_order ( $order_ids[0] );
105
+ $suffix = method_exists( $order, 'get_order_number' ) ? $order->get_order_number() : '';
106
+ } else {
107
+ $suffix = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
108
+ }
109
+ }
110
+ } else {
111
+ $suffix = date('Y-m-d'); // 2020-11-11
112
+ }
113
+
114
+ $filename = $name . '-' . $suffix . '.pdf';
115
+
116
+ // Filter filename
117
+ $order_ids = isset($args['order_ids']) ? $args['order_ids'] : array( $this->order_id );
118
+ $filename = apply_filters( 'wpo_wcpdf_filename', $filename, $this->get_type(), $order_ids, $context );
119
+
120
+ // sanitize filename (after filters to prevent human errors)!
121
+ return sanitize_file_name( $filename );
122
+ }
123
+
124
+
125
+ /**
126
+ * Initialise settings
127
+ */
128
+ public function init_settings() {
129
+ // Register settings.
130
+ $page = $option_group = $option_name = 'wpo_wcpdf_documents_settings_invoice';
131
+
132
+ $settings_fields = array(
133
+ array(
134
+ 'type' => 'section',
135
+ 'id' => 'invoice',
136
+ 'title' => '',
137
+ 'callback' => 'section',
138
+ ),
139
+ array(
140
+ 'type' => 'setting',
141
+ 'id' => 'enabled',
142
+ 'title' => __( 'Enable', 'woocommerce-pdf-invoices-packing-slips' ),
143
+ 'callback' => 'checkbox',
144
+ 'section' => 'invoice',
145
+ 'args' => array(
146
+ 'option_name' => $option_name,
147
+ 'id' => 'enabled',
148
+ )
149
+ ),
150
+ array(
151
+ 'type' => 'setting',
152
+ 'id' => 'attach_to_email_ids',
153
+ 'title' => __( 'Attach to:', 'woocommerce-pdf-invoices-packing-slips' ),
154
+ 'callback' => 'multiple_checkboxes',
155
+ 'section' => 'invoice',
156
+ 'args' => array(
157
+ 'option_name' => $option_name,
158
+ 'id' => 'attach_to_email_ids',
159
+ 'fields' => $this->get_wc_emails(),
160
+ 'description' => !is_writable( WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ) ? '<span class="wpo-warning">' . sprintf( __( 'It looks like the temp folder (<code>%s</code>) is not writable, check the permissions for this folder! Without having write access to this folder, the plugin will not be able to email invoices.', 'woocommerce-pdf-invoices-packing-slips' ), WPO_WCPDF()->main->get_tmp_path( 'attachments' ) ).'</span>':'',
161
+ )
162
+ ),
163
+ array(
164
+ 'type' => 'setting',
165
+ 'id' => 'display_shipping_address',
166
+ 'title' => __( 'Display shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
167
+ 'callback' => 'checkbox',
168
+ 'section' => 'invoice',
169
+ 'args' => array(
170
+ 'option_name' => $option_name,
171
+ 'id' => 'display_shipping_address',
172
+ 'description' => __( 'Display shipping address (in addition to the default billing address) if different from billing address', 'woocommerce-pdf-invoices-packing-slips' ),
173
+ )
174
+ ),
175
+ array(
176
+ 'type' => 'setting',
177
+ 'id' => 'display_email',
178
+ 'title' => __( 'Display email address', 'woocommerce-pdf-invoices-packing-slips' ),
179
+ 'callback' => 'checkbox',
180
+ 'section' => 'invoice',
181
+ 'args' => array(
182
+ 'option_name' => $option_name,
183
+ 'id' => 'display_email',
184
+ )
185
+ ),
186
+ array(
187
+ 'type' => 'setting',
188
+ 'id' => 'display_phone',
189
+ 'title' => __( 'Display phone number', 'woocommerce-pdf-invoices-packing-slips' ),
190
+ 'callback' => 'checkbox',
191
+ 'section' => 'invoice',
192
+ 'args' => array(
193
+ 'option_name' => $option_name,
194
+ 'id' => 'display_phone',
195
+ )
196
+ ),
197
+ array(
198
+ 'type' => 'setting',
199
+ 'id' => 'display_date',
200
+ 'title' => __( 'Display invoice date', 'woocommerce-pdf-invoices-packing-slips' ),
201
+ 'callback' => 'checkbox',
202
+ 'section' => 'invoice',
203
+ 'args' => array(
204
+ 'option_name' => $option_name,
205
+ 'id' => 'display_date',
206
+ 'value' => 'invoice_date',
207
+ )
208
+ ),
209
+ array(
210
+ 'type' => 'setting',
211
+ 'id' => 'display_number',
212
+ 'title' => __( 'Display invoice number', 'woocommerce-pdf-invoices-packing-slips' ),
213
+ 'callback' => 'checkbox',
214
+ 'section' => 'invoice',
215
+ 'args' => array(
216
+ 'option_name' => $option_name,
217
+ 'id' => 'display_number',
218
+ 'value' => 'invoice_number',
219
+ )
220
+ ),
221
+ array(
222
+ 'type' => 'setting',
223
+ 'id' => 'next_invoice_number',
224
+ 'title' => __( 'Next invoice number (without prefix/suffix etc.)', 'woocommerce-pdf-invoices-packing-slips' ),
225
+ 'callback' => 'next_number_edit',
226
+ 'section' => 'invoice',
227
+ 'args' => array(
228
+ 'store' => 'invoice_number',
229
+ 'size' => '10',
230
+ 'description' => __( 'This is the number that will be used for the next document. By default, numbering starts from 1 and increases for every new document. Note that if you override this and set it lower than the current/highest number, this could create duplicate numbers!', 'woocommerce-pdf-invoices-packing-slips' ),
231
+ )
232
+ ),
233
+ array(
234
+ 'type' => 'setting',
235
+ 'id' => 'number_format',
236
+ 'title' => __( 'Number format', 'woocommerce-pdf-invoices-packing-slips' ),
237
+ 'callback' => 'multiple_text_input',
238
+ 'section' => 'invoice',
239
+ 'args' => array(
240
+ 'option_name' => $option_name,
241
+ 'id' => 'number_format',
242
+ 'fields' => array(
243
+ 'prefix' => array(
244
+ 'placeholder' => __( 'Prefix' , 'woocommerce-pdf-invoices-packing-slips' ),
245
+ 'size' => 20,
246
+ 'description' => __( 'to use the invoice year and/or month, use [invoice_year] or [invoice_month] respectively' , 'woocommerce-pdf-invoices-packing-slips' ),
247
+ ),
248
+ 'suffix' => array(
249
+ 'placeholder' => __( 'Suffix' , 'woocommerce-pdf-invoices-packing-slips' ),
250
+ 'size' => 20,
251
+ 'description' => '',
252
+ ),
253
+ 'padding' => array(
254
+ 'placeholder' => __( 'Padding' , 'woocommerce-pdf-invoices-packing-slips' ),
255
+ 'size' => 20,
256
+ 'type' => 'number',
257
+ 'description' => __( 'enter the number of digits here - enter "6" to display 42 as 000042' , 'woocommerce-pdf-invoices-packing-slips' ),
258
+ ),
259
+ ),
260
+ 'description' => __( 'note: if you have already created a custom invoice number format with a filter, the above settings will be ignored' , 'woocommerce-pdf-invoices-packing-slips' ),
261
+ )
262
+ ),
263
+ array(
264
+ 'type' => 'setting',
265
+ 'id' => 'reset_number_yearly',
266
+ 'title' => __( 'Reset invoice number yearly', 'woocommerce-pdf-invoices-packing-slips' ),
267
+ 'callback' => 'checkbox',
268
+ 'section' => 'invoice',
269
+ 'args' => array(
270
+ 'option_name' => $option_name,
271
+ 'id' => 'reset_number_yearly',
272
+ )
273
+ ),
274
+ array(
275
+ 'type' => 'setting',
276
+ 'id' => 'my_account_buttons',
277
+ 'title' => __( 'Allow My Account invoice download', 'woocommerce-pdf-invoices-packing-slips' ),
278
+ 'callback' => 'select',
279
+ 'section' => 'invoice',
280
+ 'args' => array(
281
+ 'option_name' => $option_name,
282
+ 'id' => 'my_account_buttons',
283
+ 'options' => array(
284
+ 'available' => __( 'Only when an invoice is already created/emailed' , 'woocommerce-pdf-invoices-packing-slips' ),
285
+ 'custom' => __( 'Only for specific order statuses (define below)' , 'woocommerce-pdf-invoices-packing-slips' ),
286
+ 'always' => __( 'Always' , 'woocommerce-pdf-invoices-packing-slips' ),
287
+ 'never' => __( 'Never' , 'woocommerce-pdf-invoices-packing-slips' ),
288
+ ),
289
+ 'custom' => array(
290
+ 'type' => 'multiple_checkboxes',
291
+ 'args' => array(
292
+ 'option_name' => $option_name,
293
+ 'id' => 'my_account_restrict',
294
+ 'fields' => $this->get_wc_order_status_list(),
295
+ ),
296
+ ),
297
+ )
298
+ ),
299
+ array(
300
+ 'type' => 'setting',
301
+ 'id' => 'invoice_number_column',
302
+ 'title' => __( 'Enable invoice number column in the orders list', 'woocommerce-pdf-invoices-packing-slips' ),
303
+ 'callback' => 'checkbox',
304
+ 'section' => 'invoice',
305
+ 'args' => array(
306
+ 'option_name' => $option_name,
307
+ 'id' => 'invoice_number_column',
308
+ )
309
+ ),
310
+ array(
311
+ 'type' => 'setting',
312
+ 'id' => 'disable_free',
313
+ 'title' => __( 'Disable for free products', 'woocommerce-pdf-invoices-packing-slips' ),
314
+ 'callback' => 'checkbox',
315
+ 'section' => 'invoice',
316
+ 'args' => array(
317
+ 'option_name' => $option_name,
318
+ 'id' => 'disable_free',
319
+ 'description' => __( "Disable automatic creation/attachment when only free products are ordered", 'woocommerce-pdf-invoices-packing-slips' ),
320
+ )
321
+ ),
322
+ );
323
+
324
+
325
+ // remove/rename some fields when invoice number is controlled externally
326
+ if( apply_filters('woocommerce_invoice_number_by_plugin', false) ) {
327
+ $remove_settings = array( 'next_invoice_number', 'number_format', 'reset_number_yearly' );
328
+ foreach ($settings_fields as $key => $settings_field) {
329
+ if (in_array($settings_field['id'], $remove_settings)) {
330
+ unset($settings_fields[$key]);
331
+ } elseif ( $settings_field['id'] == 'display_number' ) {
332
+ // alternate description for invoice number
333
+ $invoice_number_desc = __( 'Invoice numbers are created by a third-party extension.', 'woocommerce-pdf-invoices-packing-slips' );
334
+ if ( esc_attr( apply_filters( 'woocommerce_invoice_number_configuration_link', null ) ) ) {
335
+ $invoice_number_desc .= ' '.sprintf(__( 'Configure it <a href="%s">here</a>.', 'woocommerce-pdf-invoices-packing-slips' ), $config_link);
336
+ }
337
+ $settings_fields[$key]['args']['description'] = '<i>'.$invoice_number_desc.'</i>';
338
+ }
339
+ }
340
+ }
341
+
342
+ // allow plugins to alter settings fields
343
+ $settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_documents_invoice', $settings_fields, $page, $option_group, $option_name );
344
+ WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
345
+ return;
346
+
347
+ }
348
+
349
+ }
350
+
351
+ endif; // class_exists
352
+
353
  return new Invoice();
includes/documents/class-wcpdf-packing-slip.php CHANGED
@@ -1,150 +1,150 @@
1
- <?php
2
- namespace WPO\WC\PDF_Invoices\Documents;
3
-
4
- use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
5
- use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
6
- use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit; // Exit if accessed directly
10
- }
11
-
12
- if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Documents\\Packing_Slip' ) ) :
13
-
14
- /**
15
- * Packing Slip Document
16
- *
17
- * @class \WPO\WC\PDF_Invoices\Documents\Packing_Slip
18
- * @version 2.0
19
- * @category Class
20
- * @author Ewout Fernhout
21
- */
22
-
23
- class Packing_Slip extends Order_Document_Methods {
24
- /**
25
- * Init/load the order object.
26
- *
27
- * @param int|object|WC_Order $order Order to init.
28
- */
29
- public function __construct( $order = 0 ) {
30
- // set properties
31
- $this->type = 'packing-slip';
32
- $this->title = __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' );
33
- $this->icon = WPO_WCPDF()->plugin_url() . "/assets/images/packing-slip.png";
34
-
35
- // Call parent constructor
36
- parent::__construct( $order );
37
- }
38
-
39
- public function get_title() {
40
- // override/not using $this->title to allow for language switching!
41
- return apply_filters( "wpo_wcpdf_{$this->slug}_title", __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ) );
42
- }
43
-
44
- public function get_settings() {
45
- $common_settings = WPO_WCPDF()->settings->get_common_document_settings();
46
- $document_settings = get_option( 'wpo_wcpdf_documents_settings_packing-slip' );
47
- return (array) $document_settings + (array) $common_settings;
48
- }
49
-
50
- public function get_filename( $context = 'download', $args = array() ) {
51
- $order_count = isset($args['order_ids']) ? count($args['order_ids']) : 1;
52
-
53
- $name = _n( 'packing-slip', 'packing-slips', $order_count, 'woocommerce-pdf-invoices-packing-slips' );
54
-
55
- if ( $order_count == 1 ) {
56
- if ( isset( $this->settings['display_number'] ) ) {
57
- $suffix = (string) $this->get_number();
58
- } else {
59
- if ( empty( $this->order ) ) {
60
- $order = WCX::get_order ( $order_ids[0] );
61
- $suffix = method_exists( $order, 'get_order_number' ) ? $order->get_order_number() : '';
62
- } else {
63
- $suffix = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
64
- }
65
- }
66
- } else {
67
- $suffix = date('Y-m-d'); // 2020-11-11
68
- }
69
-
70
- $filename = $name . '-' . $suffix . '.pdf';
71
-
72
- // Filter filename
73
- $order_ids = isset($args['order_ids']) ? $args['order_ids'] : array( $this->order_id );
74
- $filename = apply_filters( 'wpo_wcpdf_filename', $filename, $this->get_type(), $order_ids, $context );
75
-
76
- // sanitize filename (after filters to prevent human errors)!
77
- return sanitize_file_name( $filename );
78
- }
79
-
80
- public function init_settings() {
81
- // Register settings.
82
- $page = $option_group = $option_name = 'wpo_wcpdf_documents_settings_packing-slip';
83
-
84
- $settings_fields = array(
85
- array(
86
- 'type' => 'section',
87
- 'id' => 'packing_slip',
88
- 'title' => '',
89
- 'callback' => 'section',
90
- ),
91
- array(
92
- 'type' => 'setting',
93
- 'id' => 'enabled',
94
- 'title' => __( 'Enable', 'woocommerce-pdf-invoices-packing-slips' ),
95
- 'callback' => 'checkbox',
96
- 'section' => 'packing_slip',
97
- 'args' => array(
98
- 'option_name' => $option_name,
99
- 'id' => 'enabled',
100
- )
101
- ),
102
- array(
103
- 'type' => 'setting',
104
- 'id' => 'display_billing_address',
105
- 'title' => __( 'Display billing address', 'woocommerce-pdf-invoices-packing-slips' ),
106
- 'callback' => 'checkbox',
107
- 'section' => 'packing_slip',
108
- 'args' => array(
109
- 'option_name' => $option_name,
110
- 'id' => 'display_billing_address',
111
- 'description' => __( 'Display billing address (in addition to the default shipping address) if different from shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
112
- )
113
- ),
114
- array(
115
- 'type' => 'setting',
116
- 'id' => 'display_email',
117
- 'title' => __( 'Display email address', 'woocommerce-pdf-invoices-packing-slips' ),
118
- 'callback' => 'checkbox',
119
- 'section' => 'packing_slip',
120
- 'args' => array(
121
- 'option_name' => $option_name,
122
- 'id' => 'display_email',
123
- )
124
- ),
125
- array(
126
- 'type' => 'setting',
127
- 'id' => 'display_phone',
128
- 'title' => __( 'Display phone number', 'woocommerce-pdf-invoices-packing-slips' ),
129
- 'callback' => 'checkbox',
130
- 'section' => 'packing_slip',
131
- 'args' => array(
132
- 'option_name' => $option_name,
133
- 'id' => 'display_phone',
134
- )
135
- ),
136
- );
137
-
138
-
139
- // allow plugins to alter settings fields
140
- $settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_documents_packing_slip', $settings_fields, $page, $option_group, $option_name );
141
- WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
142
- return;
143
-
144
- }
145
-
146
- }
147
-
148
- endif; // class_exists
149
-
150
  return new Packing_Slip();
1
+ <?php
2
+ namespace WPO\WC\PDF_Invoices\Documents;
3
+
4
+ use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
5
+ use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
6
+ use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly
10
+ }
11
+
12
+ if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Documents\\Packing_Slip' ) ) :
13
+
14
+ /**
15
+ * Packing Slip Document
16
+ *
17
+ * @class \WPO\WC\PDF_Invoices\Documents\Packing_Slip
18
+ * @version 2.0
19
+ * @category Class
20
+ * @author Ewout Fernhout
21
+ */
22
+
23
+ class Packing_Slip extends Order_Document_Methods {
24
+ /**
25
+ * Init/load the order object.
26
+ *
27
+ * @param int|object|WC_Order $order Order to init.
28
+ */
29
+ public function __construct( $order = 0 ) {
30
+ // set properties
31
+ $this->type = 'packing-slip';
32
+ $this->title = __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' );
33
+ $this->icon = WPO_WCPDF()->plugin_url() . "/assets/images/packing-slip.png";
34
+
35
+ // Call parent constructor
36
+ parent::__construct( $order );
37
+ }
38
+
39
+ public function get_title() {
40
+ // override/not using $this->title to allow for language switching!
41
+ return apply_filters( "wpo_wcpdf_{$this->slug}_title", __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ), $this );
42
+ }
43
+
44
+ public function get_settings() {
45
+ $common_settings = WPO_WCPDF()->settings->get_common_document_settings();
46
+ $document_settings = get_option( 'wpo_wcpdf_documents_settings_packing-slip' );
47
+ return (array) $document_settings + (array) $common_settings;
48
+ }
49
+
50
+ public function get_filename( $context = 'download', $args = array() ) {
51
+ $order_count = isset($args['order_ids']) ? count($args['order_ids']) : 1;
52
+
53
+ $name = _n( 'packing-slip', 'packing-slips', $order_count, 'woocommerce-pdf-invoices-packing-slips' );
54
+
55
+ if ( $order_count == 1 ) {
56
+ if ( isset( $this->settings['display_number'] ) ) {
57
+ $suffix = (string) $this->get_number();
58
+ } else {
59
+ if ( empty( $this->order ) ) {
60
+ $order = WCX::get_order ( $order_ids[0] );
61
+ $suffix = method_exists( $order, 'get_order_number' ) ? $order->get_order_number() : '';
62
+ } else {
63
+ $suffix = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
64
+ }
65
+ }
66
+ } else {
67
+ $suffix = date('Y-m-d'); // 2020-11-11
68
+ }
69
+
70
+ $filename = $name . '-' . $suffix . '.pdf';
71
+
72
+ // Filter filename
73
+ $order_ids = isset($args['order_ids']) ? $args['order_ids'] : array( $this->order_id );
74
+ $filename = apply_filters( 'wpo_wcpdf_filename', $filename, $this->get_type(), $order_ids, $context );
75
+
76
+ // sanitize filename (after filters to prevent human errors)!
77
+ return sanitize_file_name( $filename );
78
+ }
79
+
80
+ public function init_settings() {
81
+ // Register settings.
82
+ $page = $option_group = $option_name = 'wpo_wcpdf_documents_settings_packing-slip';
83
+
84
+ $settings_fields = array(
85
+ array(
86
+ 'type' => 'section',
87
+ 'id' => 'packing_slip',
88
+ 'title' => '',
89
+ 'callback' => 'section',
90
+ ),
91
+ array(
92
+ 'type' => 'setting',
93
+ 'id' => 'enabled',
94
+ 'title' => __( 'Enable', 'woocommerce-pdf-invoices-packing-slips' ),
95
+ 'callback' => 'checkbox',
96
+ 'section' => 'packing_slip',
97
+ 'args' => array(
98
+ 'option_name' => $option_name,
99
+ 'id' => 'enabled',
100
+ )
101
+ ),
102
+ array(
103
+ 'type' => 'setting',
104
+ 'id' => 'display_billing_address',
105
+ 'title' => __( 'Display billing address', 'woocommerce-pdf-invoices-packing-slips' ),
106
+ 'callback' => 'checkbox',
107
+ 'section' => 'packing_slip',
108
+ 'args' => array(
109
+ 'option_name' => $option_name,
110
+ 'id' => 'display_billing_address',
111
+ 'description' => __( 'Display billing address (in addition to the default shipping address) if different from shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
112
+ )
113
+ ),
114
+ array(
115
+ 'type' => 'setting',
116
+ 'id' => 'display_email',
117
+ 'title' => __( 'Display email address', 'woocommerce-pdf-invoices-packing-slips' ),
118
+ 'callback' => 'checkbox',
119
+ 'section' => 'packing_slip',
120
+ 'args' => array(
121
+ 'option_name' => $option_name,
122
+ 'id' => 'display_email',
123
+ )
124
+ ),
125
+ array(
126
+ 'type' => 'setting',
127
+ 'id' => 'display_phone',
128
+ 'title' => __( 'Display phone number', 'woocommerce-pdf-invoices-packing-slips' ),
129
+ 'callback' => 'checkbox',
130
+ 'section' => 'packing_slip',
131
+ 'args' => array(
132
+ 'option_name' => $option_name,
133
+ 'id' => 'display_phone',
134
+ )
135
+ ),
136
+ );
137
+
138
+
139
+ // allow plugins to alter settings fields
140
+ $settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_documents_packing_slip', $settings_fields, $page, $option_group, $option_name );
141
+ WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
142
+ return;
143
+
144
+ }
145
+
146
+ }
147
+
148
+ endif; // class_exists
149
+
150
  return new Packing_Slip();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice,
5
  Requires at least: 3.5
6
  Tested up to: 4.9
7
  Requires PHP: 5.3
8
- Stable tag: 2.1.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -103,6 +103,12 @@ There's a setting on the Status tab of the settings page that allows you to togg
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
106
  = 2.1.0 =
107
  * Feature: WooCommerce Order Status & Actions Manager emails compatibility
108
  * Fix: Better url fallback for images stored in cloud
@@ -211,5 +217,5 @@ There's a setting on the Status tab of the settings page that allows you to togg
211
 
212
  == Upgrade Notice ==
213
 
214
- = 2.0 =
215
  2.0 is a BIG update! Make a full site backup before upgrading!
5
  Requires at least: 3.5
6
  Tested up to: 4.9
7
  Requires PHP: 5.3
8
+ Stable tag: 2.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
103
 
104
  == Changelog ==
105
 
106
+ = 2.1.1 =
107
+ * Fix: WooCommerce Order Status & Actions Manager emails compatibility
108
+ * Feature: sort orders by invoice number column
109
+ * Tweak: pass document object to title filters
110
+ * Tweak: use title getter in template files (instead of title string)
111
+
112
  = 2.1.0 =
113
  * Feature: WooCommerce Order Status & Actions Manager emails compatibility
114
  * Fix: Better url fallback for images stored in cloud
217
 
218
  == Upgrade Notice ==
219
 
220
+ = 2.1.1 =
221
  2.0 is a BIG update! Make a full site backup before upgrading!
templates/Simple/invoice.php CHANGED
@@ -1,144 +1,144 @@
1
- <?php do_action( 'wpo_wcpdf_before_document', $this->type, $this->order ); ?>
2
-
3
- <table class="head container">
4
- <tr>
5
- <td class="header">
6
- <?php
7
- if( $this->has_header_logo() ) {
8
- $this->header_logo();
9
- } else {
10
- echo apply_filters( 'wpo_wcpdf_invoice_title', __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' ) );
11
- }
12
- ?>
13
- </td>
14
- <td class="shop-info">
15
- <div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
16
- <div class="shop-address"><?php $this->shop_address(); ?></div>
17
- </td>
18
- </tr>
19
- </table>
20
-
21
- <h1 class="document-type-label">
22
- <?php if( $this->has_header_logo() ) echo apply_filters( 'wpo_wcpdf_invoice_title', __( 'Invoice', 'woocommerce-pdf-invoices-packing-slips' ) ); ?>
23
- </h1>
24
-
25
- <?php do_action( 'wpo_wcpdf_after_document_label', $this->type, $this->order ); ?>
26
-
27
- <table class="order-data-addresses">
28
- <tr>
29
- <td class="address billing-address">
30
- <!-- <h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3> -->
31
- <?php $this->billing_address(); ?>
32
- <?php if ( isset($this->settings['display_email']) ) { ?>
33
- <div class="billing-email"><?php $this->billing_email(); ?></div>
34
- <?php } ?>
35
- <?php if ( isset($this->settings['display_phone']) ) { ?>
36
- <div class="billing-phone"><?php $this->billing_phone(); ?></div>
37
- <?php } ?>
38
- </td>
39
- <td class="address shipping-address">
40
- <?php if ( isset($this->settings['display_shipping_address']) && $this->ships_to_different_address()) { ?>
41
- <h3><?php _e( 'Ship To:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
42
- <?php $this->shipping_address(); ?>
43
- <?php } ?>
44
- </td>
45
- <td class="order-data">
46
- <table>
47
- <?php do_action( 'wpo_wcpdf_before_order_data', $this->type, $this->order ); ?>
48
- <?php if ( isset($this->settings['display_number']) ) { ?>
49
- <tr class="invoice-number">
50
- <th><?php _e( 'Invoice Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
51
- <td><?php $this->invoice_number(); ?></td>
52
- </tr>
53
- <?php } ?>
54
- <?php if ( isset($this->settings['display_date']) ) { ?>
55
- <tr class="invoice-date">
56
- <th><?php _e( 'Invoice Date:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
57
- <td><?php $this->invoice_date(); ?></td>
58
- </tr>
59
- <?php } ?>
60
- <tr class="order-number">
61
- <th><?php _e( 'Order Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
62
- <td><?php $this->order_number(); ?></td>
63
- </tr>
64
- <tr class="order-date">
65
- <th><?php _e( 'Order Date:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
66
- <td><?php $this->order_date(); ?></td>
67
- </tr>
68
- <tr class="payment-method">
69
- <th><?php _e( 'Payment Method:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
70
- <td><?php $this->payment_method(); ?></td>
71
- </tr>
72
- <?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>
73
- </table>
74
- </td>
75
- </tr>
76
- </table>
77
-
78
- <?php do_action( 'wpo_wcpdf_before_order_details', $this->type, $this->order ); ?>
79
-
80
- <table class="order-details">
81
- <thead>
82
- <tr>
83
- <th class="product"><?php _e('Product', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
84
- <th class="quantity"><?php _e('Quantity', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
85
- <th class="price"><?php _e('Price', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
86
- </tr>
87
- </thead>
88
- <tbody>
89
- <?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
90
- <tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
91
- <td class="product">
92
- <?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
93
- <span class="item-name"><?php echo $item['name']; ?></span>
94
- <?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
95
- <span class="item-meta"><?php echo $item['meta']; ?></span>
96
- <dl class="meta">
97
- <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
98
- <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'SKU:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
99
- <?php if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif; ?>
100
- </dl>
101
- <?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
102
- </td>
103
- <td class="quantity"><?php echo $item['quantity']; ?></td>
104
- <td class="price"><?php echo $item['order_price']; ?></td>
105
- </tr>
106
- <?php endforeach; endif; ?>
107
- </tbody>
108
- <tfoot>
109
- <tr class="no-borders">
110
- <td class="no-borders">
111
- <div class="customer-notes">
112
- <?php do_action( 'wpo_wcpdf_before_customer_notes', $this->type, $this->order ); ?>
113
- <?php if ( $this->get_shipping_notes() ) : ?>
114
- <h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
115
- <?php $this->shipping_notes(); ?>
116
- <?php endif; ?>
117
- <?php do_action( 'wpo_wcpdf_after_customer_notes', $this->type, $this->order ); ?>
118
- </div>
119
- </td>
120
- <td class="no-borders" colspan="2">
121
- <table class="totals">
122
- <tfoot>
123
- <?php foreach( $this->get_woocommerce_totals() as $key => $total ) : ?>
124
- <tr class="<?php echo $key; ?>">
125
- <td class="no-borders"></td>
126
- <th class="description"><?php echo $total['label']; ?></th>
127
- <td class="price"><span class="totals-price"><?php echo $total['value']; ?></span></td>
128
- </tr>
129
- <?php endforeach; ?>
130
- </tfoot>
131
- </table>
132
- </td>
133
- </tr>
134
- </tfoot>
135
- </table>
136
-
137
- <?php do_action( 'wpo_wcpdf_after_order_details', $this->type, $this->order ); ?>
138
-
139
- <?php if ( $this->get_footer() ): ?>
140
- <div id="footer">
141
- <?php $this->footer(); ?>
142
- </div><!-- #letter-footer -->
143
- <?php endif; ?>
144
- <?php do_action( 'wpo_wcpdf_after_document', $this->type, $this->order ); ?>
1
+ <?php do_action( 'wpo_wcpdf_before_document', $this->type, $this->order ); ?>
2
+
3
+ <table class="head container">
4
+ <tr>
5
+ <td class="header">
6
+ <?php
7
+ if( $this->has_header_logo() ) {
8
+ $this->header_logo();
9
+ } else {
10
+ echo $this->get_title();
11
+ }
12
+ ?>
13
+ </td>
14
+ <td class="shop-info">
15
+ <div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
16
+ <div class="shop-address"><?php $this->shop_address(); ?></div>
17
+ </td>
18
+ </tr>
19
+ </table>
20
+
21
+ <h1 class="document-type-label">
22
+ <?php if( $this->has_header_logo() ) echo $this->get_title(); ?>
23
+ </h1>
24
+
25
+ <?php do_action( 'wpo_wcpdf_after_document_label', $this->type, $this->order ); ?>
26
+
27
+ <table class="order-data-addresses">
28
+ <tr>
29
+ <td class="address billing-address">
30
+ <!-- <h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3> -->
31
+ <?php $this->billing_address(); ?>
32
+ <?php if ( isset($this->settings['display_email']) ) { ?>
33
+ <div class="billing-email"><?php $this->billing_email(); ?></div>
34
+ <?php } ?>
35
+ <?php if ( isset($this->settings['display_phone']) ) { ?>
36
+ <div class="billing-phone"><?php $this->billing_phone(); ?></div>
37
+ <?php } ?>
38
+ </td>
39
+ <td class="address shipping-address">
40
+ <?php if ( isset($this->settings['display_shipping_address']) && $this->ships_to_different_address()) { ?>
41
+ <h3><?php _e( 'Ship To:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
42
+ <?php $this->shipping_address(); ?>
43
+ <?php } ?>
44
+ </td>
45
+ <td class="order-data">
46
+ <table>
47
+ <?php do_action( 'wpo_wcpdf_before_order_data', $this->type, $this->order ); ?>
48
+ <?php if ( isset($this->settings['display_number']) ) { ?>
49
+ <tr class="invoice-number">
50
+ <th><?php _e( 'Invoice Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
51
+ <td><?php $this->invoice_number(); ?></td>
52
+ </tr>
53
+ <?php } ?>
54
+ <?php if ( isset($this->settings['display_date']) ) { ?>
55
+ <tr class="invoice-date">
56
+ <th><?php _e( 'Invoice Date:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
57
+ <td><?php $this->invoice_date(); ?></td>
58
+ </tr>
59
+ <?php } ?>
60
+ <tr class="order-number">
61
+ <th><?php _e( 'Order Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
62
+ <td><?php $this->order_number(); ?></td>
63
+ </tr>
64
+ <tr class="order-date">
65
+ <th><?php _e( 'Order Date:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
66
+ <td><?php $this->order_date(); ?></td>
67
+ </tr>
68
+ <tr class="payment-method">
69
+ <th><?php _e( 'Payment Method:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
70
+ <td><?php $this->payment_method(); ?></td>
71
+ </tr>
72
+ <?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>
73
+ </table>
74
+ </td>
75
+ </tr>
76
+ </table>
77
+
78
+ <?php do_action( 'wpo_wcpdf_before_order_details', $this->type, $this->order ); ?>
79
+
80
+ <table class="order-details">
81
+ <thead>
82
+ <tr>
83
+ <th class="product"><?php _e('Product', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
84
+ <th class="quantity"><?php _e('Quantity', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
85
+ <th class="price"><?php _e('Price', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
86
+ </tr>
87
+ </thead>
88
+ <tbody>
89
+ <?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
90
+ <tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
91
+ <td class="product">
92
+ <?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
93
+ <span class="item-name"><?php echo $item['name']; ?></span>
94
+ <?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
95
+ <span class="item-meta"><?php echo $item['meta']; ?></span>
96
+ <dl class="meta">
97
+ <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
98
+ <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'SKU:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
99
+ <?php if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif; ?>
100
+ </dl>
101
+ <?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
102
+ </td>
103
+ <td class="quantity"><?php echo $item['quantity']; ?></td>
104
+ <td class="price"><?php echo $item['order_price']; ?></td>
105
+ </tr>
106
+ <?php endforeach; endif; ?>
107
+ </tbody>
108
+ <tfoot>
109
+ <tr class="no-borders">
110
+ <td class="no-borders">
111
+ <div class="customer-notes">
112
+ <?php do_action( 'wpo_wcpdf_before_customer_notes', $this->type, $this->order ); ?>
113
+ <?php if ( $this->get_shipping_notes() ) : ?>
114
+ <h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
115
+ <?php $this->shipping_notes(); ?>
116
+ <?php endif; ?>
117
+ <?php do_action( 'wpo_wcpdf_after_customer_notes', $this->type, $this->order ); ?>
118
+ </div>
119
+ </td>
120
+ <td class="no-borders" colspan="2">
121
+ <table class="totals">
122
+ <tfoot>
123
+ <?php foreach( $this->get_woocommerce_totals() as $key => $total ) : ?>
124
+ <tr class="<?php echo $key; ?>">
125
+ <td class="no-borders"></td>
126
+ <th class="description"><?php echo $total['label']; ?></th>
127
+ <td class="price"><span class="totals-price"><?php echo $total['value']; ?></span></td>
128
+ </tr>
129
+ <?php endforeach; ?>
130
+ </tfoot>
131
+ </table>
132
+ </td>
133
+ </tr>
134
+ </tfoot>
135
+ </table>
136
+
137
+ <?php do_action( 'wpo_wcpdf_after_order_details', $this->type, $this->order ); ?>
138
+
139
+ <?php if ( $this->get_footer() ): ?>
140
+ <div id="footer">
141
+ <?php $this->footer(); ?>
142
+ </div><!-- #letter-footer -->
143
+ <?php endif; ?>
144
+ <?php do_action( 'wpo_wcpdf_after_document', $this->type, $this->order ); ?>
templates/Simple/packing-slip.php CHANGED
@@ -1,113 +1,113 @@
1
- <?php do_action( 'wpo_wcpdf_before_document', $this->type, $this->order ); ?>
2
-
3
- <table class="head container">
4
- <tr>
5
- <td class="header">
6
- <?php
7
- if( $this->has_header_logo() ) {
8
- $this->header_logo();
9
- } else {
10
- echo apply_filters( 'wpo_wcpdf_packing_slip_title', __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ) );
11
- }
12
- ?>
13
- </td>
14
- <td class="shop-info">
15
- <div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
16
- <div class="shop-address"><?php $this->shop_address(); ?></div>
17
- </td>
18
- </tr>
19
- </table>
20
-
21
- <h1 class="document-type-label">
22
- <?php if( $this->has_header_logo() ) echo apply_filters( 'wpo_wcpdf_packing_slip_title', __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ) ); ?>
23
- </h1>
24
-
25
- <?php do_action( 'wpo_wcpdf_after_document_label', $this->type, $this->order ); ?>
26
-
27
- <table class="order-data-addresses">
28
- <tr>
29
- <td class="address shipping-address">
30
- <!-- <h3><?php _e( 'Shipping Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3> -->
31
- <?php $this->shipping_address(); ?>
32
- <?php if ( isset($this->settings['display_email']) ) { ?>
33
- <div class="billing-email"><?php $this->billing_email(); ?></div>
34
- <?php } ?>
35
- <?php if ( isset($this->settings['display_phone']) ) { ?>
36
- <div class="billing-phone"><?php $this->billing_phone(); ?></div>
37
- <?php } ?>
38
- </td>
39
- <td class="address billing-address">
40
- <?php if ( isset($this->settings['display_billing_address']) && $this->ships_to_different_address()) { ?>
41
- <h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
42
- <?php $this->billing_address(); ?>
43
- <?php } ?>
44
- </td>
45
- <td class="order-data">
46
- <table>
47
- <?php do_action( 'wpo_wcpdf_before_order_data', $this->type, $this->order ); ?>
48
- <tr class="order-number">
49
- <th><?php _e( 'Order Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
50
- <td><?php $this->order_number(); ?></td>
51
- </tr>
52
- <tr class="order-date">
53
- <th><?php _e( 'Order Date:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
54
- <td><?php $this->order_date(); ?></td>
55
- </tr>
56
- <tr class="shipping-method">
57
- <th><?php _e( 'Shipping Method:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
58
- <td><?php $this->shipping_method(); ?></td>
59
- </tr>
60
- <?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>
61
- </table>
62
- </td>
63
- </tr>
64
- </table>
65
-
66
- <?php do_action( 'wpo_wcpdf_before_order_details', $this->type, $this->order ); ?>
67
-
68
- <table class="order-details">
69
- <thead>
70
- <tr>
71
- <th class="product"><?php _e('Product', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
72
- <th class="quantity"><?php _e('Quantity', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
73
- </tr>
74
- </thead>
75
- <tbody>
76
- <?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
77
- <tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
78
- <td class="product">
79
- <?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
80
- <span class="item-name"><?php echo $item['name']; ?></span>
81
- <?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
82
- <span class="item-meta"><?php echo $item['meta']; ?></span>
83
- <dl class="meta">
84
- <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
85
- <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'SKU:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
86
- <?php if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif; ?>
87
- </dl>
88
- <?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
89
- </td>
90
- <td class="quantity"><?php echo $item['quantity']; ?></td>
91
- </tr>
92
- <?php endforeach; endif; ?>
93
- </tbody>
94
- </table>
95
-
96
- <?php do_action( 'wpo_wcpdf_after_order_details', $this->type, $this->order ); ?>
97
-
98
- <?php do_action( 'wpo_wcpdf_before_customer_notes', $this->type, $this->order ); ?>
99
- <div class="customer-notes">
100
- <?php if ( $this->get_shipping_notes() ) : ?>
101
- <h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
102
- <?php $this->shipping_notes(); ?>
103
- <?php endif; ?>
104
- </div>
105
- <?php do_action( 'wpo_wcpdf_after_customer_notes', $this->type, $this->order ); ?>
106
-
107
- <?php if ( $this->get_footer() ): ?>
108
- <div id="footer">
109
- <?php $this->footer(); ?>
110
- </div><!-- #letter-footer -->
111
- <?php endif; ?>
112
-
113
  <?php do_action( 'wpo_wcpdf_after_document', $this->type, $this->order ); ?>
1
+ <?php do_action( 'wpo_wcpdf_before_document', $this->type, $this->order ); ?>
2
+
3
+ <table class="head container">
4
+ <tr>
5
+ <td class="header">
6
+ <?php
7
+ if( $this->has_header_logo() ) {
8
+ $this->header_logo();
9
+ } else {
10
+ echo $this->get_title();
11
+ }
12
+ ?>
13
+ </td>
14
+ <td class="shop-info">
15
+ <div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
16
+ <div class="shop-address"><?php $this->shop_address(); ?></div>
17
+ </td>
18
+ </tr>
19
+ </table>
20
+
21
+ <h1 class="document-type-label">
22
+ <?php if( $this->has_header_logo() ) echo $this->get_title(); ?>
23
+ </h1>
24
+
25
+ <?php do_action( 'wpo_wcpdf_after_document_label', $this->type, $this->order ); ?>
26
+
27
+ <table class="order-data-addresses">
28
+ <tr>
29
+ <td class="address shipping-address">
30
+ <!-- <h3><?php _e( 'Shipping Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3> -->
31
+ <?php $this->shipping_address(); ?>
32
+ <?php if ( isset($this->settings['display_email']) ) { ?>
33
+ <div class="billing-email"><?php $this->billing_email(); ?></div>
34
+ <?php } ?>
35
+ <?php if ( isset($this->settings['display_phone']) ) { ?>
36
+ <div class="billing-phone"><?php $this->billing_phone(); ?></div>
37
+ <?php } ?>
38
+ </td>
39
+ <td class="address billing-address">
40
+ <?php if ( isset($this->settings['display_billing_address']) && $this->ships_to_different_address()) { ?>
41
+ <h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
42
+ <?php $this->billing_address(); ?>
43
+ <?php } ?>
44
+ </td>
45
+ <td class="order-data">
46
+ <table>
47
+ <?php do_action( 'wpo_wcpdf_before_order_data', $this->type, $this->order ); ?>
48
+ <tr class="order-number">
49
+ <th><?php _e( 'Order Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
50
+ <td><?php $this->order_number(); ?></td>
51
+ </tr>
52
+ <tr class="order-date">
53
+ <th><?php _e( 'Order Date:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
54
+ <td><?php $this->order_date(); ?></td>
55
+ </tr>
56
+ <tr class="shipping-method">
57
+ <th><?php _e( 'Shipping Method:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
58
+ <td><?php $this->shipping_method(); ?></td>
59
+ </tr>
60
+ <?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>
61
+ </table>
62
+ </td>
63
+ </tr>
64
+ </table>
65
+
66
+ <?php do_action( 'wpo_wcpdf_before_order_details', $this->type, $this->order ); ?>
67
+
68
+ <table class="order-details">
69
+ <thead>
70
+ <tr>
71
+ <th class="product"><?php _e('Product', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
72
+ <th class="quantity"><?php _e('Quantity', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
73
+ </tr>
74
+ </thead>
75
+ <tbody>
76
+ <?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
77
+ <tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
78
+ <td class="product">
79
+ <?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
80
+ <span class="item-name"><?php echo $item['name']; ?></span>
81
+ <?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
82
+ <span class="item-meta"><?php echo $item['meta']; ?></span>
83
+ <dl class="meta">
84
+ <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
85
+ <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'SKU:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
86
+ <?php if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif; ?>
87
+ </dl>
88
+ <?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
89
+ </td>
90
+ <td class="quantity"><?php echo $item['quantity']; ?></td>
91
+ </tr>
92
+ <?php endforeach; endif; ?>
93
+ </tbody>
94
+ </table>
95
+
96
+ <?php do_action( 'wpo_wcpdf_after_order_details', $this->type, $this->order ); ?>
97
+
98
+ <?php do_action( 'wpo_wcpdf_before_customer_notes', $this->type, $this->order ); ?>
99
+ <div class="customer-notes">
100
+ <?php if ( $this->get_shipping_notes() ) : ?>
101
+ <h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
102
+ <?php $this->shipping_notes(); ?>
103
+ <?php endif; ?>
104
+ </div>
105
+ <?php do_action( 'wpo_wcpdf_after_customer_notes', $this->type, $this->order ); ?>
106
+
107
+ <?php if ( $this->get_footer() ): ?>
108
+ <div id="footer">
109
+ <?php $this->footer(); ?>
110
+ </div><!-- #letter-footer -->
111
+ <?php endif; ?>
112
+
113
  <?php do_action( 'wpo_wcpdf_after_document', $this->type, $this->order ); ?>
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: http://www.wpovernight.com
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
- * Version: 2.1.0
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
 
22
  class WPO_WCPDF {
23
 
24
- public $version = '2.1.0';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
 
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: http://www.wpovernight.com
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
+ * Version: 2.1.1
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.1.1';
25
  public $plugin_basename;
26
  public $legacy_mode;
27