Version Description
- Dev: Added
wpo_wcpdf_pdf_data
filter for direct loading of PDF data - Dev: Added
is_bulk
property to bulk documents
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce PDF Invoices & Packing Slips |
Version | 2.4.8 |
Comparing to | |
See all releases |
Code changes from version 2.4.7 to 2.4.8
includes/documents/abstract-wcpdf-order-document.php
CHANGED
@@ -609,11 +609,13 @@ abstract class Order_Document {
|
|
609 |
*/
|
610 |
|
611 |
public function get_pdf() {
|
|
|
612 |
if ( $pdf_file = apply_filters( 'wpo_wcpdf_load_pdf_file_path', null, $this ) ) {
|
613 |
$pdf = file_get_contents( $pdf_file );
|
614 |
-
|
615 |
-
|
616 |
-
|
|
|
617 |
}
|
618 |
|
619 |
do_action( 'wpo_wcpdf_before_pdf', $this->get_type(), $this );
|
609 |
*/
|
610 |
|
611 |
public function get_pdf() {
|
612 |
+
$pdf = null;
|
613 |
if ( $pdf_file = apply_filters( 'wpo_wcpdf_load_pdf_file_path', null, $this ) ) {
|
614 |
$pdf = file_get_contents( $pdf_file );
|
615 |
+
}
|
616 |
+
$pdf = apply_filters( 'wpo_wcpdf_pdf_data', $pdf, $this );
|
617 |
+
if ( !empty( $pdf ) ) {
|
618 |
+
return $pdf;
|
619 |
}
|
620 |
|
621 |
do_action( 'wpo_wcpdf_before_pdf', $this->get_type(), $this );
|
includes/documents/class-wcpdf-bulk-document.php
CHANGED
@@ -1,125 +1,126 @@
|
|
1 |
-
<?php
|
2 |
-
namespace WPO\WC\PDF_Invoices\Documents;
|
3 |
-
|
4 |
-
use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
|
5 |
-
use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
|
6 |
-
use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly
|
10 |
-
}
|
11 |
-
|
12 |
-
if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Documents\\Bulk_Document' ) ) :
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Bulk Document
|
16 |
-
*
|
17 |
-
* Wraps single documents in a bulk document
|
18 |
-
*
|
19 |
-
* @class \WPO\WC\PDF_Invoices\Documents\Bulk_Document
|
20 |
-
* @version 2.0
|
21 |
-
* @category Class
|
22 |
-
* @author Ewout Fernhout
|
23 |
-
*/
|
24 |
-
|
25 |
-
class Bulk_Document {
|
26 |
-
/**
|
27 |
-
* Document type.
|
28 |
-
* @var String
|
29 |
-
*/
|
30 |
-
public $type;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Wrapper document - used for filename etc.
|
34 |
-
* @var String
|
35 |
-
*/
|
36 |
-
public $wrapper_document;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Order IDs.
|
40 |
-
* @var array
|
41 |
-
*/
|
42 |
-
public $order_ids;
|
43 |
-
|
44 |
-
public function __construct( $document_type, $order_ids = array() ) {
|
45 |
-
$this->type = $document_type;
|
46 |
-
$this->order_ids = $order_ids;
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
$
|
58 |
-
|
59 |
-
'
|
60 |
-
'
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
$
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
$
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
1 |
+
<?php
|
2 |
+
namespace WPO\WC\PDF_Invoices\Documents;
|
3 |
+
|
4 |
+
use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
|
5 |
+
use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
|
6 |
+
use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Documents\\Bulk_Document' ) ) :
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Bulk Document
|
16 |
+
*
|
17 |
+
* Wraps single documents in a bulk document
|
18 |
+
*
|
19 |
+
* @class \WPO\WC\PDF_Invoices\Documents\Bulk_Document
|
20 |
+
* @version 2.0
|
21 |
+
* @category Class
|
22 |
+
* @author Ewout Fernhout
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Bulk_Document {
|
26 |
+
/**
|
27 |
+
* Document type.
|
28 |
+
* @var String
|
29 |
+
*/
|
30 |
+
public $type;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Wrapper document - used for filename etc.
|
34 |
+
* @var String
|
35 |
+
*/
|
36 |
+
public $wrapper_document;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Order IDs.
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
public $order_ids;
|
43 |
+
|
44 |
+
public function __construct( $document_type, $order_ids = array() ) {
|
45 |
+
$this->type = $document_type;
|
46 |
+
$this->order_ids = $order_ids;
|
47 |
+
$this->is_bulk = true;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function get_type() {
|
51 |
+
return $this->type;
|
52 |
+
}
|
53 |
+
|
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 ),
|
60 |
+
'paper_orientation' => apply_filters( 'wpo_wcpdf_paper_orientation', 'portrait', $this->get_type(), $this ),
|
61 |
+
'font_subsetting' => $this->wrapper_document->get_setting( 'font_subsetting', false ),
|
62 |
+
);
|
63 |
+
$pdf_maker = wcpdf_get_pdf_maker( $html, $pdf_settings );
|
64 |
+
$pdf = apply_filters( 'wpo_wcpdf_pdf_data', $pdf_maker->output(), $this );
|
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 );
|
76 |
+
|
77 |
+
$order = WCX::get_order( $order_id );
|
78 |
+
|
79 |
+
if ( $document = wcpdf_get_document( $this->get_type(), $order, true ) ) {
|
80 |
+
$html_content[ $key ] = $document->get_html( array( 'wrap_html_content' => false ) );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
// get wrapper document & insert body content
|
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 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
public function merge_documents( $html_content ) {
|
94 |
+
// insert page breaks merge
|
95 |
+
$page_break = "\n<div style=\"page-break-before: always;\"></div>\n";
|
96 |
+
$html = implode( $page_break, $html_content );
|
97 |
+
return apply_filters( 'wpo_wcpdf_merged_bulk_document_content', $html, $html_content, $this );
|
98 |
+
}
|
99 |
+
|
100 |
+
public function output_pdf( $output_mode = 'download' ) {
|
101 |
+
$pdf = $this->get_pdf();
|
102 |
+
wcpdf_pdf_headers( $this->get_filename(), $output_mode, $pdf );
|
103 |
+
echo $pdf;
|
104 |
+
die();
|
105 |
+
}
|
106 |
+
|
107 |
+
public function output_html() {
|
108 |
+
echo $this->get_html();
|
109 |
+
die();
|
110 |
+
}
|
111 |
+
|
112 |
+
public function get_filename( $context = 'download', $args = array() ) {
|
113 |
+
if ( empty( $this->wrapper_document ) ) {
|
114 |
+
$this->wrapper_document = wcpdf_get_document( $this->get_type(), null );
|
115 |
+
}
|
116 |
+
$default_args = array(
|
117 |
+
'order_ids' => $this->order_ids,
|
118 |
+
);
|
119 |
+
$args = $args + $default_args;
|
120 |
+
$filename = $this->wrapper_document->get_filename( $context, $args );
|
121 |
+
return $filename;
|
122 |
+
}
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
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.4
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.4.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -102,6 +102,10 @@ There's a setting on the Status tab of the settings page that allows you to togg
|
|
102 |
|
103 |
== Changelog ==
|
104 |
|
|
|
|
|
|
|
|
|
105 |
= 2.4.7 =
|
106 |
* Fix: missing order number in filename when invoice number not enabled
|
107 |
* Dev: Added action hook for document save method (`wpo_wcpdf_save_document`)
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.4.8
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
102 |
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= 2.4.8 =
|
106 |
+
* Dev: Added `wpo_wcpdf_pdf_data` filter for direct loading of PDF data
|
107 |
+
* Dev: Added `is_bulk` property to bulk documents
|
108 |
+
|
109 |
= 2.4.7 =
|
110 |
* Fix: missing order number in filename when invoice number not enabled
|
111 |
* Dev: Added action hook for document save method (`wpo_wcpdf_save_document`)
|
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: 2.4.
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
|
|
21 |
|
22 |
class WPO_WCPDF {
|
23 |
|
24 |
-
public $version = '2.4.
|
25 |
public $plugin_basename;
|
26 |
public $legacy_mode;
|
27 |
|
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: 2.4.8
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|
21 |
|
22 |
class WPO_WCPDF {
|
23 |
|
24 |
+
public $version = '2.4.8';
|
25 |
public $plugin_basename;
|
26 |
public $legacy_mode;
|
27 |
|