Version Description
- Fix: Don't create invoice number when exporting packing slips
- Fix: Division by zero for 0 quantity items
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce PDF Invoices & Packing Slips |
Version | 1.4.2 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.4.2
includes/class-wcpdf-export.php
CHANGED
@@ -60,7 +60,9 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
|
60 |
}
|
61 |
|
62 |
// Set the invoice number
|
63 |
-
|
|
|
|
|
64 |
|
65 |
$output_html[$order_id] = $this->get_template($template);
|
66 |
|
@@ -212,7 +214,8 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
|
212 |
if ( count($order_ids) > 1 ) {
|
213 |
$filename = $template_name . '-' . date('Y-m-d') . '.pdf'; // 'invoices-2020-11-11.pdf'
|
214 |
} else {
|
215 |
-
$
|
|
|
216 |
$filename = $template_name . '-' . $display_number . '.pdf'; // 'packing-slip-123456.pdf'
|
217 |
}
|
218 |
|
@@ -438,10 +441,11 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
|
438 |
$data['quantity'] = $item['qty'];
|
439 |
|
440 |
// Set the line total (=after discount)
|
|
|
441 |
$data['line_total'] = $this->wc_price( $item['line_total'] );
|
442 |
-
$data['single_line_total'] = $this->wc_price( $item['line_total'] / $
|
443 |
$data['line_tax'] = $this->wc_price( $item['line_tax'] );
|
444 |
-
$data['single_line_tax'] = $this->wc_price( $item['line_tax'] / $
|
445 |
$data['tax_rates'] = $this->get_tax_rate( $item['tax_class'], $item['line_total'], $item['line_tax'] );
|
446 |
|
447 |
// Set the line subtotal (=before discount)
|
@@ -518,7 +522,7 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
|
518 |
*/
|
519 |
public function get_formatted_item_price ( $item, $type, $tax_display = '' ) {
|
520 |
$item_price = 0;
|
521 |
-
$divider = ($type == 'single')?$item['qty']:1; //divide by 1 if $type is not 'single' (thus 'total')
|
522 |
|
523 |
if ( ! isset( $item['line_subtotal'] ) || ! isset( $item['line_subtotal_tax'] ) )
|
524 |
return;
|
60 |
}
|
61 |
|
62 |
// Set the invoice number
|
63 |
+
if ( $template_type == 'invoice' ) {
|
64 |
+
$this->set_invoice_number( $order_id );
|
65 |
+
}
|
66 |
|
67 |
$output_html[$order_id] = $this->get_template($template);
|
68 |
|
214 |
if ( count($order_ids) > 1 ) {
|
215 |
$filename = $template_name . '-' . date('Y-m-d') . '.pdf'; // 'invoices-2020-11-11.pdf'
|
216 |
} else {
|
217 |
+
$this->order = new WC_Order ( $order_ids[0] );
|
218 |
+
$display_number = $template_type == 'invoice' ? $this->get_display_number( $order_ids[0] ) : ltrim($this->order->get_order_number(), '#');
|
219 |
$filename = $template_name . '-' . $display_number . '.pdf'; // 'packing-slip-123456.pdf'
|
220 |
}
|
221 |
|
441 |
$data['quantity'] = $item['qty'];
|
442 |
|
443 |
// Set the line total (=after discount)
|
444 |
+
$quantity_divider = ( $item['qty'] == 0 ) ? 1 : $item['qty']; // prevent division by zero
|
445 |
$data['line_total'] = $this->wc_price( $item['line_total'] );
|
446 |
+
$data['single_line_total'] = $this->wc_price( $item['line_total'] / $quantity_divider );
|
447 |
$data['line_tax'] = $this->wc_price( $item['line_tax'] );
|
448 |
+
$data['single_line_tax'] = $this->wc_price( $item['line_tax'] / $quantity_divider );
|
449 |
$data['tax_rates'] = $this->get_tax_rate( $item['tax_class'], $item['line_total'], $item['line_tax'] );
|
450 |
|
451 |
// Set the line subtotal (=before discount)
|
522 |
*/
|
523 |
public function get_formatted_item_price ( $item, $type, $tax_display = '' ) {
|
524 |
$item_price = 0;
|
525 |
+
$divider = ($type == 'single' && $item['qty'] != 0 )?$item['qty']:1; //divide by 1 if $type is not 'single' (thus 'total')
|
526 |
|
527 |
if ( ! isset( $item['line_subtotal'] ) || ! isset( $item['line_subtotal_tax'] ) )
|
528 |
return;
|
includes/class-wcpdf-writepanels.php
CHANGED
@@ -137,7 +137,7 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices_Writepanels' ) ) {
|
|
137 |
$pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $order->id . '&my-account'), 'generate_wpo_wcpdf' );
|
138 |
|
139 |
// Check if invoice has been created already or if status allows download (filter your own array of allowed statuses)
|
140 |
-
if (get_post_meta($order->id,'_wcpdf_invoice_exists',true) ||
|
141 |
$actions['invoice'] = array(
|
142 |
'url' => $pdf_url,
|
143 |
'name' => __( 'Download invoice (PDF)', 'wpo_wcpdf' )
|
137 |
$pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $order->id . '&my-account'), 'generate_wpo_wcpdf' );
|
138 |
|
139 |
// Check if invoice has been created already or if status allows download (filter your own array of allowed statuses)
|
140 |
+
if ( get_post_meta($order->id,'_wcpdf_invoice_exists',true) || in_array($order->status, apply_filters( 'wpo_wcpdf_myaccount_allowed_order_statuses', array() ) ) ) {
|
141 |
$actions['invoice'] = array(
|
142 |
'url' => $pdf_url,
|
143 |
'name' => __( 'Download invoice (PDF)', 'wpo_wcpdf' )
|
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.9.1 and WooCommerce 2.1
|
6 |
-
Stable tag: 1.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -160,6 +160,10 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
|
|
160 |
|
161 |
== Changelog ==
|
162 |
|
|
|
|
|
|
|
|
|
163 |
= 1.4.1 =
|
164 |
* Translations: Added Polish (Thanks Mike!)
|
165 |
* Fix: Invoice number formatting notices in debug mode
|
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.9.1 and WooCommerce 2.1
|
6 |
+
Stable tag: 1.4.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
160 |
|
161 |
== Changelog ==
|
162 |
|
163 |
+
= 1.4.2 =
|
164 |
+
* Fix: Don't create invoice number when exporting packing slips
|
165 |
+
* Fix: Division by zero for 0 quantity items
|
166 |
+
|
167 |
= 1.4.1 =
|
168 |
* Translations: Added Polish (Thanks Mike!)
|
169 |
* Fix: Invoice number formatting notices in debug mode
|
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.4.
|
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.4.2
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|