WooCommerce PDF Invoices & Packing Slips - Version 2.11.3

Version Description

  • Fix: Extended currency symbol support in bulk documents
  • Fix: Prevent copying packing slip and other document data for renewal orders (WooCommerce Subscriptions)
  • Marked tested up to WooCommerce 6.0
Download this release

Release Info

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

Code changes from version 2.11.2 to 2.11.3

includes/compatibility/class-wcpdf-compatibility-third-party-plugins.php CHANGED
@@ -22,7 +22,8 @@ class Third_Party_Plugins {
22
  if ( version_compare( \WC_Subscriptions::$version, '2.0', '<' ) ) {
23
  add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'woocommerce_subscriptions_renewal_order_created' ), 10, 4 );
24
  } else {
25
- add_action( 'wcs_renewal_order_created', array( $this, 'wcs_renewal_order_created' ), 10, 2 );
 
26
  }
27
  }
28
 
@@ -62,11 +63,6 @@ class Third_Party_Plugins {
62
  return $renewal_order;
63
  }
64
 
65
- public function wcs_renewal_order_created ( $renewal_order, $subscription ) {
66
- $this->reset_invoice_data( $renewal_order );
67
- return $renewal_order;
68
- }
69
-
70
  public function reset_invoice_data ( $order ) {
71
  if ( ! is_object( $order ) ) {
72
  $order = wc_get_order( $order );
@@ -79,6 +75,41 @@ class Third_Party_Plugins {
79
  WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
80
  }
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  /**
83
  * WooCommerce Product Bundles
84
  * @param string $classes CSS classes for item row (tr)
22
  if ( version_compare( \WC_Subscriptions::$version, '2.0', '<' ) ) {
23
  add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'woocommerce_subscriptions_renewal_order_created' ), 10, 4 );
24
  } else {
25
+ add_action( 'wcs_renewal_order_meta', array( $this, 'wcs_renewal_order_meta' ), 10, 3 );
26
+ add_action( 'wcs_resubscribe_order_meta', array( $this, 'wcs_renewal_order_meta' ), 10, 3 );
27
  }
28
  }
29
 
63
  return $renewal_order;
64
  }
65
 
 
 
 
 
 
66
  public function reset_invoice_data ( $order ) {
67
  if ( ! is_object( $order ) ) {
68
  $order = wc_get_order( $order );
75
  WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
76
  }
77
 
78
+ /**
79
+ * Removes documents meta from WooCommerce Subscriptions renewal order
80
+ */
81
+ public function wcs_renewal_order_meta ( $meta, $to_order, $from_order ) {
82
+ if ( ! empty( $meta ) ) {
83
+ $documents = WPO_WCPDF()->documents->get_documents();
84
+ $documents_meta = array();
85
+
86
+ foreach ( $documents as $document ) {
87
+ $document_data_keys = apply_filters( 'wpo_wcpdf_delete_document_data_keys', array(
88
+ 'settings',
89
+ 'date',
90
+ 'date_formatted',
91
+ 'number',
92
+ 'number_data',
93
+ 'notes',
94
+ 'exists',
95
+ ), $document );
96
+
97
+ $document_meta = array_map( function ( $data_key ) use ( $document ) {
98
+ return "_wcpdf_{$document->slug}_{$data_key}";
99
+ }, $document_data_keys );
100
+ $document_meta[] = "_wcpdf_formatted_{$document->slug}_number"; // legacy meta key
101
+ $documents_meta = array_merge( $documents_meta, $document_meta );
102
+ }
103
+
104
+ foreach ( $meta as $key => $value ) {
105
+ if ( in_array( $value['meta_key'], $documents_meta ) ) {
106
+ unset( $meta[$key] );
107
+ }
108
+ }
109
+ }
110
+ return $meta;
111
+ }
112
+
113
  /**
114
  * WooCommerce Product Bundles
115
  * @param string $classes CSS classes for item row (tr)
includes/documents/class-wcpdf-bulk-document.php CHANGED
@@ -54,6 +54,10 @@ class Bulk_Document {
54
  public function get_pdf() {
55
  do_action( 'wpo_wcpdf_before_pdf', $this->get_type(), $this );
56
 
 
 
 
 
57
  $html = $this->get_html();
58
  $pdf_settings = array(
59
  'paper_size' => apply_filters( 'wpo_wcpdf_paper_format', $this->wrapper_document->get_setting( 'paper_size', 'A4' ), $this->get_type(), $this ),
@@ -65,11 +69,19 @@ class Bulk_Document {
65
 
66
  do_action( 'wpo_wcpdf_after_pdf', $this->get_type(), $this );
67
 
 
 
 
68
  return $pdf;
69
  }
70
 
71
  public function get_html() {
72
  do_action( 'wpo_wcpdf_before_html', $this->get_type(), $this );
 
 
 
 
 
73
  $html_content = array();
74
  foreach ( $this->order_ids as $key => $order_id ) {
75
  do_action( 'wpo_wcpdf_process_template_order', $this->get_type(), $order_id );
@@ -85,6 +97,9 @@ class Bulk_Document {
85
  $this->wrapper_document = wcpdf_get_document( $this->get_type(), null );
86
  $html = $this->wrapper_document->wrap_html_content( $this->merge_documents( $html_content ) );
87
  do_action( 'wpo_wcpdf_after_html', $this->get_type(), $this );
 
 
 
88
 
89
  return $html;
90
  }
@@ -121,6 +136,29 @@ class Bulk_Document {
121
  return $filename;
122
  }
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  endif; // class_exists
54
  public function get_pdf() {
55
  do_action( 'wpo_wcpdf_before_pdf', $this->get_type(), $this );
56
 
57
+ // temporarily apply filters that need to be removed again after the pdf is generated
58
+ $pdf_filters = apply_filters( 'wpo_wcpdf_pdf_filters', array() );
59
+ $this->add_filters( $pdf_filters );
60
+
61
  $html = $this->get_html();
62
  $pdf_settings = array(
63
  'paper_size' => apply_filters( 'wpo_wcpdf_paper_format', $this->wrapper_document->get_setting( 'paper_size', 'A4' ), $this->get_type(), $this ),
69
 
70
  do_action( 'wpo_wcpdf_after_pdf', $this->get_type(), $this );
71
 
72
+ // remove temporary filters
73
+ $this->remove_filters( $pdf_filters );
74
+
75
  return $pdf;
76
  }
77
 
78
  public function get_html() {
79
  do_action( 'wpo_wcpdf_before_html', $this->get_type(), $this );
80
+
81
+ // temporarily apply filters that need to be removed again after the html is generated
82
+ $html_filters = apply_filters( 'wpo_wcpdf_html_filters', array() );
83
+ $this->add_filters( $html_filters );
84
+
85
  $html_content = array();
86
  foreach ( $this->order_ids as $key => $order_id ) {
87
  do_action( 'wpo_wcpdf_process_template_order', $this->get_type(), $order_id );
97
  $this->wrapper_document = wcpdf_get_document( $this->get_type(), null );
98
  $html = $this->wrapper_document->wrap_html_content( $this->merge_documents( $html_content ) );
99
  do_action( 'wpo_wcpdf_after_html', $this->get_type(), $this );
100
+
101
+ // remove temporary filters
102
+ $this->remove_filters( $html_filters );
103
 
104
  return $html;
105
  }
136
  return $filename;
137
  }
138
 
139
+ protected function add_filters( $filters ) {
140
+ foreach ( $filters as $filter ) {
141
+ $filter = $this->normalize_filter_args( $filter );
142
+ add_filter( $filter['hook_name'], $filter['callback'], $filter['priority'], $filter['accepted_args'] );
143
+ }
144
+ }
145
+
146
+ protected function remove_filters( $filters ) {
147
+ foreach ( $filters as $filter ) {
148
+ $filter = $this->normalize_filter_args( $filter );
149
+ remove_filter( $filter['hook_name'], $filter['callback'], $filter['priority'] );
150
+ }
151
+ }
152
+
153
+ protected function normalize_filter_args( $filter ) {
154
+ $filter = array_values( $filter );
155
+ $hook_name = $filter[0];
156
+ $callback = $filter[1];
157
+ $priority = isset( $filter[2] ) ? $filter[2] : 10;
158
+ $accepted_args = isset( $filter[3] ) ? $filter[3] : 1;
159
+ return compact( 'hook_name', 'callback', 'priority', 'accepted_args' );
160
+ }
161
+
162
  }
163
 
164
  endif; // class_exists
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: 5.8
7
  Requires PHP: 7.1
8
- Stable tag: 2.11.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -102,6 +102,11 @@ There's a setting on the Status tab of the settings page that allows you to togg
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
105
  = 2.11.2 =
106
  * New: filter and fallback for the default settings tab
107
  * Tweak: Improved font synchronization during plugin updates
5
  Requires at least: 3.5
6
  Tested up to: 5.8
7
  Requires PHP: 7.1
8
+ Stable tag: 2.11.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
102
 
103
  == Changelog ==
104
 
105
+ = 2.11.3 =
106
+ * Fix: Extended currency symbol support in bulk documents
107
+ * Fix: Prevent copying packing slip and other document data for renewal orders (WooCommerce Subscriptions)
108
+ * Marked tested up to WooCommerce 6.0
109
+
110
  = 2.11.2 =
111
  * New: filter and fallback for the default settings tab
112
  * Tweak: Improved font synchronization during plugin updates
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
- * Version: 2.11.2
7
  * Author: WP Overnight
8
  * Author URI: https://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: https://opensource.org/licenses/gpl-license.php
11
  * Text Domain: woocommerce-pdf-invoices-packing-slips
12
  * WC requires at least: 2.2.0
13
- * WC tested up to: 5.9.0
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
 
22
  class WPO_WCPDF {
23
 
24
- public $version = '2.11.2';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
  public $legacy_textdomain;
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
+ * Version: 2.11.3
7
  * Author: WP Overnight
8
  * Author URI: https://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: https://opensource.org/licenses/gpl-license.php
11
  * Text Domain: woocommerce-pdf-invoices-packing-slips
12
  * WC requires at least: 2.2.0
13
+ * WC tested up to: 6.0.0
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.11.3';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
  public $legacy_textdomain;