WooCommerce PDF Invoices & Packing Slips - Version 1.4.12

Version Description

  • Fix: issues with post parent objects (WC2.1 and older)
Download this release

Release Info

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

Code changes from version 1.4.11 to 1.4.12

readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: pomegranate
3
  Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
4
  Requires at least: 3.5
5
  Tested up to: 4.0
6
- Stable tag: 1.4.11
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -188,6 +188,9 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
188
 
189
  == Changelog ==
190
 
 
 
 
191
  = 1.4.11 =
192
  * Small fix: bulk actions for specific i18n configurations
193
  * Tweak: total row key used as class in Simple template
3
  Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
4
  Requires at least: 3.5
5
  Tested up to: 4.0
6
+ Stable tag: 1.4.12
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
188
 
189
  == Changelog ==
190
 
191
+ = 1.4.12 =
192
+ * Fix: issues with post parent objects (WC2.1 and older)
193
+
194
  = 1.4.11 =
195
  * Small fix: bulk actions for specific i18n configurations
196
  * Tweak: total row key used as class in Simple template
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: 1.4.11
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -192,12 +192,12 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
192
  return apply_filters( 'wpo_wcpdf_billing_address', $address );
193
  }
194
 
195
- if ( !$address && $this->export->order->post->post_parent > 0 ) {
196
  // try parent address
197
 
198
  // temporarily switch order to make all filters / order calls work correctly
199
  $current_order = $this->export->order;
200
- $this->export->order = new WC_Order( $this->export->order->post->post_parent );
201
  $address = apply_filters( 'wpo_wcpdf_billing_address', $this->export->order->get_formatted_billing_address() );
202
  // switch back & unset
203
  $this->export->order = $current_order;
@@ -219,9 +219,9 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
219
  $billing_email = $this->export->order->billing_email;
220
 
221
 
222
- if ( !$billing_email && $this->export->order->post->post_parent > 0 ) {
223
  // try parent
224
- $billing_email = get_post_meta( $this->export->order->post->post_parent, '_billing_email', true );
225
  }
226
 
227
  return apply_filters( 'wpo_wcpdf_billing_email', $billing_email );
@@ -236,9 +236,9 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
236
  public function get_billing_phone() {
237
  $billing_phone = $this->export->order->billing_phone;
238
 
239
- if ( !$billing_phone && $this->export->order->post->post_parent > 0 ) {
240
  // try parent
241
- $billing_phone = get_post_meta( $this->export->order->post->post_parent, '_billing_phone', true );
242
  }
243
 
244
  return apply_filters( 'wpo_wcpdf_billing_phone', $billing_phone );
@@ -255,12 +255,12 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
255
  return apply_filters( 'wpo_wcpdf_shipping_address', $address );
256
  }
257
 
258
- if ( !$address && $this->export->order->post->post_parent > 0 ) {
259
  // try parent address
260
 
261
  // temporarily switch order to make all filters / order calls work correctly
262
  $current_order = $this->export->order;
263
- $this->export->order = new WC_Order( $this->export->order->post->post_parent );
264
  $address = apply_filters( 'wpo_wcpdf_shipping_address', $this->export->order->get_formatted_shipping_address() );
265
  // switch back & unset
266
  $this->export->order = $current_order;
@@ -281,9 +281,9 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
281
  public function get_custom_field( $field_name ) {
282
  $custom_field = get_post_meta($this->export->order->id,$field_name,true);
283
 
284
- if ( !$custom_field && $this->export->order->post->post_parent > 0 ) {
285
  // try parent
286
- $custom_field = get_post_meta( $this->export->order->post->post_parent, $field_name, true );
287
  }
288
 
289
  return apply_filters( 'wpo_wcpdf_billing_custom_field', $custom_field );
@@ -378,8 +378,8 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
378
  */
379
  public function get_order_number() {
380
  // try parent first
381
- if ( $this->export->order->post->post_parent > 0 && $this->export->order->post->post_type == 'shop_order_refund' ) {
382
- $parent_order = new WC_Order( $this->export->order->post->post_parent );
383
  $order_number = $parent_order->get_order_number();
384
  } else {
385
  $order_number = $this->export->order->get_order_number();
@@ -409,8 +409,8 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
409
  * Return/Show the order date
410
  */
411
  public function get_order_date() {
412
- if ( $this->export->order->post->post_parent > 0 && $this->export->order->post->post_type == 'shop_order_refund' ) {
413
- $parent_order = new WC_Order( $this->export->order->post->post_parent );
414
  $date = $parent_order->order_date;
415
  } else {
416
  $date = $this->export->order->order_date;
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: 1.4.12
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
192
  return apply_filters( 'wpo_wcpdf_billing_address', $address );
193
  }
194
 
195
+ if ( !$address && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
196
  // try parent address
197
 
198
  // temporarily switch order to make all filters / order calls work correctly
199
  $current_order = $this->export->order;
200
+ $this->export->order = new WC_Order( $parent_order_id );
201
  $address = apply_filters( 'wpo_wcpdf_billing_address', $this->export->order->get_formatted_billing_address() );
202
  // switch back & unset
203
  $this->export->order = $current_order;
219
  $billing_email = $this->export->order->billing_email;
220
 
221
 
222
+ if ( !$billing_email && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
223
  // try parent
224
+ $billing_email = get_post_meta( $parent_order_id, '_billing_email', true );
225
  }
226
 
227
  return apply_filters( 'wpo_wcpdf_billing_email', $billing_email );
236
  public function get_billing_phone() {
237
  $billing_phone = $this->export->order->billing_phone;
238
 
239
+ if ( !$billing_phone && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
240
  // try parent
241
+ $billing_phone = get_post_meta( $parent_order_id, '_billing_phone', true );
242
  }
243
 
244
  return apply_filters( 'wpo_wcpdf_billing_phone', $billing_phone );
255
  return apply_filters( 'wpo_wcpdf_shipping_address', $address );
256
  }
257
 
258
+ if ( !$address && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
259
  // try parent address
260
 
261
  // temporarily switch order to make all filters / order calls work correctly
262
  $current_order = $this->export->order;
263
+ $this->export->order = new WC_Order( $parent_order_id );
264
  $address = apply_filters( 'wpo_wcpdf_shipping_address', $this->export->order->get_formatted_shipping_address() );
265
  // switch back & unset
266
  $this->export->order = $current_order;
281
  public function get_custom_field( $field_name ) {
282
  $custom_field = get_post_meta($this->export->order->id,$field_name,true);
283
 
284
+ if ( !$custom_field && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
285
  // try parent
286
+ $custom_field = get_post_meta( $parent_order_id, $field_name, true );
287
  }
288
 
289
  return apply_filters( 'wpo_wcpdf_billing_custom_field', $custom_field );
378
  */
379
  public function get_order_number() {
380
  // try parent first
381
+ if ( get_post_type( $this->export->order->id ) == 'shop_order_refund' && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
382
+ $parent_order = new WC_Order( $parent_order_id );
383
  $order_number = $parent_order->get_order_number();
384
  } else {
385
  $order_number = $this->export->order->get_order_number();
409
  * Return/Show the order date
410
  */
411
  public function get_order_date() {
412
+ if ( get_post_type( $this->export->order->id ) == 'shop_order_refund' && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
413
+ $parent_order = new WC_Order( $parent_order_id );
414
  $date = $parent_order->order_date;
415
  } else {
416
  $date = $this->export->order->order_date;