WooCommerce PDF Invoices - Version 2.4.7

Version Description

  • May 2, 2016 =

  • Fixed: Invoice not attached to email

Download this release

Release Info

Developer baaaaas
Plugin Icon 128x128 WooCommerce PDF Invoices
Version 2.4.7
Comparing to
See all releases

Code changes from version 2.4.6 to 2.4.7

bootstrap.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce PDF Invoices
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
5
  * Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
6
- * Version: 2.4.6
7
  * Author: Bas Elbers
8
  * Author URI: http://wcpdfinvoices.com
9
  * License: GPL-2.0+
@@ -19,7 +19,7 @@ function bewpi_plugins_loaded() {
19
 
20
  $wp_upload_dir = wp_upload_dir();
21
 
22
- define( 'BEWPI_VERSION', '2.4.6' );
23
  define( 'BEWPI_URL', plugins_url( '', __FILE__ ) . '/' );
24
  define( 'BEWPI_DIR', plugin_dir_path( __FILE__ ) . '/' );
25
  define( 'BEWPI_TEMPLATES_DIR', plugin_dir_path( __FILE__ ) . 'includes/templates/' );
3
  * Plugin Name: WooCommerce PDF Invoices
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
5
  * Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
6
+ * Version: 2.4.7
7
  * Author: Bas Elbers
8
  * Author URI: http://wcpdfinvoices.com
9
  * License: GPL-2.0+
19
 
20
  $wp_upload_dir = wp_upload_dir();
21
 
22
+ define( 'BEWPI_VERSION', '2.4.7' );
23
  define( 'BEWPI_URL', plugins_url( '', __FILE__ ) . '/' );
24
  define( 'BEWPI_DIR', plugin_dir_path( __FILE__ ) . '/' );
25
  define( 'BEWPI_TEMPLATES_DIR', plugin_dir_path( __FILE__ ) . 'includes/templates/' );
includes/be-woocommerce-pdf-invoices.php CHANGED
@@ -20,12 +20,6 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
20
  public $general_options = array();
21
  public $template_options = array();
22
 
23
- /**
24
- * Initialize plugin and register actions and filters.
25
- *
26
- * @param $general_settings
27
- * @param $template_settings
28
- */
29
  public function __construct() {
30
  $this->lang_code = get_bloginfo( "language" );
31
  new BEWPI_General_Settings();
@@ -78,6 +72,11 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
78
  */
79
  add_filter( 'woocommerce_email_attachments', array( &$this, 'attach_invoice_to_email' ), 99, 3 );
80
 
 
 
 
 
 
81
  /**
82
  * Adds a download link for the pdf invoice on the my account page
83
  */
@@ -347,6 +346,33 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
347
  return $headers;
348
  }
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  /**
351
  * Attaches invoice to a specific WooCommerce email. Invoice will only be generated when it does not exists already.
352
  *
@@ -359,8 +385,8 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
359
  function attach_invoice_to_email( $attachments, $status, $order ) {
360
  $attachments = apply_filters( 'bewpi_email_attachments', $attachments, $status, $order );
361
 
362
- $general_options = get_option( 'bewpi_general_settings' );
363
- if($status !== $general_options["bewpi_email_type"] && (!$general_options['bewpi_new_order'] && $status === "new_order"))
364
  {
365
  return $attachments;
366
  }
20
  public $general_options = array();
21
  public $template_options = array();
22
 
 
 
 
 
 
 
23
  public function __construct() {
24
  $this->lang_code = get_bloginfo( "language" );
25
  new BEWPI_General_Settings();
72
  */
73
  add_filter( 'woocommerce_email_attachments', array( &$this, 'attach_invoice_to_email' ), 99, 3 );
74
 
75
+ /**
76
+ * Attach invoice to a new order email
77
+ */
78
+ add_filter( 'woocommerce_email_attachments', array( &$this, 'attach_invoice_to_new_order_email' ), 99, 3 );
79
+
80
  /**
81
  * Adds a download link for the pdf invoice on the my account page
82
  */
346
  return $headers;
347
  }
348
 
