Version Description
- Feature: More advanced address visibility options
- Fix: Deprecation notice in WooCommerce 4.4
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce PDF Invoices & Packing Slips |
Version | 2.6.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.4 to 2.6.0
- includes/documents/abstract-wcpdf-order-document-methods.php +5 -1
- includes/documents/class-wcpdf-invoice.php +7 -2
- includes/documents/class-wcpdf-packing-slip.php +148 -143
- readme.txt +5 -1
- templates/Simple/invoice.php +1 -1
- templates/Simple/packing-slip.php +1 -1
- woocommerce-pdf-invoices-packingslips.php +2 -2
includes/documents/abstract-wcpdf-order-document-methods.php
CHANGED
@@ -546,7 +546,11 @@ abstract class Order_Document_Methods extends Order_Document {
|
|
546 |
$data['item'] = $item;
|
547 |
|
548 |
// Get the product to add more info
|
549 |
-
|
|
|
|
|
|
|
|
|
550 |
|
551 |
// Checking fo existance, thanks to MDesigner0
|
552 |
if( !empty( $product ) ) {
|
546 |
$data['item'] = $item;
|
547 |
|
548 |
// Get the product to add more info
|
549 |
+
if ( is_callable( array( $item, 'get_product' ) ) ) { // WC4.4+
|
550 |
+
$product = $item->get_product();
|
551 |
+
} else {
|
552 |
+
$product = $this->order->get_product_from_item( $item );
|
553 |
+
}
|
554 |
|
555 |
// Checking fo existance, thanks to MDesigner0
|
556 |
if( !empty( $product ) ) {
|
includes/documents/class-wcpdf-invoice.php
CHANGED
@@ -211,12 +211,17 @@ class Invoice extends Order_Document_Methods {
|
|
211 |
'type' => 'setting',
|
212 |
'id' => 'display_shipping_address',
|
213 |
'title' => __( 'Display shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
|
214 |
-
'callback' => '
|
215 |
'section' => 'invoice',
|
216 |
'args' => array(
|
217 |
'option_name' => $option_name,
|
218 |
'id' => 'display_shipping_address',
|
219 |
-
'
|
|
|
|
|
|
|
|
|
|
|
220 |
)
|
221 |
),
|
222 |
array(
|
211 |
'type' => 'setting',
|
212 |
'id' => 'display_shipping_address',
|
213 |
'title' => __( 'Display shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
|
214 |
+
'callback' => 'select',
|
215 |
'section' => 'invoice',
|
216 |
'args' => array(
|
217 |
'option_name' => $option_name,
|
218 |
'id' => 'display_shipping_address',
|
219 |
+
'options' => array(
|
220 |
+
'' => __( 'No' , 'woocommerce-pdf-invoices-packing-slips' ),
|
221 |
+
'when_different'=> __( 'Only when different from billing address' , 'woocommerce-pdf-invoices-packing-slips' ),
|
222 |
+
'always' => __( 'Always' , 'woocommerce-pdf-invoices-packing-slips' ),
|
223 |
+
),
|
224 |
+
// 'description' => __( 'Display shipping address (in addition to the default billing address) if different from billing address', 'woocommerce-pdf-invoices-packing-slips' ),
|
225 |
)
|
226 |
),
|
227 |
array(
|
includes/documents/class-wcpdf-packing-slip.php
CHANGED
@@ -1,144 +1,149 @@
|
|
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\\Packing_Slip' ) ) :
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Packing Slip Document
|
16 |
-
*
|
17 |
-
* @class \WPO\WC\PDF_Invoices\Documents\Packing_Slip
|
18 |
-
* @version 2.0
|
19 |
-
* @category Class
|
20 |
-
* @author Ewout Fernhout
|
21 |
-
*/
|
22 |
-
|
23 |
-
class Packing_Slip extends Order_Document_Methods {
|
24 |
-
/**
|
25 |
-
* Init/load the order object.
|
26 |
-
*
|
27 |
-
* @param int|object|WC_Order $order Order to init.
|
28 |
-
*/
|
29 |
-
public function __construct( $order = 0 ) {
|
30 |
-
// set properties
|
31 |
-
$this->type = 'packing-slip';
|
32 |
-
$this->title = __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' );
|
33 |
-
$this->icon = WPO_WCPDF()->plugin_url() . "/assets/images/packing-slip.png";
|
34 |
-
|
35 |
-
// Call parent constructor
|
36 |
-
parent::__construct( $order );
|
37 |
-
}
|
38 |
-
|
39 |
-
public function get_title() {
|
40 |
-
// override/not using $this->title to allow for language switching!
|
41 |
-
return apply_filters( "wpo_wcpdf_{$this->slug}_title", __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ), $this );
|
42 |
-
}
|
43 |
-
|
44 |
-
public function get_filename( $context = 'download', $args = array() ) {
|
45 |
-
$order_count = isset($args['order_ids']) ? count($args['order_ids']) : 1;
|
46 |
-
|
47 |
-
$name = _n( 'packing-slip', 'packing-slips', $order_count, 'woocommerce-pdf-invoices-packing-slips' );
|
48 |
-
|
49 |
-
if ( $order_count == 1 ) {
|
50 |
-
if ( isset( $this->settings['display_number'] ) ) {
|
51 |
-
$suffix = (string) $this->get_number();
|
52 |
-
} else {
|
53 |
-
if ( empty( $this->order ) ) {
|
54 |
-
$order = WCX::get_order ( $order_ids[0] );
|
55 |
-
$suffix = method_exists( $order, 'get_order_number' ) ? $order->get_order_number() : '';
|
56 |
-
} else {
|
57 |
-
$suffix = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
|
58 |
-
}
|
59 |
-
}
|
60 |
-
} else {
|
61 |
-
$suffix = date('Y-m-d'); // 2020-11-11
|
62 |
-
}
|
63 |
-
|
64 |
-
$filename = $name . '-' . $suffix . '.pdf';
|
65 |
-
|
66 |
-
// Filter filename
|
67 |
-
$order_ids = isset($args['order_ids']) ? $args['order_ids'] : array( $this->order_id );
|
68 |
-
$filename = apply_filters( 'wpo_wcpdf_filename', $filename, $this->get_type(), $order_ids, $context );
|
69 |
-
|
70 |
-
// sanitize filename (after filters to prevent human errors)!
|
71 |
-
return sanitize_file_name( $filename );
|
72 |
-
}
|
73 |
-
|
74 |
-
public function init_settings() {
|
75 |
-
// Register settings.
|
76 |
-
$page = $option_group = $option_name = 'wpo_wcpdf_documents_settings_packing-slip';
|
77 |
-
|
78 |
-
$settings_fields = array(
|
79 |
-
array(
|
80 |
-
'type' => 'section',
|
81 |
-
'id' => 'packing_slip',
|
82 |
-
'title' => '',
|
83 |
-
'callback' => 'section',
|
84 |
-
),
|
85 |
-
array(
|
86 |
-
'type' => 'setting',
|
87 |
-
'id' => 'enabled',
|
88 |
-
'title' => __( 'Enable', 'woocommerce-pdf-invoices-packing-slips' ),
|
89 |
-
'callback' => 'checkbox',
|
90 |
-
'section' => 'packing_slip',
|
91 |
-
'args' => array(
|
92 |
-
'option_name' => $option_name,
|
93 |
-
'id' => 'enabled',
|
94 |
-
)
|
95 |
-
),
|
96 |
-
array(
|
97 |
-
'type' => 'setting',
|
98 |
-
'id' => 'display_billing_address',
|
99 |
-
'title' => __( 'Display billing address', 'woocommerce-pdf-invoices-packing-slips' ),
|
100 |
-
'callback' => '
|
101 |
-
'section' => 'packing_slip',
|
102 |
-
'args' => array(
|
103 |
-
'option_name' => $option_name,
|
104 |
-
'id' => 'display_billing_address',
|
105 |
-
'
|
106 |
-
)
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
'
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
array(
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
'
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
144 |
return new Packing_Slip();
|
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\\Packing_Slip' ) ) :
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Packing Slip Document
|
16 |
+
*
|
17 |
+
* @class \WPO\WC\PDF_Invoices\Documents\Packing_Slip
|
18 |
+
* @version 2.0
|
19 |
+
* @category Class
|
20 |
+
* @author Ewout Fernhout
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Packing_Slip extends Order_Document_Methods {
|
24 |
+
/**
|
25 |
+
* Init/load the order object.
|
26 |
+
*
|
27 |
+
* @param int|object|WC_Order $order Order to init.
|
28 |
+
*/
|
29 |
+
public function __construct( $order = 0 ) {
|
30 |
+
// set properties
|
31 |
+
$this->type = 'packing-slip';
|
32 |
+
$this->title = __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' );
|
33 |
+
$this->icon = WPO_WCPDF()->plugin_url() . "/assets/images/packing-slip.png";
|
34 |
+
|
35 |
+
// Call parent constructor
|
36 |
+
parent::__construct( $order );
|
37 |
+
}
|
38 |
+
|
39 |
+
public function get_title() {
|
40 |
+
// override/not using $this->title to allow for language switching!
|
41 |
+
return apply_filters( "wpo_wcpdf_{$this->slug}_title", __( 'Packing Slip', 'woocommerce-pdf-invoices-packing-slips' ), $this );
|
42 |
+
}
|
43 |
+
|
44 |
+
public function get_filename( $context = 'download', $args = array() ) {
|
45 |
+
$order_count = isset($args['order_ids']) ? count($args['order_ids']) : 1;
|
46 |
+
|
47 |
+
$name = _n( 'packing-slip', 'packing-slips', $order_count, 'woocommerce-pdf-invoices-packing-slips' );
|
48 |
+
|
49 |
+
if ( $order_count == 1 ) {
|
50 |
+
if ( isset( $this->settings['display_number'] ) ) {
|
51 |
+
$suffix = (string) $this->get_number();
|
52 |
+
} else {
|
53 |
+
if ( empty( $this->order ) ) {
|
54 |
+
$order = WCX::get_order ( $order_ids[0] );
|
55 |
+
$suffix = method_exists( $order, 'get_order_number' ) ? $order->get_order_number() : '';
|
56 |
+
} else {
|
57 |
+
$suffix = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
|
58 |
+
}
|
59 |
+
}
|
60 |
+
} else {
|
61 |
+
$suffix = date('Y-m-d'); // 2020-11-11
|
62 |
+
}
|
63 |
+
|
64 |
+
$filename = $name . '-' . $suffix . '.pdf';
|
65 |
+
|
66 |
+
// Filter filename
|
67 |
+
$order_ids = isset($args['order_ids']) ? $args['order_ids'] : array( $this->order_id );
|
68 |
+
$filename = apply_filters( 'wpo_wcpdf_filename', $filename, $this->get_type(), $order_ids, $context );
|
69 |
+
|
70 |
+
// sanitize filename (after filters to prevent human errors)!
|
71 |
+
return sanitize_file_name( $filename );
|
72 |
+
}
|
73 |
+
|
74 |
+
public function init_settings() {
|
75 |
+
// Register settings.
|
76 |
+
$page = $option_group = $option_name = 'wpo_wcpdf_documents_settings_packing-slip';
|
77 |
+
|
78 |
+
$settings_fields = array(
|
79 |
+
array(
|
80 |
+
'type' => 'section',
|
81 |
+
'id' => 'packing_slip',
|
82 |
+
'title' => '',
|
83 |
+
'callback' => 'section',
|
84 |
+
),
|
85 |
+
array(
|
86 |
+
'type' => 'setting',
|
87 |
+
'id' => 'enabled',
|
88 |
+
'title' => __( 'Enable', 'woocommerce-pdf-invoices-packing-slips' ),
|
89 |
+
'callback' => 'checkbox',
|
90 |
+
'section' => 'packing_slip',
|
91 |
+
'args' => array(
|
92 |
+
'option_name' => $option_name,
|
93 |
+
'id' => 'enabled',
|
94 |
+
)
|
95 |
+
),
|
96 |
+
array(
|
97 |
+
'type' => 'setting',
|
98 |
+
'id' => 'display_billing_address',
|
99 |
+
'title' => __( 'Display billing address', 'woocommerce-pdf-invoices-packing-slips' ),
|
100 |
+
'callback' => 'select',
|
101 |
+
'section' => 'packing_slip',
|
102 |
+
'args' => array(
|
103 |
+
'option_name' => $option_name,
|
104 |
+
'id' => 'display_billing_address',
|
105 |
+
'options' => array(
|
106 |
+
'' => __( 'No' , 'woocommerce-pdf-invoices-packing-slips' ),
|
107 |
+
'when_different'=> __( 'Only when different from shipping address' , 'woocommerce-pdf-invoices-packing-slips' ),
|
108 |
+
'always' => __( 'Always' , 'woocommerce-pdf-invoices-packing-slips' ),
|
109 |
+
),
|
110 |
+
// 'description' => __( 'Display billing address (in addition to the default shipping address) if different from shipping address', 'woocommerce-pdf-invoices-packing-slips' ),
|
111 |
+
)
|
112 |
+
),
|
113 |
+
array(
|
114 |
+
'type' => 'setting',
|
115 |
+
'id' => 'display_email',
|
116 |
+
'title' => __( 'Display email address', 'woocommerce-pdf-invoices-packing-slips' ),
|
117 |
+
'callback' => 'checkbox',
|
118 |
+
'section' => 'packing_slip',
|
119 |
+
'args' => array(
|
120 |
+
'option_name' => $option_name,
|
121 |
+
'id' => 'display_email',
|
122 |
+
)
|
123 |
+
),
|
124 |
+
array(
|
125 |
+
'type' => 'setting',
|
126 |
+
'id' => 'display_phone',
|
127 |
+
'title' => __( 'Display phone number', 'woocommerce-pdf-invoices-packing-slips' ),
|
128 |
+
'callback' => 'checkbox',
|
129 |
+
'section' => 'packing_slip',
|
130 |
+
'args' => array(
|
131 |
+
'option_name' => $option_name,
|
132 |
+
'id' => 'display_phone',
|
133 |
+
)
|
134 |
+
),
|
135 |
+
);
|
136 |
+
|
137 |
+
|
138 |
+
// allow plugins to alter settings fields
|
139 |
+
$settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_documents_packing_slip', $settings_fields, $page, $option_group, $option_name );
|
140 |
+
WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
|
141 |
+
return;
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
endif; // class_exists
|
148 |
+
|
149 |
return new Packing_Slip();
|
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.5
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.
|
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.5.4 =
|
106 |
* Fix: check for existence of WooCommerce functions preventing incidental crashes in specific deployment setups
|
107 |
* Fix: documents could still be generated programmatically when document disabled and not specifically checking for `$documment->is_allowed()`
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.6.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
102 |
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= 2.6.0 =
|
106 |
+
* Feature: More advanced address visibility options
|
107 |
+
* Fix: Deprecation notice in WooCommerce 4.4
|
108 |
+
|
109 |
= 2.5.4 =
|
110 |
* Fix: check for existence of WooCommerce functions preventing incidental crashes in specific deployment setups
|
111 |
* Fix: documents could still be generated programmatically when document disabled and not specifically checking for `$documment->is_allowed()`
|
templates/Simple/invoice.php
CHANGED
@@ -40,7 +40,7 @@
|
|
40 |
<?php } ?>
|
41 |
</td>
|
42 |
<td class="address shipping-address">
|
43 |
-
<?php if (
|
44 |
<h3><?php _e( 'Ship To:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
|
45 |
<?php do_action( 'wpo_wcpdf_before_shipping_address', $this->type, $this->order ); ?>
|
46 |
<?php $this->shipping_address(); ?>
|
40 |
<?php } ?>
|
41 |
</td>
|
42 |
<td class="address shipping-address">
|
43 |
+
<?php if ( !empty($this->settings['display_shipping_address']) && ( $this->ships_to_different_address() || $this->settings['display_shipping_address'] == 'always' ) ) { ?>
|
44 |
<h3><?php _e( 'Ship To:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
|
45 |
<?php do_action( 'wpo_wcpdf_before_shipping_address', $this->type, $this->order ); ?>
|
46 |
<?php $this->shipping_address(); ?>
|
templates/Simple/packing-slip.php
CHANGED
@@ -40,7 +40,7 @@
|
|
40 |
<?php } ?>
|
41 |
</td>
|
42 |
<td class="address billing-address">
|
43 |
-
<?php if (
|
44 |
<h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
|
45 |
<?php do_action( 'wpo_wcpdf_before_billing_address', $this->type, $this->order ); ?>
|
46 |
<?php $this->billing_address(); ?>
|
40 |
<?php } ?>
|
41 |
</td>
|
42 |
<td class="address billing-address">
|
43 |
+
<?php if ( !empty($this->settings['display_billing_address']) && ( $this->ships_to_different_address() || $this->settings['display_billing_address'] == 'always' ) ) { ?>
|
44 |
<h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
|
45 |
<?php do_action( 'wpo_wcpdf_before_billing_address', $this->type, $this->order ); ?>
|
46 |
<?php $this->billing_address(); ?>
|
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.
|
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.
|
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.6.0
|
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.6.0';
|
25 |
public $plugin_basename;
|
26 |
public $legacy_mode;
|
27 |
|