Version Description
- Feature: Set which type of emails you want to attach the invoice to
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce PDF Invoices & Packing Slips |
Version | 1.2.4 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.4
- includes/class-wcpdf-export.php +17 -3
- includes/class-wcpdf-settings.php +54 -13
- readme.txt +4 -1
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- woocommerce-pdf-invoices-packingslips.php +1 -1
includes/class-wcpdf-export.php
CHANGED
@@ -32,7 +32,7 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
|
32 |
$this->template_default_base_path = WooCommerce_PDF_Invoices::$plugin_path . 'templates/' . $this->template_directory_name . '/';
|
33 |
$this->template_default_base_uri = WooCommerce_PDF_Invoices::$plugin_url . 'templates/' . $this->template_directory_name . '/';
|
34 |
|
35 |
-
$this->template_path = $this->template_settings['template_path'];
|
36 |
|
37 |
add_action( 'wp_ajax_generate_wpo_wcpdf', array($this, 'generate_pdf_ajax' ));
|
38 |
add_filter( 'woocommerce_email_attachments', array( $this, 'attach_pdf_to_email' ), 99, 3);
|
@@ -240,10 +240,24 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
|
240 |
// clear temp folder (from http://stackoverflow.com/a/13468943/1446634)
|
241 |
$tmp_path = WooCommerce_PDF_Invoices::$plugin_path . 'tmp/';
|
242 |
array_map('unlink', ( glob( $tmp_path.'*' ) ? glob( $tmp_path.'*' ) : array() ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
-
$
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
-
if( isset( $status ) && ( $status
|
247 |
$order_number = ltrim( $order->get_order_number(), '#' );
|
248 |
$pdf_filename_prefix = __( 'invoice', 'wpo_wcpdf' );
|
249 |
$pdf_filename = $pdf_filename_prefix . '-' . $order_number . '.pdf';
|
32 |
$this->template_default_base_path = WooCommerce_PDF_Invoices::$plugin_path . 'templates/' . $this->template_directory_name . '/';
|
33 |
$this->template_default_base_uri = WooCommerce_PDF_Invoices::$plugin_url . 'templates/' . $this->template_directory_name . '/';
|
34 |
|
35 |
+
$this->template_path = isset( $this->template_settings['template_path'] )?$this->template_settings['template_path']:'';
|
36 |
|
37 |
add_action( 'wp_ajax_generate_wpo_wcpdf', array($this, 'generate_pdf_ajax' ));
|
38 |
add_filter( 'woocommerce_email_attachments', array( $this, 'attach_pdf_to_email' ), 99, 3);
|
240 |
// clear temp folder (from http://stackoverflow.com/a/13468943/1446634)
|
241 |
$tmp_path = WooCommerce_PDF_Invoices::$plugin_path . 'tmp/';
|
242 |
array_map('unlink', ( glob( $tmp_path.'*' ) ? glob( $tmp_path.'*' ) : array() ) );
|
243 |
+
|
244 |
+
|
245 |
+
// Relevant (default) statuses:
|
246 |
+
// new_order
|
247 |
+
// customer_invoice
|
248 |
+
// customer_processing_order
|
249 |
+
// customer_completed_order
|
250 |
+
|
251 |
+
$allowed_statuses = array_keys( $this->general_settings['email_pdf'] );
|
252 |
|
253 |
+
foreach ($allowed_statuses as $key => $order_status) {
|
254 |
+
// convert 'lazy' status name
|
255 |
+
if ($order_status == 'completed' || $order_status == 'processing') {
|
256 |
+
$allowed_statuses[$key] = "customer_" . $order_status . "_order";
|
257 |
+
}
|
258 |
+
}
|
259 |
|
260 |
+
if( isset( $status ) && in_array ( $status, $allowed_statuses ) ) {
|
261 |
$order_number = ltrim( $order->get_order_number(), '#' );
|
262 |
$pdf_filename_prefix = __( 'invoice', 'wpo_wcpdf' );
|
263 |
$pdf_filename = $pdf_filename_prefix . '-' . $order_number . '.pdf';
|
includes/class-wcpdf-settings.php
CHANGED
@@ -176,13 +176,19 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
176 |
|
177 |
add_settings_field(
|
178 |
'email_pdf',
|
179 |
-
__( '
|
180 |
-
array( &$this, '
|
181 |
$option,
|
182 |
'general_settings',
|
183 |
array(
|
184 |
'menu' => $option,
|
185 |
'id' => 'email_pdf',
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
'description' => $tmp_path_check ? '<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.', 'wpo_wcpdf' ), $tmp_path ).'</span>':'',
|
187 |
)
|
188 |
);
|
@@ -190,6 +196,16 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
190 |
// Register settings.
|
191 |
register_setting( $option, $option, array( &$this, 'validate_options' ) );
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
|
194 |
/**************************************/
|
195 |
/********** TEMPLATE SETTINGS *********/
|
@@ -420,14 +436,14 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
420 |
// Register settings.
|
421 |
register_setting( $option, $option, array( &$this, 'validate_options' ) );
|
422 |
|
423 |
-
// Register defaults if settings empty
|
424 |
$option_values = get_option($option);
|
425 |
-
if (
|
426 |
$this->default_settings();
|
427 |
}
|
428 |
|
429 |
// determine highest invoice number if option not set
|
430 |
-
if ( !isset($option_values['next_invoice_number']) ) {
|
431 |
// Based on code from WooCommerce Sequential Order Numbers
|
432 |
global $wpdb;
|
433 |
// get highest invoice_number in postmeta table
|
@@ -456,7 +472,6 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
456 |
|
457 |
$default_general = array(
|
458 |
'download_display' => 'download',
|
459 |
-
'email_pdf' => '1',
|
460 |
);
|
461 |
|
462 |
$default_template = array(
|
@@ -539,8 +554,6 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
539 |
|
540 |
$html = sprintf( '<input type="checkbox" id="%1$s" name="%2$s[%1$s]" value="1"%3$s />', $id, $menu, checked( 1, $current, false ) );
|
541 |
|
542 |
-
//$html .= sprintf( '<label for="%s"> %s</label><br />', $id, __( 'Activate/Deactivate', 'wpo_wcpdf' ) );
|
543 |
-
|
544 |
// Displays option description.
|
545 |
if ( isset( $args['description'] ) ) {
|
546 |
$html .= sprintf( '<p class="description">%s</p>', $args['description'] );
|
@@ -549,6 +562,31 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
549 |
echo $html;
|
550 |
}
|
551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
/**
|
553 |
* Select element callback.
|
554 |
*
|
@@ -697,12 +735,15 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Settings' ) ) {
|
|
697 |
|
698 |
// Check to see if the current option has a value. If so, process it.
|
699 |
if ( isset( $input[$key] ) ) {
|
700 |
-
|
701 |
// Strip all HTML and PHP tags and properly handle quoted strings.
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
|
|
|
|
|
|
|
|
706 |
}
|
707 |
}
|
708 |
|
176 |
|
177 |
add_settings_field(
|
178 |
'email_pdf',
|
179 |
+
__( 'Attach invoice to:', 'wpo_wcpdf' ),
|
180 |
+
array( &$this, 'multiple_checkbox_element_callback' ),
|
181 |
$option,
|
182 |
'general_settings',
|
183 |
array(
|
184 |
'menu' => $option,
|
185 |
'id' => 'email_pdf',
|
186 |
+
'options' => array(
|
187 |
+
'new_order' => __( 'Admin New Order email' , 'wpo_wcpdf' ),
|
188 |
+
'processing' => __( 'Customer Processing Order email' , 'wpo_wcpdf' ),
|
189 |
+
'completed' => __( 'Customer Completed Order email' , 'wpo_wcpdf' ),
|
190 |
+
'customer_invoice' => __( 'Customer Invoice email' , 'wpo_wcpdf' ),
|
191 |
+
),
|
192 |
'description' => $tmp_path_check ? '<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.', 'wpo_wcpdf' ), $tmp_path ).'</span>':'',
|
193 |
)
|
194 |
);
|
196 |
// Register settings.
|
197 |
register_setting( $option, $option, array( &$this, 'validate_options' ) );
|
198 |
|
199 |
+
$option_values = get_option($option);
|
200 |
+
// convert old 'statusless' setting to new status array
|
201 |
+
if ( isset( $option_values['email_pdf'] ) && !is_array( $option_values['email_pdf'] ) ) {
|
202 |
+
$default_status = apply_filters( 'wpo_wcpdf_attach_to_status', 'completed' );
|
203 |
+
$option_values['email_pdf'] = array (
|
204 |
+
$default_status => 1,
|
205 |
+
'customer_invoice' => 1,
|
206 |
+
);
|
207 |
+
update_option( $option, $option_values );
|
208 |
+
}
|
209 |
|
210 |
/**************************************/
|
211 |
/********** TEMPLATE SETTINGS *********/
|
436 |
// Register settings.
|
437 |
register_setting( $option, $option, array( &$this, 'validate_options' ) );
|
438 |
|
439 |
+
// Register defaults if settings empty
|
440 |
$option_values = get_option($option);
|
441 |
+
if ( !isset( $option_values['paper_size'] ) ) {
|
442 |
$this->default_settings();
|
443 |
}
|
444 |
|
445 |
// determine highest invoice number if option not set
|
446 |
+
if ( !isset( $option_values['next_invoice_number']) ) {
|
447 |
// Based on code from WooCommerce Sequential Order Numbers
|
448 |
global $wpdb;
|
449 |
// get highest invoice_number in postmeta table
|
472 |
|
473 |
$default_general = array(
|
474 |
'download_display' => 'download',
|
|
|
475 |
);
|
476 |
|
477 |
$default_template = array(
|
554 |
|
555 |
$html = sprintf( '<input type="checkbox" id="%1$s" name="%2$s[%1$s]" value="1"%3$s />', $id, $menu, checked( 1, $current, false ) );
|
556 |
|
|
|
|
|
557 |
// Displays option description.
|
558 |
if ( isset( $args['description'] ) ) {
|
559 |
$html .= sprintf( '<p class="description">%s</p>', $args['description'] );
|
562 |
echo $html;
|
563 |
}
|
564 |
|
565 |
+
/**
|
566 |
+
* Multiple Checkbox field callback.
|
567 |
+
*
|
568 |
+
* @param array $args Field arguments.
|
569 |
+
*
|
570 |
+
* @return string Checkbox field.
|
571 |
+
*/
|
572 |
+
public function multiple_checkbox_element_callback( $args ) {
|
573 |
+
$menu = $args['menu'];
|
574 |
+
$id = $args['id'];
|
575 |
+
|
576 |
+
$options = get_option( $menu );
|
577 |
+
|
578 |
+
|
579 |
+
foreach ( $args['options'] as $key => $label ) {
|
580 |
+
$current = ( isset( $options[$id][$key] ) ) ? $options[$id][$key] : '';
|
581 |
+
printf( '<input type="checkbox" id="%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="1"%4$s /> %5$s<br/>', $menu, $id, $key, checked( 1, $current, false ), $label );
|
582 |
+
}
|
583 |
+
|
584 |
+
// Displays option description.
|
585 |
+
if ( isset( $args['description'] ) ) {
|
586 |
+
printf( '<p class="description">%s</p>', $args['description'] );
|
587 |
+
}
|
588 |
+
}
|
589 |
+
|
590 |
/**
|
591 |
* Select element callback.
|
592 |
*
|
735 |
|
736 |
// Check to see if the current option has a value. If so, process it.
|
737 |
if ( isset( $input[$key] ) ) {
|
|
|
738 |
// Strip all HTML and PHP tags and properly handle quoted strings.
|
739 |
+
if ( is_array( $input[$key] ) ) {
|
740 |
+
foreach ( $input[$key] as $sub_key => $sub_value ) {
|
741 |
+
$output[$key][$sub_key] = strip_tags( $input[$key][$sub_key] );
|
742 |
+
}
|
743 |
+
|
744 |
+
} else {
|
745 |
+
$output[$key] = strip_tags( $input[$key] );
|
746 |
+
}
|
747 |
}
|
748 |
}
|
749 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: pomegranate
|
|
3 |
Tags: woocommerce, print, pdf, bulk, packing slips, invoices, delivery notes, invoice, packing slip, export, email
|
4 |
Requires at least: 3.5 and WooCommerce 2.0
|
5 |
Tested up to: 3.8 and WooCommerce 2.1
|
6 |
-
Stable tag: 1.2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -99,6 +99,9 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
|
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
102 |
= 1.2.3 =
|
103 |
* Feature: Manually edit invoice number on the edit order screen
|
104 |
* Feature: Set the first (/next) invoice number on the settings screen
|
3 |
Tags: woocommerce, print, pdf, bulk, packing slips, invoices, delivery notes, invoice, packing slip, export, email
|
4 |
Requires at least: 3.5 and WooCommerce 2.0
|
5 |
Tested up to: 3.8 and WooCommerce 2.1
|
6 |
+
Stable tag: 1.2.4
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
99 |
|
100 |
== Changelog ==
|
101 |
|
102 |
+
= 1.2.4 =
|
103 |
+
* Feature: Set which type of emails you want to attach the invoice to
|
104 |
+
|
105 |
= 1.2.3 =
|
106 |
* Feature: Manually edit invoice number on the edit order screen
|
107 |
* Feature: Set the first (/next) invoice number on the settings screen
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
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.2.
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|
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.2.4
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|