349
+ public function attach_invoice_to_new_order_email($attachments, $status, $order)
350
+ {
351
+ $general_options = get_option( 'bewpi_general_settings' );
352
+ if(!$general_options['bewpi_new_order'] || $status !== "new_order")
353
+ {
354
+ return $attachments;
355
+ }
356
+
357
+ $invoice = new BEWPI_Invoice( $order->id );
358
+ if($invoice->exists())
359
+ {
360
+ $full_path = $invoice->get_full_path();
361
+ }
362
+ else
363
+ {
364
+ $full_path = $invoice->save("F");
365
+ }
366
+
367
+ // only add to attachments if it isn't already added.
368
+ if(!in_array($full_path, $attachments))
369
+ {
370
+ $attachments[] = $full_path;
371
+ }
372
+
373
+ return $attachments;
374
+ }
375
+
376
  /**
377
  * Attaches invoice to a specific WooCommerce email. Invoice will only be generated when it does not exists already.
378
  *
385
  function attach_invoice_to_email( $attachments, $status, $order ) {
386
  $attachments = apply_filters( 'bewpi_email_attachments', $attachments, $status, $order );
387
 
388
+ $general_options = get_option( 'bewpi_general_settings' );
389
+ if(empty($general_options["bewpi_email_type"]) || $status !== $general_options["bewpi_email_type"])
390
  {
391
  return $attachments;
392
  }
includes/partials/settings-sidebar.php CHANGED
@@ -5,7 +5,7 @@
5
  - <?php _e( 'Bill periodically by generating and sending global invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
6
  - <?php _e( 'Add additional PDF\'s to customer invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
7
  - <?php _e( 'Send customer invoices directly to suppliers and others.', 'woocommerce-pdf-invoices' ); ?><br/>
8
- - <?php printf( __( 'Compatible with <a href="%s">WooCommerce Subscriptions</a> plugin emails.', 'woocommerce-pdf-invoices' ), "http://www.woothemes.com/products/woocommerce-subscriptions/" ); ?><br/>
9
  </p>
10
  <a class="bewpi-learn-more" href="http://wcpdfinvoices.com" target="_blank"><?php _e ( 'Learn more', 'woocommerce-pdf-invoices' ); ?></a>
11
  </aside>
@@ -49,7 +49,7 @@
49
  <aside class="bewpi-sidebar support">
50
  <h3><?php _e( 'Support', 'woocommerce-pdf-invoices' ); ?></h3>
51
  <p>
52
- <?php _e( 'We will never ask for donations, but to garantee future development, we do need your support. Please show us your appreciation by leaving a <a href="https://wordpress.org/support/view/plugin-reviews/woocommerce-pdf-invoices?rate=5#postform">★★★★★</a> rating and vote for <a href="https://wordpress.org/plugins/woocommerce-pdf-invoices/">works</a>.', 'woocommerce-pdf-invoices' ); ?>
53
  </p>
54
  <!-- Github star -->
55
  <div class="github btn">
5
  - <?php _e( 'Bill periodically by generating and sending global invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
6
  - <?php _e( 'Add additional PDF\'s to customer invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
7
  - <?php _e( 'Send customer invoices directly to suppliers and others.', 'woocommerce-pdf-invoices' ); ?><br/>
8
+ - <?php printf( __( 'Attach invoices to <a href="%s">WooCommerce Subscriptions</a> emails.', 'woocommerce-pdf-invoices' ), "http://www.woothemes.com/products/woocommerce-subscriptions/" ); ?><br/>
9
  </p>
10
  <a class="bewpi-learn-more" href="http://wcpdfinvoices.com" target="_blank"><?php _e ( 'Learn more', 'woocommerce-pdf-invoices' ); ?></a>
11
  </aside>
49
  <aside class="bewpi-sidebar support">
50
  <h3><?php _e( 'Support', 'woocommerce-pdf-invoices' ); ?></h3>
51
  <p>
52
+ <?php _e( 'We will never ask for donations, but to guarantee future development, we do need your support. Please show us your appreciation by leaving a <a href="https://wordpress.org/support/view/plugin-reviews/woocommerce-pdf-invoices?rate=5#postform">★★★★★</a> rating and vote for <a href="https://wordpress.org/plugins/woocommerce-pdf-invoices/">works</a>.', 'woocommerce-pdf-invoices' ); ?>
53
  </p>
54
  <!-- Github star -->
55
  <div class="github btn">
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
  Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
5
  Requires at least: 3.8
6
  Tested up to: 4.5
7
- Stable tag: 2.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -218,7 +218,12 @@ add_filter('bewpi_allowed_roles_to_download_invoice', 'bewpi_allowed_roles_to_do
218
 
219
  == Changelog ==
220
 
 
 
 
 
221
  = 2.4.6 - April 29, 2016 =
 
222
  - Added: Option to change the title of the invoice
223
  - Fixed: Invoice not attached to email
224
  - Fixed: Shortcode error when no order_id is given
4
  Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
5
  Requires at least: 3.8
6
  Tested up to: 4.5
7
+ Stable tag: 2.4.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
218
 
219
  == Changelog ==
220
 
221
+ = 2.4.7 - May 2, 2016 =
222
+
223
+ - Fixed: Invoice not attached to email
224
+
225
  = 2.4.6 - April 29, 2016 =
226
+
227
  - Added: Option to change the title of the invoice
228
  - Fixed: Invoice not attached to email
229
  - Fixed: Shortcode error when no order_id is given