WooCommerce PDF Invoices & Packing Slips - Version 1.5.3

Version Description

  • Feature: add original order date value to order date filter
  • Feature: Work with line_tax_data when available
  • Feature: pass item_id to items
  • Tweak: later check for woocommerce active
  • Fix: do not try to validate empty settings (Status page settings)
  • Translations: Fixed Dutch typo
Download this release

Release Info

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

Code changes from version 1.5.2 to 1.5.3

includes/class-wcpdf-export.php CHANGED
@@ -656,9 +656,12 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
656
  $data_list = array();
657
 
658
  if( sizeof( $items ) > 0 ) {
659
- foreach ( $items as $item ) {
660
  // Array with data for the pdf template
661
  $data = array();
 
 
 
662
 
663
  // Set the id
664
  $data['product_id'] = $item['product_id'];
@@ -676,7 +679,9 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
676
  $data['single_line_total'] = $this->wc_price( $item['line_total'] / $quantity_divider );
677
  $data['line_tax'] = $this->wc_price( $item['line_tax'] );
678
  $data['single_line_tax'] = $this->wc_price( $item['line_tax'] / $quantity_divider );
679
- $data['tax_rates'] = $this->get_tax_rate( $item['tax_class'], $item['line_total'], $item['line_tax'] );
 
 
680
 
681
  // Set the line subtotal (=before discount)
682
  $data['line_subtotal'] = $this->wc_price( $item['line_subtotal'] );
@@ -777,13 +782,29 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
777
  * @param string $tax_class tax class slug
778
  * @return string $tax_rates imploded list of tax rates
779
  */
780
- public function get_tax_rate( $tax_class, $line_total, $line_tax ) {
781
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
782
- // WC 2.1 or newer is used
783
- if ( $line_tax == 0 ) {
784
- return '-'; // no need to determine tax rate...
 
 
 
 
 
 
 
 
 
785
  }
786
 
 
 
 
 
 
 
 
787
  // if (empty($tax_class))
788
  // $tax_class = 'standard';// does not appear to work anymore - get_rates does accept an empty tax_class though!
789
 
@@ -807,7 +828,7 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
807
 
808
  $tax_rates = implode(' ,', $tax_rates );
809
  } else {
810
- // Backwards compatibility: calculate tax from line items
811
  if ( $line_total != 0) {
812
  $tax_rates = round( ($line_tax / $line_total)*100, 1 ).' %';
813
  } else {
656
  $data_list = array();
657
 
658
  if( sizeof( $items ) > 0 ) {
659
+ foreach ( $items as $item_id => $item ) {
660
  // Array with data for the pdf template
661
  $data = array();
662
+
663
+ // Set the item_id
664
+ $data['item_id'] = $item_id;
665
 
666
  // Set the id
667
  $data['product_id'] = $item['product_id'];
679
  $data['single_line_total'] = $this->wc_price( $item['line_total'] / $quantity_divider );
680
  $data['line_tax'] = $this->wc_price( $item['line_tax'] );
681
  $data['single_line_tax'] = $this->wc_price( $item['line_tax'] / $quantity_divider );
682
+
683
+ $line_tax_data = maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' );
684
+ $data['tax_rates'] = $this->get_tax_rate( $item['tax_class'], $item['line_total'], $item['line_tax'], $line_tax_data );
685
 
686
  // Set the line subtotal (=before discount)
687
  $data['line_subtotal'] = $this->wc_price( $item['line_subtotal'] );
782
  * @param string $tax_class tax class slug
783
  * @return string $tax_rates imploded list of tax rates
784
  */
785
+ public function get_tax_rate( $tax_class, $line_total, $line_tax, $line_tax_data = '' ) {
786
+ if ( $line_tax == 0 ) {
787
+ return '-'; // no need to determine tax rate...
788
+ }
789
+
790
+ // first try the easy wc2.2 way, using line_tax_data
791
+ if ( !empty( $line_tax_data ) ) {
792
+ $tax_rates = array();
793
+
794
+ $line_taxes = $line_tax_data['total'];
795
+ foreach ( $line_taxes as $tax_id => $tax ) {
796
+ if ( !empty($tax) && $tax != 0 ) {
797
+ $tax_rates[] = $this->get_tax_rate_by_id( $tax_id ) . ' %';
798
+ }
799
  }
800
 
801
+ $tax_rates = implode(' ,', $tax_rates );
802
+ return $tax_rates;
803
+ }
804
+
805
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 && !apply_filters( 'wpo_wcpdf_calculate_tax_rate', false ) ) {
806
+ // WC 2.1 or newer is used
807
+
808
  // if (empty($tax_class))
809
  // $tax_class = 'standard';// does not appear to work anymore - get_rates does accept an empty tax_class though!
810
 
828
 
829
  $tax_rates = implode(' ,', $tax_rates );
830
  } else {
831
+ // Backwards compatibility/fallback: calculate tax from line items
832
  if ( $line_total != 0) {
833
  $tax_rates = round( ($line_tax / $line_total)*100, 1 ).' %';
834
  } else {
includes/class-wcpdf-settings.php CHANGED
@@ -953,6 +953,10 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
953
  public function validate_options( $input ) {
954
  // Create our array for storing the validated options.
955
  $output = array();
 
 
 
 
956
 
957
  // Loop through each of the incoming options.
958
  foreach ( $input as $key => $value ) {
953
  public function validate_options( $input ) {
954
  // Create our array for storing the validated options.
955
  $output = array();
956
+
957
+ if (empty($input) || !is_array($input)) {
958
+ return $input;
959
+ }
960
 
961
  // Loop through each of the incoming options.
962
  foreach ( $input as $key => $value ) {
includes/dompdf-status.php CHANGED
@@ -163,6 +163,10 @@ $permissions = array(
163
  ),
164
  );
165
 
 
 
 
 
166
  ?>
167
  <br />
168
  <h3 id="system">Permissions</h3>
163
  ),
164
  );
165
 
166
+ if ( isset($wpo_wcpdf->export->debug_settings['old_tmp']) ) {
167
+ unset($permissions['WCPDF_TEMP_DIR']);
168
+ }
169
+
170
  ?>
171
  <br />
172
  <h3 id="system">Permissions</h3>
languages/wpo_wcpdf-nl_NL.mo CHANGED
Binary file
languages/wpo_wcpdf-nl_NL.po CHANGED
@@ -3,7 +3,7 @@ msgstr ""
3
  "Project-Id-Version: WooCommerce PDF Invoices & Packing Slips\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2014-12-11 16:50+0100\n"
6
- "PO-Revision-Date: 2014-12-11 16:55+0100\n"
7
  "Last-Translator: Ewout Fernhout <chocolade@extrapuur.nl>\n"
8
  "Language-Team: WP Overnight <support@wpovernight.com>\n"
9
  "Language: nl_NL\n"
@@ -16,7 +16,7 @@ msgstr ""
16
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
  "X-Poedit-Basepath: ../\n"
18
  "X-Textdomain-Support: yes\n"
19
- "X-Generator: Poedit 1.7.1\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
 
22
  #: includes/class-wcpdf-export.php:326 includes/class-wcpdf-export.php:331
@@ -292,7 +292,7 @@ msgstr ""
292
 
293
  #: includes/class-wcpdf-settings.php:567
294
  msgid "Use old tmp folder"
295
- msgstr "Gebruik de oude tml folder"
296
 
297
  #: includes/class-wcpdf-settings.php:574
298
  msgid ""
3
  "Project-Id-Version: WooCommerce PDF Invoices & Packing Slips\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2014-12-11 16:50+0100\n"
6
+ "PO-Revision-Date: 2015-01-22 10:45+0100\n"
7
  "Last-Translator: Ewout Fernhout <chocolade@extrapuur.nl>\n"
8
  "Language-Team: WP Overnight <support@wpovernight.com>\n"
9
  "Language: nl_NL\n"
16
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
  "X-Poedit-Basepath: ../\n"
18
  "X-Textdomain-Support: yes\n"
19
+ "X-Generator: Poedit 1.7.3\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
 
22
  #: includes/class-wcpdf-export.php:326 includes/class-wcpdf-export.php:331
292
 
293
  #: includes/class-wcpdf-settings.php:567
294
  msgid "Use old tmp folder"
295
+ msgstr "Gebruik de oude tmp folder"
296
 
297
  #: includes/class-wcpdf-settings.php:574
298
  msgid ""
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.1
6
- Stable tag: 1.5.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -248,6 +248,14 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
248
 
249
  == Changelog ==
250
 
 
 
 
 
 
 
 
 
251
  = 1.5.2 =
252
  * Fix: fatal error when trying to activate with WooCommerce not installed yet.
253
  * Tweak: indentation fix on the Simple template
@@ -467,5 +475,5 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
467
 
468
  == Upgrade Notice ==
469
 
470
- = 1.5.2 =
471
  Version 1.5 changes where temporary files are stored - everything is now stored centrally in the WP uploads folder. For backwards compatibility, this feature is turned off by default, but we recommend to use the new folders. Check the plugin Status panel for more information!
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.1
6
+ Stable tag: 1.5.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
248
 
249
  == Changelog ==
250
 
251
+ = 1.5.3 =
252
+ * Feature: add original order date value to order date filter
253
+ * Feature: Work with line_tax_data when available
254
+ * Feature: pass item_id to items
255
+ * Tweak: later check for woocommerce active
256
+ * Fix: do not try to validate empty settings (Status page settings)
257
+ * Translations: Fixed Dutch typo
258
+
259
  = 1.5.2 =
260
  * Fix: fatal error when trying to activate with WooCommerce not installed yet.
261
  * Tweak: indentation fix on the Simple template
475
 
476
  == Upgrade Notice ==
477
 
478
+ = 1.5.3 =
479
  Version 1.5 changes where temporary files are stored - everything is now stored centrally in the WP uploads folder. For backwards compatibility, this feature is turned off by default, but we recommend to use the new folders. Check the plugin Status panel for more information!
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.5.2
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -33,7 +33,7 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
33
  self::$plugin_basename = plugin_basename(__FILE__);
34
  self::$plugin_url = plugin_dir_url(self::$plugin_basename);
35
  self::$plugin_path = trailingslashit(dirname(__FILE__));
36
- self::$version = '1.5.2';
37
 
38
  // load the localisation & classes
39
  add_action( 'plugins_loaded', array( $this, 'translations' ) ); // or use init?
@@ -514,13 +514,13 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
514
  public function get_order_date() {
515
  if ( get_post_type( $this->export->order->id ) == 'shop_order_refund' && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
516
  $parent_order = new WC_Order( $parent_order_id );
517
- $date = $parent_order->order_date;
518
  } else {
519
- $date = $this->export->order->order_date;
520
  }
521
 
522
- $date = date_i18n( get_option( 'date_format' ), strtotime( $date ) );
523
- return apply_filters( 'wpo_wcpdf_order_date', $date );
524
  }
525
  public function order_date() {
526
  echo $this->get_order_date();
@@ -600,14 +600,15 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
600
  */
601
  public function get_order_shipping( $tax = 'excl' ) { // set $tax to 'incl' to include tax
602
  if ($tax == 'excl' ) {
603
- $shipping_costs = woocommerce_price ( $this->export->order->order_shipping );
604
  } else {
605
- $shipping_costs = woocommerce_price ( $this->export->order->order_shipping + $this->export->order->order_shipping_tax );
606
  }
607
 
608
  $shipping = array (
609
  'label' => __('Shipping', 'wpo_wcpdf'),
610
  'value' => $shipping_costs,
 
611
  );
612
  return apply_filters( 'wpo_wcpdf_order_shipping', $shipping );
613
  }
@@ -671,15 +672,16 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
671
  if ( $wcfees = $this->export->order->get_fees() ) {
672
  foreach( $wcfees as $id => $fee ) {
673
  if ($tax == 'excl' ) {
674
- $fee_price = woocommerce_price( $fee['line_total'] );
675
  } else {
676
- $fee_price = woocommerce_price( $fee['line_total'] + $fee['line_tax'] );
677
  }
678
 
679
-
680
  $fees[ $id ] = array(
681
- 'label' => $fee['name'],
682
- 'value' => $fee_price
 
 
683
  );
684
  }
685
  return $fees;
@@ -696,7 +698,7 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
696
  foreach ( $this->export->order->get_taxes() as $key => $tax ) {
697
  $taxes[ $key ] = array(
698
  'label' => isset( $tax[ 'label' ] ) ? $tax[ 'label' ] : $tax[ 'name' ],
699
- 'value' => woocommerce_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) ),
700
  'rate_id' => $tax['rate_id'],
701
  'tax_amount' => $tax['tax_amount'],
702
  'shipping_tax_amount' => $tax['shipping_tax_amount'],
@@ -726,7 +728,7 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
726
  $total_unformatted = $this->export->order->get_order_total();
727
  }
728
 
729
- $total = woocommerce_price( ( $total_unformatted - $total_tax ) );
730
  $label = __('Total ex. VAT');
731
  } else {
732
  $total = $this->export->order->get_formatted_order_total();
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.5.3
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
33
  self::$plugin_basename = plugin_basename(__FILE__);
34
  self::$plugin_url = plugin_dir_url(self::$plugin_basename);
35
  self::$plugin_path = trailingslashit(dirname(__FILE__));
36
+ self::$version = '1.5.3';
37
 
38
  // load the localisation & classes
39
  add_action( 'plugins_loaded', array( $this, 'translations' ) ); // or use init?
514
  public function get_order_date() {
515
  if ( get_post_type( $this->export->order->id ) == 'shop_order_refund' && $parent_order_id = wp_get_post_parent_id( $this->export->order->id ) ) {
516
  $parent_order = new WC_Order( $parent_order_id );
517
+ $order_date = $parent_order->order_date;
518
  } else {
519
+ $order_date = $this->export->order->order_date;
520
  }
521
 
522
+ $date = date_i18n( get_option( 'date_format' ), strtotime( $order_date ) );
523
+ return apply_filters( 'wpo_wcpdf_order_date', $date, $order_date );
524
  }
525
  public function order_date() {
526
  echo $this->get_order_date();
600
  */
601
  public function get_order_shipping( $tax = 'excl' ) { // set $tax to 'incl' to include tax
602
  if ($tax == 'excl' ) {
603
+ $shipping_costs = $this->export->wc_price( $this->export->order->order_shipping );
604
  } else {
605
+ $shipping_costs = $this->export->wc_price( $this->export->order->order_shipping + $this->export->order->order_shipping_tax );
606
  }
607
 
608
  $shipping = array (
609
  'label' => __('Shipping', 'wpo_wcpdf'),
610
  'value' => $shipping_costs,
611
+ 'tax' => $this->export->wc_price( $this->export->order->order_shipping_tax ),
612
  );
613
  return apply_filters( 'wpo_wcpdf_order_shipping', $shipping );
614
  }
672
  if ( $wcfees = $this->export->order->get_fees() ) {
673
  foreach( $wcfees as $id => $fee ) {
674
  if ($tax == 'excl' ) {
675
+ $fee_price = $this->export->wc_price( $fee['line_total'] );
676
  } else {
677
+ $fee_price = $this->export->wc_price( $fee['line_total'] + $fee['line_tax'] );
678
  }
679
 
 
680
  $fees[ $id ] = array(
681
+ 'label' => $fee['name'],
682
+ 'value' => $fee_price,
683
+ 'line_total' => $this->export->wc_price($fee['line_total']),
684
+ 'line_tax' => $this->export->wc_price($fee['line_tax'])
685
  );
686
  }
687
  return $fees;
698
  foreach ( $this->export->order->get_taxes() as $key => $tax ) {
699
  $taxes[ $key ] = array(
700
  'label' => isset( $tax[ 'label' ] ) ? $tax[ 'label' ] : $tax[ 'name' ],
701
+ 'value' => $this->export->wc_price( ( $tax[ 'tax_amount' ] + $tax[ 'shipping_tax_amount' ] ) ),
702
  'rate_id' => $tax['rate_id'],
703
  'tax_amount' => $tax['tax_amount'],
704
  'shipping_tax_amount' => $tax['shipping_tax_amount'],
728
  $total_unformatted = $this->export->order->get_order_total();
729
  }
730
 
731
+ $total = $this->export->wc_price( ( $total_unformatted - $total_tax ) );
732
  $label = __('Total ex. VAT');
733
  } else {
734
  $total = $this->export->order->get_formatted_order_total();