WooCommerce PDF Invoices & Packing Slips - Version 1.5.9

Version Description

  • Feature: Shorthand function to display product attributes: $wpo_wcpdf->get_product_attribute( $attribute_name, $product )
Download this release

Release Info

Developer pomegranate
Plugin Icon 128x128 WooCommerce PDF Invoices & Packing Slips
Version 1.5.9
Comparing to
See all releases

Code changes from version 1.5.8 to 1.5.9

includes/class-wcpdf-export.php CHANGED
@@ -590,7 +590,7 @@ if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
590
  } else {
591
  $order = new WC_Order( $order_id );
592
  $order_number = $order->get_order_number();
593
- $order_date = $order->order_date;
594
  }
595
 
596
  return apply_filters( 'wpo_wcpdf_invoice_number', $invoice_number, $order_number, $order_id, $order_date );
590
  } else {
591
  $order = new WC_Order( $order_id );
592
  $order_number = $order->get_order_number();
593
+ $order_date = $order->order_date;
594
  }
595
 
596
  return apply_filters( 'wpo_wcpdf_invoice_number', $invoice_number, $order_number, $order_id, $order_date );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: pomegranate
3
  Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
4
  Requires at least: 3.5
5
  Tested up to: 4.1
6
- Stable tag: 1.5.8
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -233,6 +233,9 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
233
 
234
  == Changelog ==
235
 
 
 
 
236
  = 1.5.8 =
237
  * Feature: disable invoice for free orders
238
  * Feature: action to insert data before & after item meta
@@ -496,5 +499,5 @@ This usually only happens on batch actions. PDF creation is a memory intensive j
496
 
497
  == Upgrade Notice ==
498
 
499
- = 1.5.8 =
500
  Version 1.5 changes where temporary files are stored - everything is now stored centrally in the WP uploads folder. For backwards compatibility, this feature is turned off by default, but we recommend to use the new folders. Check the plugin Status panel for more information!
3
  Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
4
  Requires at least: 3.5
5
  Tested up to: 4.1
6
+ Stable tag: 1.5.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
233
 
234
  == Changelog ==
235
 
236
+ = 1.5.9 =
237
+ * Feature: Shorthand function to display product attributes: `$wpo_wcpdf->get_product_attribute( $attribute_name, $product )`
238
+
239
  = 1.5.8 =
240
  * Feature: disable invoice for free orders
241
  * Feature: action to insert data before & after item meta
499
 
500
  == Upgrade Notice ==
501
 
502
+ = 1.5.9 =
503
  Version 1.5 changes where temporary files are stored - everything is now stored centrally in the WP uploads folder. For backwards compatibility, this feature is turned off by default, but we recommend to use the new folders. Check the plugin Status panel for more information!
templates/pdf/Simple/style.css CHANGED
@@ -116,7 +116,7 @@ td.no-borders {
116
 
117
  /* Header */
118
  table.head {
119
- margin-bottom: 12mm;
120
  }
121
 
122
  td.header img {
116
 
117
  /* Header */
118
  table.head {
119
+ margin-bottom: 12mm;
120
  }
121
 
122
  td.header img {
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.5.8
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -33,7 +33,7 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
33
  self::$plugin_basename = plugin_basename(__FILE__);
34
  self::$plugin_url = plugin_dir_url(self::$plugin_basename);
35
  self::$plugin_path = trailingslashit(dirname(__FILE__));
36
- self::$version = '1.5.8';
37
 
38
  // load the localisation & classes
39
  add_action( 'plugins_loaded', array( $this, 'translations' ) ); // or use init?
@@ -577,6 +577,34 @@ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
577
  public function get_order_items() {
578
  return apply_filters( 'wpo_wcpdf_order_items', $this->export->get_order_items() );
579
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
 
581
  /**
582
  * Return the order totals listing
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.5.9
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
33
  self::$plugin_basename = plugin_basename(__FILE__);
34
  self::$plugin_url = plugin_dir_url(self::$plugin_basename);
35
  self::$plugin_path = trailingslashit(dirname(__FILE__));
36
+ self::$version = '1.5.9';
37
 
38
  // load the localisation & classes
39
  add_action( 'plugins_loaded', array( $this, 'translations' ) ); // or use init?
577
  public function get_order_items() {
578
  return apply_filters( 'wpo_wcpdf_order_items', $this->export->get_order_items() );
579
  }
580
+
581
+ /**
582
+ * Return/show product attribute
583
+ */
584
+ public function get_product_attribute( $attribute_name, $product ) {
585
+ // first, check the text attributes
586
+ $attributes = $product->get_attributes();
587
+ if (array_key_exists( sanitize_title( $attribute_name ), $attributes) ) {
588
+ $attribute = $product->get_attribute ( $attribute_name );
589
+ return $attribute;
590
+ }
591
+
592
+ // not a text attribute, try attribute taxonomy
593
+ $attribute_key = @wc_attribute_taxonomy_name( $attribute_name );
594
+ $product_terms = @wc_get_product_terms( $product->id, $attribute_key, array( 'fields' => 'names' ) );
595
+ // check if not empty, then display
596
+ if ( !empty($product_terms) ) {
597
+ $attribute = array_shift( $product_terms );
598
+ return $attribute;
599
+ } else {
600
+ // no attribute under this name
601
+ return false;
602
+ }
603
+ }
604
+ public function product_attribute( $attribute_name, $product ) {
605
+ echo $this->get_product_attribute( $attribute_name, $product );
606
+ }
607
+
608
 
609
  /**
610
  * Return the order totals listing