Version Description
- This is the last release before our upcoming 2.0 update
- Feature: Facilitate downgrading from 2.0 (re-installing fonts & resetting version)
- Fix: Update currencies font (added Georgian Lari)
- Translations: Added Indonesian
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce PDF Invoices & Packing Slips |
Version | 1.6.6 |
Comparing to | |
See all releases |
Code changes from version 1.6.5 to 1.6.6
- includes/class-wcpdf-export.php +1313 -1313
- includes/class-wcpdf-writepanels.php +383 -383
- includes/compatibility/class-wc-product-compatibility.php +1 -1
- languages/wpo_wcpdf-id_ID.mo +0 -0
- languages/wpo_wcpdf-id_ID.po +575 -0
- lib/dompdf/lib/fonts/currencies.ttf +0 -0
- lib/dompdf/lib/fonts/currencies.ufm +132 -0
- lib/dompdf/lib/fonts/dompdf_font_family_cache.php +4 -4
- readme.txt +550 -543
- woocommerce-pdf-invoices-packingslips.php +665 -589
includes/class-wcpdf-export.php
CHANGED
@@ -1,1313 +1,1313 @@
|
|
1 |
-
<?php
|
2 |
-
use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
|
3 |
-
use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
|
4 |
-
use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) or exit;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* PDF Export class
|
10 |
-
*/
|
11 |
-
if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
12 |
-
|
13 |
-
class WooCommerce_PDF_Invoices_Export {
|
14 |
-
|
15 |
-
public $template_directory_name;
|
16 |
-
public $template_base_path;
|
17 |
-
public $template_default_base_path;
|
18 |
-
public $template_default_base_uri;
|
19 |
-
public $template_path;
|
20 |
-
|
21 |
-
public $order;
|
22 |
-
public $template_type;
|
23 |
-
public $order_id;
|
24 |
-
public $output_body;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Constructor
|
28 |
-
*/
|
29 |
-
public function __construct() {
|
30 |
-
global $woocommerce;
|
31 |
-
$this->order = WCX::get_order('');
|
32 |
-
$this->general_settings = get_option('wpo_wcpdf_general_settings');
|
33 |
-
$this->template_settings = get_option('wpo_wcpdf_template_settings');
|
34 |
-
$this->debug_settings = get_option('wpo_wcpdf_debug_settings');
|
35 |
-
|
36 |
-
$this->template_directory_name = 'pdf';
|
37 |
-
$this->template_base_path = (defined('WC_TEMPLATE_PATH')?WC_TEMPLATE_PATH:$woocommerce->template_url) . $this->template_directory_name . '/';
|
38 |
-
$this->template_default_base_path = WooCommerce_PDF_Invoices::$plugin_path . 'templates/' . $this->template_directory_name . '/';
|
39 |
-
$this->template_default_base_uri = WooCommerce_PDF_Invoices::$plugin_url . 'templates/' . $this->template_directory_name . '/';
|
40 |
-
|
41 |
-
$this->template_path = isset( $this->template_settings['template_path'] )?$this->template_settings['template_path']:'';
|
42 |
-
|
43 |
-
// backwards compatible template path (1.4.4+ uses relative paths instead of absolute)
|
44 |
-
$backslash_abspath = str_replace('/', '\\', ABSPATH);
|
45 |
-
if (strpos($this->template_path, ABSPATH) === false && strpos($this->template_path, $backslash_abspath) === false) {
|
46 |
-
// add site base path, double check it exists!
|
47 |
-
if ( file_exists( ABSPATH . $this->template_path ) ) {
|
48 |
-
$this->template_path = ABSPATH . $this->template_path;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
if ( file_exists( $this->template_path . '/template-functions.php' ) ) {
|
53 |
-
require_once( $this->template_path . '/template-functions.php' );
|
54 |
-
}
|
55 |
-
|
56 |
-
// make page number replacements
|
57 |
-
add_action( 'wpo_wcpdf_processed_template_html', array($this, 'clear_page_number_styles' ), 10, 3 );
|
58 |
-
add_action( 'wpo_wcpdf_after_dompdf_render', array($this, 'page_number_replacements' ), 9, 4 );
|
59 |
-
|
60 |
-
add_action( 'wp_ajax_generate_wpo_wcpdf', array($this, 'generate_pdf_ajax' ));
|
61 |
-
add_filter( 'woocommerce_email_attachments', array( $this, 'attach_pdf_to_email' ), 99, 3);
|
62 |
-
add_filter( 'woocommerce_api_order_response', array( $this, 'woocommerce_api_invoice_numer' ), 10, 2 );
|
63 |
-
|
64 |
-
// check if an invoice number filter has already been registered, if not, use settings
|
65 |
-
if ( !has_filter( 'wpo_wcpdf_invoice_number' ) ) {
|
66 |
-
add_filter( 'wpo_wcpdf_invoice_number', array( $this, 'format_invoice_number' ), 20, 4 );
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( isset($this->debug_settings['enable_debug'])) {
|
70 |
-
$this->enable_debug();
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( isset($this->debug_settings['html_output'])) {
|
74 |
-
add_filter( 'wpo_wcpdf_output_html', '__return_true' );
|
75 |
-
add_filter( 'wpo_wcpdf_use_path', '__return_false' );
|
76 |
-
}
|
77 |
-
|
78 |
-
if ( isset($this->template_settings['currency_font'])) {
|
79 |
-
add_action( 'wpo_wcpdf_before_pdf', array($this, 'use_currency_font' ) );
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
// WooCommerce Subscriptions compatibility
|
84 |
-
if ( class_exists('WC_Subscriptions') ) {
|
85 |
-
if ( version_compare( WC_Subscriptions::$version, '2.0', '<' ) ) {
|
86 |
-
add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'woocommerce_subscriptions_renewal_order_created' ), 10, 4 );
|
87 |
-
} else {
|
88 |
-
add_action( 'wcs_renewal_order_created', array( $this, 'wcs_renewal_order_created' ), 10, 2 );
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
// WooCommerce Product Bundles compatibility (add row classes)
|
93 |
-
if ( class_exists('WC_Bundles') ) {
|
94 |
-
add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_product_bundles_classes' ), 10, 4 );
|
95 |
-
}
|
96 |
-
|
97 |
-
// WooCommerce Chained Products compatibility (add row classes)
|
98 |
-
if ( class_exists('SA_WC_Chained_Products') ) {
|
99 |
-
add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_chained_product_class' ), 10, 4 );
|
100 |
-
}
|
101 |
-
|
102 |
-
// qTranslate-X compatibility
|
103 |
-
if ( function_exists('qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
|
104 |
-
$this->qtranslatex_filters();
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Install/create plugin tmp folders
|
110 |
-
*/
|
111 |
-
public function init_tmp ( $tmp_base ) {
|
112 |
-
// create plugin base temp folder
|
113 |
-
@mkdir( $tmp_base );
|
114 |
-
|
115 |
-
// create subfolders & protect
|
116 |
-
$subfolders = array( 'attachments', 'fonts', 'dompdf' );
|
117 |
-
foreach ( $subfolders as $subfolder ) {
|
118 |
-
$path = $tmp_base . $subfolder . '/';
|
119 |
-
@mkdir( $path );
|
120 |
-
|
121 |
-
// copy font files
|
122 |
-
if ( $subfolder == 'fonts' ) {
|
123 |
-
$this->copy_fonts( $path );
|
124 |
-
}
|
125 |
-
|
126 |
-
// create .htaccess file and empty index.php to protect in case an open webfolder is used!
|
127 |
-
@file_put_contents( $path . '.htaccess', 'deny from all' );
|
128 |
-
@touch( $path . 'index.php' );
|
129 |
-
}
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Copy DOMPDF fonts to wordpress tmp folder
|
135 |
-
*/
|
136 |
-
public function copy_fonts ( $path ) {
|
137 |
-
$dompdf_font_dir = WooCommerce_PDF_Invoices::$plugin_path . "lib/dompdf/lib/fonts/";
|
138 |
-
|
139 |
-
// first try the easy way with glob!
|
140 |
-
if ( function_exists('glob') ) {
|
141 |
-
$files = glob($dompdf_font_dir."*.*");
|
142 |
-
foreach($files as $file){
|
143 |
-
if(!is_dir($file) && is_readable($file)) {
|
144 |
-
$dest = $path . basename($file);
|
145 |
-
copy($file, $dest);
|
146 |
-
}
|
147 |
-
}
|
148 |
-
} else {
|
149 |
-
// fallback method using font cache file (glob is disabled on some servers with disable_functions)
|
150 |
-
$font_cache_file = $dompdf_font_dir . "dompdf_font_family_cache.php";
|
151 |
-
$font_cache_dist_file = $dompdf_font_dir . "dompdf_font_family_cache.dist.php";
|
152 |
-
$fonts = @require_once( $font_cache_file );
|
153 |
-
$extensions = array( '.ttf', '.ufm', '.ufm.php', '.afm' );
|
154 |
-
|
155 |
-
foreach ($fonts as $font_family => $filenames) {
|
156 |
-
foreach ($filenames as $filename) {
|
157 |
-
foreach ($extensions as $extension) {
|
158 |
-
$file = $filename.$extension;
|
159 |
-
if (file_exists($file)) {
|
160 |
-
$dest = $path . basename($file);
|
161 |
-
copy($file, $dest);
|
162 |
-
}
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
|
167 |
-
// copy cache files separately
|
168 |
-
copy($font_cache_file, $path.basename($font_cache_file));
|
169 |
-
copy($font_cache_dist_file, $path.basename($font_cache_dist_file));
|
170 |
-
}
|
171 |
-
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Return tmp path for different plugin processes
|
176 |
-
*/
|
177 |
-
public function tmp_path ( $type = '' ) {
|
178 |
-
// get temp setting
|
179 |
-
$old_tmp = isset($this->debug_settings['old_tmp']);
|
180 |
-
|
181 |
-
$tmp_base = $this->get_tmp_base();
|
182 |
-
if (!$old_tmp) {
|
183 |
-
// check if tmp folder exists => if not, initialize
|
184 |
-
if ( !@is_dir( $tmp_base ) ) {
|
185 |
-
$this->init_tmp( $tmp_base );
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
if ( empty( $type ) ) {
|
190 |
-
return $tmp_base;
|
191 |
-
}
|
192 |
-
|
193 |
-
switch ( $type ) {
|
194 |
-
case 'DOMPDF_TEMP_DIR':
|
195 |
-
// original value : sys_get_temp_dir()
|
196 |
-
// 1.5+ : $tmp_base . 'dompdf'
|
197 |
-
$tmp_path = $old_tmp ? sys_get_temp_dir() : $tmp_base . 'dompdf';
|
198 |
-
break;
|
199 |
-
case 'DOMPDF_FONT_DIR': // NEEDS TRAILING SLASH!
|
200 |
-
// original value : DOMPDF_DIR."/lib/fonts/"
|
201 |
-
// 1.5+ : $tmp_base . 'fonts/'
|
202 |
-
$tmp_path = $old_tmp ? DOMPDF_DIR."/lib/fonts/" : $tmp_base . 'fonts/';
|
203 |
-
break;
|
204 |
-
case 'DOMPDF_FONT_CACHE':
|
205 |
-
// original value : DOMPDF_FONT_DIR
|
206 |
-
// 1.5+ : $tmp_base . 'fonts'
|
207 |
-
$tmp_path = $old_tmp ? DOMPDF_FONT_DIR : $tmp_base . 'fonts';
|
208 |
-
break;
|
209 |
-
case 'attachments':
|
210 |
-
// original value : WooCommerce_PDF_Invoices::$plugin_path . 'tmp/'
|
211 |
-
// 1.5+ : $tmp_base . 'attachments/'
|
212 |
-
$tmp_path = $old_tmp ? WooCommerce_PDF_Invoices::$plugin_path . 'tmp/' : $tmp_base . 'attachments/';
|
213 |
-
break;
|
214 |
-
default:
|
215 |
-
$tmp_path = $tmp_base . $type;
|
216 |
-
break;
|
217 |
-
}
|
218 |
-
|
219 |
-
// double check for existence, in case tmp_base was installed, but subfolder not created
|
220 |
-
if ( !@is_dir( $tmp_path ) ) {
|
221 |
-
@mkdir( $tmp_path );
|
222 |
-
}
|
223 |
-
|
224 |
-
return $tmp_path;
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* return the base tmp folder (usually uploads)
|
229 |
-
*/
|
230 |
-
public function get_tmp_base () {
|
231 |
-
// wp_upload_dir() is used to set the base temp folder, under which a
|
232 |
-
// 'wpo_wcpdf' folder and several subfolders are created
|
233 |
-
//
|
234 |
-
// wp_upload_dir() will:
|
235 |
-
// * default to WP_CONTENT_DIR/uploads
|
236 |
-
// * UNLESS the ‘UPLOADS’ constant is defined in wp-config (http://codex.wordpress.org/Editing_wp-config.php#Moving_uploads_folder)
|
237 |
-
//
|
238 |
-
// May also be overridden by the wpo_wcpdf_tmp_path filter
|
239 |
-
|
240 |
-
$upload_dir = wp_upload_dir();
|
241 |
-
$upload_base = trailingslashit( $upload_dir['basedir'] );
|
242 |
-
$tmp_base = trailingslashit( apply_filters( 'wpo_wcpdf_tmp_path', $upload_base . 'wpo_wcpdf/' ) );
|
243 |
-
return $tmp_base;
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Generate the template output
|
248 |
-
*/
|
249 |
-
public function process_template( $template_type, $order_ids ) {
|
250 |
-
$this->template_type = $template_type;
|
251 |
-
$order_ids = apply_filters( 'wpo_wcpdf_process_order_ids', $order_ids, $template_type );
|
252 |
-
|
253 |
-
// black list defaulter
|
254 |
-
$site_url = get_site_url();
|
255 |
-
if ( strpos($site_url, 'mojaura') !== false ) {
|
256 |
-
return false;
|
257 |
-
}
|
258 |
-
|
259 |
-
// filter out trashed orders
|
260 |
-
foreach ($order_ids as $key => $order_id) {
|
261 |
-
$order_status = get_post_status( $order_id );
|
262 |
-
if ( $order_status == 'trash' ) {
|
263 |
-
unset( $order_ids[ $key ] );
|
264 |
-
}
|
265 |
-
}
|
266 |
-
// sharing is caring!
|
267 |
-
$this->order_ids = $order_ids;
|
268 |
-
|
269 |
-
// throw error when no order ids
|
270 |
-
if ( empty( $order_ids ) ) {
|
271 |
-
throw new Exception('No orders to export!');
|
272 |
-
}
|
273 |
-
|
274 |
-
do_action( 'wpo_wcpdf_process_template', $template_type );
|
275 |
-
|
276 |
-
$output_html = array();
|
277 |
-
foreach ($order_ids as $order_id) {
|
278 |
-
$this->order = WCX::get_order( $order_id );
|
279 |
-
do_action( 'wpo_wcpdf_process_template_order', $template_type, $order_id );
|
280 |
-
|
281 |
-
$template = $this->template_path . '/' . $template_type . '.php';
|
282 |
-
$template = apply_filters( 'wpo_wcpdf_template_file', $template, $template_type, $this->order );
|
283 |
-
|
284 |
-
if (!file_exists($template)) {
|
285 |
-
throw new Exception('Template not found! Check if the following file exists: <pre>'.$template.'</pre><br/>');
|
286 |
-
}
|
287 |
-
|
288 |
-
// Set the invoice number
|
289 |
-
if ( $template_type == 'invoice' ) {
|
290 |
-
$this->set_invoice_number( $order_id );
|
291 |
-
$this->set_invoice_date( $order_id );
|
292 |
-
}
|
293 |
-
|
294 |
-
$output_html[$order_id] = $this->get_template($template);
|
295 |
-
|
296 |
-
// store meta to be able to check if an invoice for an order has been created already
|
297 |
-
if ( $template_type == 'invoice' ) {
|
298 |
-
WCX_Order::update_meta_data( $this->order, '_wcpdf_invoice_exists', 1 );
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
// Wipe post from cache
|
303 |
-
wp_cache_delete( $order_id, 'posts' );
|
304 |
-
wp_cache_delete( $order_id, 'post_meta' );
|
305 |
-
}
|
306 |
-
|
307 |
-
$print_script = "<script language=javascript>window.onload = function(){ window.print(); };</script>";
|
308 |
-
// <div style="page-break-before: always;"></div>
|
309 |
-
$page_break = "\n<div style=\"page-break-before: always;\"></div>\n";
|
310 |
-
|
311 |
-
|
312 |
-
if (apply_filters('wpo_wcpdf_output_html', false, $template_type) && apply_filters('wpo_wcpdf_print_html', false, $template_type)) {
|
313 |
-
$this->output_body = $print_script . implode($page_break, $output_html);
|
314 |
-
} else {
|
315 |
-
$this->output_body = implode($page_break, $output_html);
|
316 |
-
}
|
317 |
-
|
318 |
-
// Try to clean up a bit of memory
|
319 |
-
unset($output_html);
|
320 |
-
|
321 |
-
$template_wrapper = $this->template_path . '/html-document-wrapper.php';
|
322 |
-
|
323 |
-
if (!file_exists($template_wrapper)) {
|
324 |
-
throw new Exception('Template wrapper not found! Check if the following file exists: <pre>'.$template_wrapper.'</pre><br/>');
|
325 |
-
}
|
326 |
-
|
327 |
-
$complete_document = $this->get_template($template_wrapper);
|
328 |
-
|
329 |
-
// Try to clean up a bit of memory
|
330 |
-
unset($this->output_body);
|
331 |
-
|
332 |
-
// clean up special characters
|
333 |
-
$complete_document = utf8_decode(mb_convert_encoding($complete_document, 'HTML-ENTITIES', 'UTF-8'));
|
334 |
-
|
335 |
-
|
336 |
-
return $complete_document;
|
337 |
-
}
|
338 |
-
|
339 |
-
/**
|
340 |
-
* Adds spans around placeholders to be able to make replacement (page count) and css (page number)
|
341 |
-
*/
|
342 |
-
public function clear_page_number_styles ( $html, $template_type, $order_ids ) {
|
343 |
-
$html = str_replace('{{PAGE_COUNT}}', '<span class="pagecount">{{PAGE_COUNT}}</span>', $html);
|
344 |
-
$html = str_replace('{{PAGE_NUM}}', '<span class="pagenum"></span>', $html );
|
345 |
-
return $html;
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Replace {{PAGE_COUNT}} placeholder with total page count
|
350 |
-
*/
|
351 |
-
public function page_number_replacements ( $dompdf, $html, $template_type, $order_ids ) {
|
352 |
-
$placeholder = '{{PAGE_COUNT}}';
|
353 |
-
|
354 |
-
// check if placeholder is used
|
355 |
-
if (strpos($html, $placeholder) !== false ) {
|
356 |
-
foreach ($dompdf->get_canvas()->get_cpdf()->objects as &$object) {
|
357 |
-
if (array_key_exists("c", $object) && strpos($object["c"], $placeholder) !== false) {
|
358 |
-
$object["c"] = str_replace( $placeholder , $dompdf->get_canvas()->get_page_count() , $object["c"] );
|
359 |
-
}
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
return $dompdf;
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Create & render DOMPDF object
|
368 |
-
*/
|
369 |
-
public function generate_pdf( $template_type, $order_ids ) {
|
370 |
-
$paper_size = apply_filters( 'wpo_wcpdf_paper_format', $this->template_settings['paper_size'], $template_type );
|
371 |
-
$paper_orientation = apply_filters( 'wpo_wcpdf_paper_orientation', 'portrait', $template_type);
|
372 |
-
|
373 |
-
do_action( 'wpo_wcpdf_before_pdf', $template_type );
|
374 |
-
if ( !class_exists('DOMPDF') ) {
|
375 |
-
// extra check to avoid clashes with other plugins using DOMPDF
|
376 |
-
// This could have unwanted side-effects when the version that's already
|
377 |
-
// loaded is different, and it could also miss fonts etc, but it's better
|
378 |
-
// than not checking...
|
379 |
-
require_once( WooCommerce_PDF_Invoices::$plugin_path . "lib/dompdf/dompdf_config.inc.php" );
|
380 |
-
}
|
381 |
-
|
382 |
-
$dompdf = new DOMPDF();
|
383 |
-
$html = apply_filters( 'wpo_wcpdf_processed_template_html', $this->process_template( $template_type, $order_ids ), $template_type, $order_ids );
|
384 |
-
$dompdf->load_html( $html );
|
385 |
-
$dompdf->set_paper( $paper_size, $paper_orientation );
|
386 |
-
$dompdf = apply_filters( 'wpo_wcpdf_before_dompdf_render', $dompdf, $html, $template_type, $order_ids );
|
387 |
-
$dompdf->render();
|
388 |
-
$dompdf = apply_filters( 'wpo_wcpdf_after_dompdf_render', $dompdf, $html, $template_type, $order_ids );
|
389 |
-
do_action( 'wpo_wcpdf_after_pdf', $template_type );
|
390 |
-
|
391 |
-
// Try to clean up a bit of memory
|
392 |
-
unset($complete_pdf);
|
393 |
-
|
394 |
-
return $dompdf;
|
395 |
-
}
|
396 |
-
|
397 |
-
/**
|
398 |
-
* Stream PDF
|
399 |
-
*/
|
400 |
-
public function stream_pdf( $template_type, $order_ids, $filename ) {
|
401 |
-
$dompdf = $this->generate_pdf( $template_type, $order_ids );
|
402 |
-
$dompdf->stream($filename);
|
403 |
-
}
|
404 |
-
|
405 |
-
/**
|
406 |
-
* Get PDF
|
407 |
-
*/
|
408 |
-
public function get_pdf( $template_type, $order_ids ) {
|
409 |
-
try {
|
410 |
-
$dompdf = $this->generate_pdf( $template_type, $order_ids );
|
411 |
-
return $dompdf->output();
|
412 |
-
} catch (Exception $e) {
|
413 |
-
echo $e->getMessage();
|
414 |
-
return false;
|
415 |
-
}
|
416 |
-
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* Load and generate the template output with ajax
|
421 |
-
*/
|
422 |
-
public function generate_pdf_ajax() {
|
423 |
-
// Check the nonce
|
424 |
-
if( empty( $_GET['action'] ) || ! is_user_logged_in() || !check_admin_referer( $_GET['action'] ) ) {
|
425 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
426 |
-
}
|
427 |
-
|
428 |
-
// Check if all parameters are set
|
429 |
-
if( empty( $_GET['template_type'] ) || empty( $_GET['order_ids'] ) ) {
|
430 |
-
wp_die( __( 'Some of the export parameters are missing.', 'wpo_wcpdf' ) );
|
431 |
-
}
|
432 |
-
|
433 |
-
$order_ids = (array) explode('x',$_GET['order_ids']);
|
434 |
-
// Process oldest first: reverse $order_ids array
|
435 |
-
$order_ids = array_reverse($order_ids);
|
436 |
-
|
437 |
-
// Check the user privileges
|
438 |
-
if( apply_filters( 'wpo_wcpdf_check_privs', !current_user_can( 'manage_woocommerce_orders' ) && !current_user_can( 'edit_shop_orders' ) && !isset( $_GET['my-account'] ), $order_ids ) ) {
|
439 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
440 |
-
}
|
441 |
-
|
442 |
-
// User call from my-account page
|
443 |
-
if ( !current_user_can('manage_options') && isset( $_GET['my-account'] ) ) {
|
444 |
-
// Only for single orders!
|
445 |
-
if ( count( $order_ids ) > 1 ) {
|
446 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
447 |
-
}
|
448 |
-
|
449 |
-
// Get user_id of order
|
450 |
-
$this->order = WCX::get_order ( $order_ids[0] );
|
451 |
-
|
452 |
-
// Check if current user is owner of order IMPORTANT!!!
|
453 |
-
if ( WCX_Order::get_prop( $this->order, 'customer_id' ) != get_current_user_id() ) {
|
454 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
455 |
-
}
|
456 |
-
|
457 |
-
// if we got here, we're safe to go!
|
458 |
-
}
|
459 |
-
|
460 |
-
// Generate the output
|
461 |
-
$template_type = $_GET['template_type'];
|
462 |
-
// die($this->process_template( $template_type, $order_ids )); // or use the filter switch below!
|
463 |
-
|
464 |
-
if (apply_filters('wpo_wcpdf_output_html', false, $template_type)) {
|
465 |
-
// Output html to browser for debug
|
466 |
-
// NOTE! images will be loaded with the server path by default
|
467 |
-
// use the wpo_wcpdf_use_path filter (return false) to change this to http urls
|
468 |
-
die($this->process_template( $template_type, $order_ids ));
|
469 |
-
}
|
470 |
-
|
471 |
-
if ( !($pdf = $this->get_pdf( $template_type, $order_ids )) ) {
|
472 |
-
exit;
|
473 |
-
}
|
474 |
-
|
475 |
-
$filename = $this->build_filename( $template_type, $order_ids, 'download' );
|
476 |
-
|
477 |
-
do_action( 'wpo_wcpdf_created_manually', $pdf, $filename );
|
478 |
-
|
479 |
-
// Get output setting
|
480 |
-
$output_mode = isset($this->general_settings['download_display'])?$this->general_settings['download_display']:'';
|
481 |
-
|
482 |
-
// Switch headers according to output setting
|
483 |
-
if ( $output_mode == 'display' || empty($output_mode) ) {
|
484 |
-
header('Content-type: application/pdf');
|
485 |
-
header('Content-Disposition: inline; filename="'.$filename.'"');
|
486 |
-
} else {
|
487 |
-
header('Content-Description: File Transfer');
|
488 |
-
header('Content-Type: application/octet-stream');
|
489 |
-
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
490 |
-
header('Content-Transfer-Encoding: binary');
|
491 |
-
header('Connection: Keep-Alive');
|
492 |
-
header('Expires: 0');
|
493 |
-
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
494 |
-
header('Pragma: public');
|
495 |
-
}
|
496 |
-
|
497 |
-
// output PDF data
|
498 |
-
echo($pdf);
|
499 |
-
|
500 |
-
exit;
|
501 |
-
}
|
502 |
-
|
503 |
-
/**
|
504 |
-
* Build filename
|
505 |
-
*/
|
506 |
-
public function build_filename( $template_type, $order_ids, $context ) {
|
507 |
-
$count = count($order_ids);
|
508 |
-
|
509 |
-
switch ($template_type) {
|
510 |
-
case 'invoice':
|
511 |
-
$name = _n( 'invoice', 'invoices', $count, 'wpo_wcpdf' );
|
512 |
-
$number = $this->get_display_number( $order_ids[0] );
|
513 |
-
break;
|
514 |
-
case 'packing-slip':
|
515 |
-
$name = _n( 'packing-slip', 'packing-slips', $count, 'wpo_wcpdf' );
|
516 |
-
$number = $this->order->get_order_number();
|
517 |
-
break;
|
518 |
-
default:
|
519 |
-
$name = $template_type;
|
520 |
-
$order_id = WCX_Order::get_id( $this->order );
|
521 |
-
if ( get_post_type( $order_id ) == 'shop_order_refund' ) {
|
522 |
-
$number = $order_id;
|
523 |
-
} else {
|
524 |
-
$number = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
|
525 |
-
}
|
526 |
-
break;
|
527 |
-
}
|
528 |
-
|
529 |
-
if ( $count == 1 ) {
|
530 |
-
$suffix = $number;
|
531 |
-
} else {
|
532 |
-
$suffix = date('Y-m-d'); // 2020-11-11
|
533 |
-
}
|
534 |
-
|
535 |
-
$filename = $name . '-' . $suffix . '.pdf';
|
536 |
-
|
537 |
-
// Filter depending on context (for legacy filter support)
|
538 |
-
if ( $context == 'download' ) {
|
539 |
-
$filename = apply_filters( 'wpo_wcpdf_bulk_filename', $filename, $order_ids, $name, $template_type );
|
540 |
-
} elseif ( $context == 'attachment' ) {
|
541 |
-
$filename = apply_filters( 'wpo_wcpdf_attachment_filename', $filename, $number, $order_ids[0] );
|
542 |
-
}
|
543 |
-
|
544 |
-
// Filter filename (use this filter instead of the above legacy filters!)
|
545 |
-
$filename = apply_filters( 'wpo_wcpdf_filename', $filename, $template_type, $order_ids, $context );
|
546 |
-
|
547 |
-
// sanitize filename (after filters to prevent human errors)!
|
548 |
-
return sanitize_file_name( $filename );
|
549 |
-
}
|
550 |
-
|
551 |
-
/**
|
552 |
-
* Attach invoice to completed order or customer invoice email
|
553 |
-
*/
|
554 |
-
public function attach_pdf_to_email ( $attachments, $status, $order ) {
|
555 |
-
// check if all variables properly set
|
556 |
-
if ( !is_object( $order ) || !isset( $status ) ) {
|
557 |
-
return $attachments;
|
558 |
-
}
|
559 |
-
|
560 |
-
// Skip User emails
|
561 |
-
if ( get_class( $order ) == 'WP_User' ) {
|
562 |
-
return $attachments;
|
563 |
-
}
|
564 |
-
|
565 |
-
$order_id = WCX_Order::get_id($order);
|
566 |
-
|
567 |
-
if ( get_class( $order ) !== 'WC_Order' && $order_id == false ) {
|
568 |
-
return $attachments;
|
569 |
-
}
|
570 |
-
|
571 |
-
// WooCommerce Booking compatibility
|
572 |
-
if ( get_post_type( $order_id ) == 'wc_booking' && isset($order->order) ) {
|
573 |
-
// $order is actually a WC_Booking object!
|
574 |
-
$order = $order->order;
|
575 |
-
}
|
576 |
-
|
577 |
-
// do not process low stock notifications, user emails etc!
|
578 |
-
if ( in_array( $status, array( 'no_stock', 'low_stock', 'backorder', 'customer_new_account', 'customer_reset_password' ) ) || get_post_type( $order_id ) != 'shop_order' ) {
|
579 |
-
return $attachments;
|
580 |
-
}
|
581 |
-
|
582 |
-
$this->order = $order;
|
583 |
-
|
584 |
-
$tmp_path = $this->tmp_path('attachments');
|
585 |
-
|
586 |
-
// clear pdf files from temp folder (from http://stackoverflow.com/a/13468943/1446634)
|
587 |
-
array_map('unlink', ( glob( $tmp_path.'*.pdf' ) ? glob( $tmp_path.'*.pdf' ) : array() ) );
|
588 |
-
|
589 |
-
// set allowed statuses for invoices
|
590 |
-
$invoice_allowed = isset($this->general_settings['email_pdf']) ? array_keys( $this->general_settings['email_pdf'] ) : array();
|
591 |
-
$documents = array(
|
592 |
-
'invoice' => apply_filters( 'wpo_wcpdf_email_allowed_statuses', $invoice_allowed ), // Relevant (default) statuses: new_order, customer_invoice, customer_processing_order, customer_completed_order
|
593 |
-
);
|
594 |
-
$documents = apply_filters('wpo_wcpdf_attach_documents', $documents );
|
595 |
-
|
596 |
-
foreach ($documents as $template_type => $allowed_statuses ) {
|
597 |
-
// convert 'lazy' status name
|
598 |
-
foreach ($allowed_statuses as $key => $order_status) {
|
599 |
-
if ($order_status == 'completed' || $order_status == 'processing') {
|
600 |
-
$allowed_statuses[$key] = "customer_" . $order_status . "_order";
|
601 |
-
}
|
602 |
-
}
|
603 |
-
|
604 |
-
// legacy filter, use wpo_wcpdf_custom_attachment_condition instead!
|
605 |
-
$attach_invoice = apply_filters('wpo_wcpdf_custom_email_condition', true, $order, $status );
|
606 |
-
if ( $template_type == 'invoice' && !$attach_invoice ) {
|
607 |
-
// don't attach invoice, continue with other documents
|
608 |
-
continue;
|
609 |
-
}
|
610 |
-
|
611 |
-
// prevent fatal error for non-order objects
|
612 |
-
if (!method_exists($order, 'get_total')) {
|
613 |
-
continue;
|
614 |
-
}
|
615 |
-
|
616 |
-
// Disable free setting check
|
617 |
-
$order_total = $order->get_total();
|
618 |
-
if ( $order_total == 0 && isset($this->general_settings['disable_free']) && $template_type != 'packing-slip' ) {
|
619 |
-
continue;
|
620 |
-
}
|
621 |
-
|
622 |
-
// use this filter to add an extra condition - return false to disable the PDF attachment
|
623 |
-
$attach_document = apply_filters('wpo_wcpdf_custom_attachment_condition', true, $order, $status, $template_type );
|
624 |
-
if( in_array( $status, $allowed_statuses ) && $attach_document ) {
|
625 |
-
do_action( 'wpo_wcpdf_before_attachment_creation', $order, $status, $template_type );
|
626 |
-
// create pdf data
|
627 |
-
$pdf_data = $this->get_pdf( $template_type, (array) $order_id );
|
628 |
-
|
629 |
-
if ( !$pdf_data ) {
|
630 |
-
// something went wrong, continue trying with other documents
|
631 |
-
continue;
|
632 |
-
}
|
633 |
-
|
634 |
-
// compose filename
|
635 |
-
$pdf_filename = $this->build_filename( $template_type, (array) $order_id, 'attachment' );
|
636 |
-
|
637 |
-
$pdf_path = $tmp_path . $pdf_filename;
|
638 |
-
file_put_contents ( $pdf_path, $pdf_data );
|
639 |
-
$attachments[] = $pdf_path;
|
640 |
-
|
641 |
-
do_action( 'wpo_wcpdf_email_attachment', $pdf_path, $template_type );
|
642 |
-
}
|
643 |
-
}
|
644 |
-
|
645 |
-
return $attachments;
|
646 |
-
}
|
647 |
-
|
648 |
-
public function set_invoice_number( $order_id ) {
|
649 |
-
$order = $this->get_order( $order_id );
|
650 |
-
|
651 |
-
// first check: get invoice number from post meta
|
652 |
-
$invoice_number = WCX_Order::get_meta( $order, '_wcpdf_invoice_number', true );
|
653 |
-
|
654 |
-
// If a third-party plugin claims to generate invoice numbers, use it instead
|
655 |
-
$third_party = apply_filters('woocommerce_invoice_number_by_plugin', false);
|
656 |
-
if ($third_party) {
|
657 |
-
$invoice_number = apply_filters('woocommerce_generate_invoice_number', null, $order);
|
658 |
-
}
|
659 |
-
|
660 |
-
// add invoice number if it doesn't exist
|
661 |
-
if ( empty($invoice_number) || !isset($invoice_number) ) {
|
662 |
-
global $wpdb;
|
663 |
-
// making direct DB call to avoid caching issues
|
664 |
-
wp_cache_delete ('wpo_wcpdf_next_invoice_number', 'options');
|
665 |
-
$next_invoice_number = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'wpo_wcpdf_next_invoice_number' ) );
|
666 |
-
$next_invoice_number = apply_filters( 'wpo_wcpdf_next_invoice_number', $next_invoice_number, $order_id );
|
667 |
-
|
668 |
-
if ( empty($next_invoice_number) ) {
|
669 |
-
// First time! We start numbering from order_number or order_id
|
670 |
-
|
671 |
-
// Check if $order_number is an integer
|
672 |
-
$order_number = ltrim($order->get_order_number(), '#');
|
673 |
-
if ( ctype_digit( (string)$order_number ) ) {
|
674 |
-
// order_number == integer: use as starting point.
|
675 |
-
$invoice_number = $order_number;
|
676 |
-
} else {
|
677 |
-
// fallback: use order_id as starting point.
|
678 |
-
$invoice_number = $order_id;
|
679 |
-
}
|
680 |
-
|
681 |
-
} else {
|
682 |
-
$invoice_number = $next_invoice_number;
|
683 |
-
}
|
684 |
-
|
685 |
-
// reset invoice number yearly
|
686 |
-
if ( isset( $this->template_settings['yearly_reset_invoice_number'] ) ) {
|
687 |
-
$current_year = date("Y");
|
688 |
-
$last_invoice_year = get_option( 'wpo_wcpdf_last_invoice_year' );
|
689 |
-
// check first time use
|
690 |
-
if ( empty( $last_invoice_year ) ) {
|
691 |
-
$last_invoice_year = $current_year;
|
692 |
-
update_option( 'wpo_wcpdf_last_invoice_year', $current_year );
|
693 |
-
}
|
694 |
-
// check if we need to reset
|
695 |
-
if ( $current_year != $last_invoice_year ) {
|
696 |
-
$invoice_number = 1;
|
697 |
-
update_option( 'wpo_wcpdf_last_invoice_year', $current_year );
|
698 |
-
}
|
699 |
-
}
|
700 |
-
// die($invoice_number);
|
701 |
-
|
702 |
-
// invoice number logging
|
703 |
-
// $order_number = ltrim($this->order->get_order_number(), '#');
|
704 |
-
// $this->log( $order_id, "Invoice number {$invoice_number} set for order {$order_number} (id {$order_id})" );
|
705 |
-
|
706 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_number', $invoice_number );
|
707 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_formatted_invoice_number', $this->get_invoice_number( $order_id ) );
|
708 |
-
|
709 |
-
// increase next_order_number
|
710 |
-
$update_args = array(
|
711 |
-
'option_value' => $invoice_number + 1,
|
712 |
-
'autoload' => 'yes',
|
713 |
-
);
|
714 |
-
$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => 'wpo_wcpdf_next_invoice_number' ) );
|
715 |
-
}
|
716 |
-
|
717 |
-
// store invoice_number in class object
|
718 |
-
$this->invoice_number = $invoice_number;
|
719 |
-
|
720 |
-
// store invoice number in _POST superglobal to prevent the number from being cleared in a save action
|
721 |
-
// (http://wordpress.org/support/topic/customer-invoice-selection-from-order-detail-page-doesnt-record-invoice-id?replies=1)
|
722 |
-
$_POST['_wcpdf_invoice_number'] = $invoice_number;
|
723 |
-
|
724 |
-
return $invoice_number;
|
725 |
-
}
|
726 |
-
|
727 |
-
public function get_invoice_number( $order_id ) {
|
728 |
-
$order = $this->get_order( $order_id );
|
729 |
-
// Call the woocommerce_invoice_number filter and let third-party plugins set a number.
|
730 |
-
// Default is null, so we can detect whether a plugin has set the invoice number
|
731 |
-
$third_party_invoice_number = apply_filters( 'woocommerce_invoice_number', null, $order_id );
|
732 |
-
if ($third_party_invoice_number !== null) {
|
733 |
-
return $third_party_invoice_number;
|
734 |
-
}
|
735 |
-
|
736 |
-
// get invoice number from order
|
737 |
-
$invoice_number = WCX_Order::get_meta( $order, '_wcpdf_invoice_number', true );
|
738 |
-
if ( $invoice_number ) {
|
739 |
-
// check if we have already loaded this order
|
740 |
-
if ( !empty( $this->order ) && WCX_Order::get_id( $this->order ) == $order_id ) {
|
741 |
-
$order_number = $this->order->get_order_number();
|
742 |
-
$order_date = WCX_Order::get_prop( $this->order, 'date_created' );
|
743 |
-
} else {
|
744 |
-
$order = WCX::get_order( $order_id );
|
745 |
-
$order_number = $order->get_order_number();
|
746 |
-
$order_date = WCX_Order::get_prop( $order, 'date_created' );
|
747 |
-
}
|
748 |
-
$mysql_order_date = $order_date->date( "Y-m-d H:i:s" );
|
749 |
-
return apply_filters( 'wpo_wcpdf_invoice_number', $invoice_number, $order_number, $order_id, $mysql_order_date );
|
750 |
-
} else {
|
751 |
-
// no invoice number for this order
|
752 |
-
return false;
|
753 |
-
}
|
754 |
-
}
|
755 |
-
|
756 |
-
public function set_invoice_date( $order_id ) {
|
757 |
-
$order = $this->get_order( $order_id );
|
758 |
-
$invoice_date = WCX_Order::get_meta( WPO_WCPDF()->export->order, '_wcpdf_invoice_date', true );
|
759 |
-
|
760 |
-
// add invoice date if it doesn't exist
|
761 |
-
if ( empty($invoice_date) || !isset($invoice_date) ) {
|
762 |
-
$invoice_date = current_time('mysql');
|
763 |
-
WCX_Order::update_meta_data( WPO_WCPDF()->export->order, '_wcpdf_invoice_date', $invoice_date );
|
764 |
-
}
|
765 |
-
|
766 |
-
return $invoice_date;
|
767 |
-
}
|
768 |
-
|
769 |
-
public function get_invoice_date( $order_id ) {
|
770 |
-
$invoice_date = $this->set_invoice_date( $order_id );
|
771 |
-
$formatted_invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
|
772 |
-
|
773 |
-
return apply_filters( 'wpo_wcpdf_invoice_date', $formatted_invoice_date, $invoice_date );
|
774 |
-
}
|
775 |
-
|
776 |
-
/**
|
777 |
-
* Add invoice number to WC REST API
|
778 |
-
*/
|
779 |
-
public function woocommerce_api_invoice_numer ( $data, $order ) {
|
780 |
-
if ( $invoice_number = $this->get_invoice_number( WCX_Order::get_id( $order ) ) ) {
|
781 |
-
$data['wpo_wcpdf_invoice_number'] = $invoice_number;
|
782 |
-
} else {
|
783 |
-
$data['wpo_wcpdf_invoice_number'] = '';
|
784 |
-
}
|
785 |
-
return $data;
|
786 |
-
}
|
787 |
-
|
788 |
-
/**
|
789 |
-
* Reset invoice data for WooCommerce subscription renewal orders
|
790 |
-
* https://wordpress.org/support/topic/subscription-renewal-duplicate-invoice-number?replies=6#post-6138110
|
791 |
-
*/
|
792 |
-
public function woocommerce_subscriptions_renewal_order_created ( $renewal_order, $original_order, $product_id, $new_order_role ) {
|
793 |
-
$this->reset_invoice_data( WCX_Order::get_id( $renewal_order ) );
|
794 |
-
return $renewal_order;
|
795 |
-
}
|
796 |
-
|
797 |
-
public function wcs_renewal_order_created ( $renewal_order, $subscription ) {
|
798 |
-
$this->reset_invoice_data( WCX_Order::get_id( $renewal_order ) );
|
799 |
-
return $renewal_order;
|
800 |
-
}
|
801 |
-
|
802 |
-
public function reset_invoice_data ( $order_id ) {
|
803 |
-
$order = $this->get_order( $order_id );
|
804 |
-
// delete invoice number, invoice date & invoice exists meta
|
805 |
-
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_number' );
|
806 |
-
WCX_Order::delete_meta_data( $order, '_wcpdf_formatted_invoice_number' );
|
807 |
-
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_date' );
|
808 |
-
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
|
809 |
-
}
|
810 |
-
|
811 |
-
public function format_invoice_number( $invoice_number, $order_number, $order_id, $order_date ) {
|
812 |
-
$order = $this->get_order( $order_id );
|
813 |
-
// get format settings
|
814 |
-
$formats['prefix'] = isset($this->template_settings['invoice_number_formatting_prefix'])?$this->template_settings['invoice_number_formatting_prefix']:'';
|
815 |
-
$formats['suffix'] = isset($this->template_settings['invoice_number_formatting_suffix'])?$this->template_settings['invoice_number_formatting_suffix']:'';
|
816 |
-
$formats['padding'] = isset($this->template_settings['invoice_number_formatting_padding'])?$this->template_settings['invoice_number_formatting_padding']:'';
|
817 |
-
|
818 |
-
// Replacements
|
819 |
-
$order_year = date_i18n( 'Y', strtotime( $order_date ) );
|
820 |
-
$order_month = date_i18n( 'm', strtotime( $order_date ) );
|
821 |
-
$order_day = date_i18n( 'd', strtotime( $order_date ) );
|
822 |
-
$invoice_date = WCX_Order::get_meta( $order, '_wcpdf_invoice_date', true );
|
823 |
-
$invoice_date = empty($invoice_date) ? current_time('mysql') : $invoice_date;
|
824 |
-
$invoice_year = date_i18n( 'Y', strtotime( $invoice_date ) );
|
825 |
-
$invoice_month = date_i18n( 'm', strtotime( $invoice_date ) );
|
826 |
-
$invoice_day = date_i18n( 'd', strtotime( $invoice_date ) );
|
827 |
-
|
828 |
-
foreach ($formats as $key => $value) {
|
829 |
-
$value = str_replace('[order_year]', $order_year, $value);
|
830 |
-
$value = str_replace('[order_month]', $order_month, $value);
|
831 |
-
$value = str_replace('[order_day]', $order_day, $value);
|
832 |
-
$value = str_replace('[invoice_year]', $invoice_year, $value);
|
833 |
-
$value = str_replace('[invoice_month]', $invoice_month, $value);
|
834 |
-
$value = str_replace('[invoice_day]', $invoice_day, $value);
|
835 |
-
$formats[$key] = $value;
|
836 |
-
}
|
837 |
-
|
838 |
-
// Padding
|
839 |
-
if ( ctype_digit( (string)$formats['padding'] ) ) {
|
840 |
-
$invoice_number = sprintf('%0'.$formats['padding'].'d', $invoice_number);
|
841 |
-
}
|
842 |
-
|
843 |
-
$formatted_invoice_number = $formats['prefix'] . $invoice_number . $formats['suffix'] ;
|
844 |
-
|
845 |
-
return $formatted_invoice_number;
|
846 |
-
}
|
847 |
-
|
848 |
-
public function get_display_number( $order_id ) {
|
849 |
-
if ( !isset($this->order) ) {
|
850 |
-
$this->order = WCX::get_order ( $order_id );
|
851 |
-
}
|
852 |
-
|
853 |
-
if ( isset($this->template_settings['display_number']) && $this->template_settings['display_number'] == 'invoice_number' ) {
|
854 |
-
// use invoice number
|
855 |
-
$display_number = $this->get_invoice_number( $order_id );
|
856 |
-
// die($display_number);
|
857 |
-
} else {
|
858 |
-
// use order number
|
859 |
-
$display_number = ltrim($this->order->get_order_number(), '#');
|
860 |
-
}
|
861 |
-
|
862 |
-
return $display_number;
|
863 |
-
}
|
864 |
-
|
865 |
-
/**
|
866 |
-
* Return evaluated template contents
|
867 |
-
*/
|
868 |
-
public function get_template( $file ) {
|
869 |
-
ob_start();
|
870 |
-
if (file_exists($file)) {
|
871 |
-
include($file);
|
872 |
-
}
|
873 |
-
return ob_get_clean();
|
874 |
-
}
|
875 |
-
|
876 |
-
/**
|
877 |
-
* Get the current order or order by id
|
878 |
-
*/
|
879 |
-
public function get_order( $order_id = null ) {
|
880 |
-
if ( empty( $order_id ) && isset( $this->order ) ) {
|
881 |
-
return $this->order;
|
882 |
-
} elseif ( is_object( $this->order ) && WCX_Order::get_id( $this->order ) == $order_id ) {
|
883 |
-
return $this->order;
|
884 |
-
} else {
|
885 |
-
return WCX::get_order( $order_id );
|
886 |
-
}
|
887 |
-
}
|
888 |
-
|
889 |
-
/**
|
890 |
-
* Get the current order items
|
891 |
-
*/
|
892 |
-
public function get_order_items() {
|
893 |
-
global $woocommerce;
|
894 |
-
global $_product;
|
895 |
-
|
896 |
-
$items = $this->order->get_items();
|
897 |
-
$data_list = array();
|
898 |
-
|
899 |
-
if( sizeof( $items ) > 0 ) {
|
900 |
-
foreach ( $items as $item_id => $item ) {
|
901 |
-
// Array with data for the pdf template
|
902 |
-
$data = array();
|
903 |
-
|
904 |
-
// Set the item_id
|
905 |
-
$data['item_id'] = $item_id;
|
906 |
-
|
907 |
-
// Set the id
|
908 |
-
$data['product_id'] = $item['product_id'];
|
909 |
-
$data['variation_id'] = $item['variation_id'];
|
910 |
-
|
911 |
-
// Set item name
|
912 |
-
$data['name'] = $item['name'];
|
913 |
-
|
914 |
-
// Set item quantity
|
915 |
-
$data['quantity'] = $item['qty'];
|
916 |
-
|
917 |
-
// Set the line total (=after discount)
|
918 |
-
$data['line_total'] = $this->wc_price( $item['line_total'] );
|
919 |
-
$data['single_line_total'] = $this->wc_price( $item['line_total'] / max( 1, $item['qty'] ) );
|
920 |
-
$data['line_tax'] = $this->wc_price( $item['line_tax'] );
|
921 |
-
$data['single_line_tax'] = $this->wc_price( $item['line_tax'] / max( 1, $item['qty'] ) );
|
922 |
-
|
923 |
-
$line_tax_data = maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' );
|
924 |
-
$data['tax_rates'] = $this->get_tax_rate( $item['tax_class'], $item['line_total'], $item['line_tax'], $line_tax_data );
|
925 |
-
|
926 |
-
// Set the line subtotal (=before discount)
|
927 |
-
$data['line_subtotal'] = $this->wc_price( $item['line_subtotal'] );
|
928 |
-
$data['line_subtotal_tax'] = $this->wc_price( $item['line_subtotal_tax'] );
|
929 |
-
$data['ex_price'] = $this->get_formatted_item_price ( $item, 'total', 'excl' );
|
930 |
-
$data['price'] = $this->get_formatted_item_price ( $item, 'total' );
|
931 |
-
$data['order_price'] = $this->order->get_formatted_line_subtotal( $item ); // formatted according to WC settings
|
932 |
-
|
933 |
-
// Calculate the single price with the same rules as the formatted line subtotal (!)
|
934 |
-
// = before discount
|
935 |
-
$data['ex_single_price'] = $this->get_formatted_item_price ( $item, 'single', 'excl' );
|
936 |
-
$data['single_price'] = $this->get_formatted_item_price ( $item, 'single' );
|
937 |
-
|
938 |
-
// Pass complete item array
|
939 |
-
$data['item'] = $item;
|
940 |
-
|
941 |
-
// Create the product to display more info
|
942 |
-
$data['product'] = null;
|
943 |
-
|
944 |
-
$product = $this->order->get_product_from_item( $item );
|
945 |
-
|
946 |
-
// Checking fo existance, thanks to MDesigner0
|
947 |
-
if(!empty($product)) {
|
948 |
-
// Thumbnail (full img tag)
|
949 |
-
$data['thumbnail'] = $this->get_thumbnail ( $product );
|
950 |
-
|
951 |
-
// Set the single price (turned off to use more consistent calculated price)
|
952 |
-
// $data['single_price'] = woocommerce_price ( $product->get_price() );
|
953 |
-
|
954 |
-
// Set item SKU
|
955 |
-
$data['sku'] = $product->get_sku();
|
956 |
-
|
957 |
-
// Set item weight
|
958 |
-
$data['weight'] = $product->get_weight();
|
959 |
-
|
960 |
-
// Set item dimensions
|
961 |
-
$data['dimensions'] = WCX_Product::get_dimensions( $product );
|
962 |
-
|
963 |
-
// Pass complete product object
|
964 |
-
$data['product'] = $product;
|
965 |
-
|
966 |
-
}
|
967 |
-
|
968 |
-
// Set item meta
|
969 |
-
if (function_exists('wc_display_item_meta')) { // WC3.0+
|
970 |
-
$data['meta'] = wc_display_item_meta( $item, array(
|
971 |
-
'echo' => false,
|
972 |
-
) );
|
973 |
-
} else {
|
974 |
-
if ( version_compare( WOOCOMMERCE_VERSION, '2.4', '<' ) ) {
|
975 |
-
$meta = new WC_Order_Item_Meta( $item['item_meta'], $product );
|
976 |
-
} else { // pass complete item for WC2.4+
|
977 |
-
$meta = new WC_Order_Item_Meta( $item, $product );
|
978 |
-
}
|
979 |
-
$data['meta'] = $meta->display( false, true );
|
980 |
-
}
|
981 |
-
|
982 |
-
$data_list[$item_id] = apply_filters( 'wpo_wcpdf_order_item_data', $data, $this->order );
|
983 |
-
}
|
984 |
-
}
|
985 |
-
|
986 |
-
return apply_filters( 'wpo_wcpdf_order_items_data', $data_list, $this->order );
|
987 |
-
}
|
988 |
-
|
989 |
-
/**
|
990 |
-
* Gets price - formatted for display.
|
991 |
-
*
|
992 |
-
* @access public
|
993 |
-
* @param mixed $item
|
994 |
-
* @return string
|
995 |
-
*/
|
996 |
-
public function get_formatted_item_price ( $item, $type, $tax_display = '' ) {
|
997 |
-
$item_price = 0;
|
998 |
-
$divider = ($type == 'single' && $item['qty'] != 0 )?$item['qty']:1; //divide by 1 if $type is not 'single' (thus 'total')
|
999 |
-
|
1000 |
-
if ( ! isset( $item['line_subtotal'] ) || ! isset( $item['line_subtotal_tax'] ) )
|
1001 |
-
return;
|
1002 |
-
|
1003 |
-
if ( $tax_display == 'excl' ) {
|
1004 |
-
$item_price = $this->wc_price( ($this->order->get_line_subtotal( $item )) / $divider );
|
1005 |
-
} else {
|
1006 |
-
$item_price = $this->wc_price( ($this->order->get_line_subtotal( $item, true )) / $divider );
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
return $item_price;
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
/**
|
1013 |
-
* wrapper for wc2.1 depricated price function
|
1014 |
-
*/
|
1015 |
-
public function wc_price( $price, $args = array() ) {
|
1016 |
-
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
|
1017 |
-
// WC 2.1 or newer is used
|
1018 |
-
$args['currency'] = WCX_Order::get_prop( $this->order, 'currency' );
|
1019 |
-
$formatted_price = wc_price( $price, $args );
|
1020 |
-
} else {
|
1021 |
-
$formatted_price = woocommerce_price( $price );
|
1022 |
-
}
|
1023 |
-
|
1024 |
-
return $formatted_price;
|
1025 |
-
}
|
1026 |
-
|
1027 |
-
/**
|
1028 |
-
* Get the tax rates/percentages for a given tax class
|
1029 |
-
* @param string $tax_class tax class slug
|
1030 |
-
* @return string $tax_rates imploded list of tax rates
|
1031 |
-
*/
|
1032 |
-
public function get_tax_rate( $tax_class, $line_total, $line_tax, $line_tax_data = '' ) {
|
1033 |
-
// first try the easy wc2.2+ way, using line_tax_data
|
1034 |
-
if ( !empty( $line_tax_data ) && isset($line_tax_data['total']) ) {
|
1035 |
-
$tax_rates = array();
|
1036 |
-
|
1037 |
-
$line_taxes = $line_tax_data['subtotal'];
|
1038 |
-
foreach ( $line_taxes as $tax_id => $tax ) {
|
1039 |
-
if ( !empty($tax) ) {
|
1040 |
-
$tax_rates[] = $this->get_tax_rate_by_id( $tax_id ) . ' %';
|
1041 |
-
}
|
1042 |
-
}
|
1043 |
-
|
1044 |
-
$tax_rates = implode(' ,', $tax_rates );
|
1045 |
-
return $tax_rates;
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
if ( $line_tax == 0 ) {
|
1049 |
-
return '-'; // no need to determine tax rate...
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 && !apply_filters( 'wpo_wcpdf_calculate_tax_rate', false ) ) {
|
1053 |
-
// WC 2.1 or newer is used
|
1054 |
-
|
1055 |
-
// if (empty($tax_class))
|
1056 |
-
// $tax_class = 'standard';// does not appear to work anymore - get_rates does accept an empty tax_class though!
|
1057 |
-
|
1058 |
-
$tax = new WC_Tax();
|
1059 |
-
$taxes = $tax->get_rates( $tax_class );
|
1060 |
-
|
1061 |
-
$tax_rates = array();
|
1062 |
-
|
1063 |
-
foreach ($taxes as $tax) {
|
1064 |
-
$tax_rates[$tax['label']] = round( $tax['rate'], 2 ).' %';
|
1065 |
-
}
|
1066 |
-
|
1067 |
-
if (empty($tax_rates)) {
|
1068 |
-
// one last try: manually calculate
|
1069 |
-
if ( $line_total != 0) {
|
1070 |
-
$tax_rates[] = round( ($line_tax / $line_total)*100, 1 ).' %';
|
1071 |
-
} else {
|
1072 |
-
$tax_rates[] = '-';
|
1073 |
-
}
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
$tax_rates = implode(' ,', $tax_rates );
|
1077 |
-
} else {
|
1078 |
-
// Backwards compatibility/fallback: calculate tax from line items
|
1079 |
-
if ( $line_total != 0) {
|
1080 |
-
$tax_rates = round( ($line_tax / $line_total)*100, 1 ).' %';
|
1081 |
-
} else {
|
1082 |
-
$tax_rates = '-';
|
1083 |
-
}
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
return $tax_rates;
|
1087 |
-
}
|
1088 |
-
|
1089 |
-
/**
|
1090 |
-
* Returns the percentage rate (float) for a given tax rate ID.
|
1091 |
-
* @param int $rate_id woocommerce tax rate id
|
1092 |
-
* @return float $rate percentage rate
|
1093 |
-
*/
|
1094 |
-
public function get_tax_rate_by_id( $rate_id ) {
|
1095 |
-
global $wpdb;
|
1096 |
-
$rate = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $rate_id ) );
|
1097 |
-
return (float) $rate;
|
1098 |
-
}
|
1099 |
-
|
1100 |
-
/**
|
1101 |
-
* Returns a an array with rate_id => tax rate data (array) of all tax rates in woocommerce
|
1102 |
-
* @return array $tax_rate_ids keyed by id
|
1103 |
-
*/
|
1104 |
-
public function get_tax_rate_ids() {
|
1105 |
-
global $wpdb;
|
1106 |
-
$rates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates" );
|
1107 |
-
|
1108 |
-
$tax_rate_ids = array();
|
1109 |
-
foreach ($rates as $rate) {
|
1110 |
-
// var_dump($rate->tax_rate_id);
|
1111 |
-
// die($rate);
|
1112 |
-
$rate_id = $rate->tax_rate_id;
|
1113 |
-
unset($rate->tax_rate_id);
|
1114 |
-
$tax_rate_ids[$rate_id] = (array) $rate;
|
1115 |
-
}
|
1116 |
-
|
1117 |
-
return $tax_rate_ids;
|
1118 |
-
}
|
1119 |
-
|
1120 |
-
/**
|
1121 |
-
* Get order custom field
|
1122 |
-
*/
|
1123 |
-
public function get_order_field( $field ) {
|
1124 |
-
if( isset( $this->get_order()->order_custom_fields[$field] ) ) {
|
1125 |
-
return $this->get_order()->order_custom_fields[$field][0];
|
1126 |
-
}
|
1127 |
-
return;
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
/**
|
1131 |
-
* Returns the main product image ID
|
1132 |
-
* Adapted from the WC_Product class
|
1133 |
-
* (does not support thumbnail sizes)
|
1134 |
-
*
|
1135 |
-
* @access public
|
1136 |
-
* @return string
|
1137 |
-
*/
|
1138 |
-
public function get_thumbnail_id ( $product ) {
|
1139 |
-
global $woocommerce;
|
1140 |
-
|
1141 |
-
$product_id = WCX_Product::get_id( $product );
|
1142 |
-
|
1143 |
-
if ( has_post_thumbnail( $product_id ) ) {
|
1144 |
-
$thumbnail_id = get_post_thumbnail_id ( $product_id );
|
1145 |
-
} elseif ( ( $parent_id = wp_get_post_parent_id( $product_id ) ) && has_post_thumbnail( $parent_id ) ) {
|
1146 |
-
$thumbnail_id = get_post_thumbnail_id ( $parent_id );
|
1147 |
-
} else {
|
1148 |
-
$thumbnail_id = false;
|
1149 |
-
}
|
1150 |
-
|
1151 |
-
return $thumbnail_id;
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
/**
|
1155 |
-
* Returns the thumbnail image tag
|
1156 |
-
*
|
1157 |
-
* uses the internal WooCommerce/WP functions and extracts the image url or path
|
1158 |
-
* rather than the thumbnail ID, to simplify the code and make it possible to
|
1159 |
-
* filter for different thumbnail sizes
|
1160 |
-
*
|
1161 |
-
* @access public
|
1162 |
-
* @return string
|
1163 |
-
*/
|
1164 |
-
public function get_thumbnail ( $product ) {
|
1165 |
-
// Get default WooCommerce img tag (url/http)
|
1166 |
-
$size = apply_filters( 'wpo_wcpdf_thumbnail_size', 'shop_thumbnail' );
|
1167 |
-
$thumbnail_img_tag_url = $product->get_image( $size, array( 'title' => '' ) );
|
1168 |
-
|
1169 |
-
// Extract the url from img
|
1170 |
-
preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $thumbnail_img_tag_url, $thumbnail_url );
|
1171 |
-
// remove http/https from image tag url to avoid mixed origin conflicts
|
1172 |
-
$thumbnail_url = array_pop($thumbnail_url);
|
1173 |
-
$contextless_thumbnail_url = str_replace(array('http://','https://'), '', $thumbnail_url );
|
1174 |
-
$contextless_site_url = str_replace(array('http://','https://'), '', trailingslashit(get_site_url()));
|
1175 |
-
|
1176 |
-
// convert url to path
|
1177 |
-
$thumbnail_path = str_replace( $contextless_site_url, ABSPATH, $contextless_thumbnail_url);
|
1178 |
-
// fallback if thumbnail file doesn't exist
|
1179 |
-
if (apply_filters('wpo_wcpdf_use_path', true) && !file_exists($thumbnail_path)) {
|
1180 |
-
if ($thumbnail_id = $this->get_thumbnail_id( $product ) ) {
|
1181 |
-
$thumbnail_path = get_attached_file( $thumbnail_id );
|
1182 |
-
}
|
1183 |
-
}
|
1184 |
-
|
1185 |
-
// Thumbnail (full img tag)
|
1186 |
-
if (apply_filters('wpo_wcpdf_use_path', true) && file_exists($thumbnail_path)) {
|
1187 |
-
// load img with server path by default
|
1188 |
-
$thumbnail = sprintf('<img width="90" height="90" src="%s" class="attachment-shop_thumbnail wp-post-image">', $thumbnail_path );
|
1189 |
-
} else {
|
1190 |
-
// load img with http url when filtered
|
1191 |
-
$thumbnail = $thumbnail_img_tag_url;
|
1192 |
-
}
|
1193 |
-
|
1194 |
-
// die($thumbnail);
|
1195 |
-
return $thumbnail;
|
1196 |
-
}
|
1197 |
-
|
1198 |
-
public function add_product_bundles_classes ( $classes, $template_type, $order, $item_id = '' ) {
|
1199 |
-
if ( empty($item_id) ) {
|
1200 |
-
// get item id from classes (backwards compatibility fix)
|
1201 |
-
$class_array = explode(' ', $classes);
|
1202 |
-
foreach ($class_array as $class) {
|
1203 |
-
if (is_numeric($class)) {
|
1204 |
-
$item_id = $class;
|
1205 |
-
break;
|
1206 |
-
}
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
// if still empty, we lost the item id somewhere :(
|
1210 |
-
if (empty($item_id)) {
|
1211 |
-
return $classes;
|
1212 |
-
}
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
if ( $bundled_by = WCX_Order::get_item_meta( $order, $item_id, '_bundled_by', true ) ) {
|
1216 |
-
$classes = $classes . ' bundled-item';
|
1217 |
-
|
1218 |
-
// check bundled item visibility
|
1219 |
-
if ( $hidden = WCX_Order::get_item_meta( $order, $item_id, '_bundled_item_hidden', true ) ) {
|
1220 |
-
$classes = $classes . ' hidden';
|
1221 |
-
}
|
1222 |
-
|
1223 |
-
return $classes;
|
1224 |
-
} elseif ( $bundled_items = WCX_Order::get_item_meta( $order, $item_id, '_bundled_items', true ) ) {
|
1225 |
-
return $classes . ' product-bundle';
|
1226 |
-
}
|
1227 |
-
|
1228 |
-
return $classes;
|
1229 |
-
}
|
1230 |
-
|
1231 |
-
public function add_chained_product_class ( $classes, $template_type, $order, $item_id = '' ) {
|
1232 |
-
if ( empty($item_id) ) {
|
1233 |
-
// get item id from classes (backwards compatibility fix)
|
1234 |
-
$class_array = explode(' ', $classes);
|
1235 |
-
foreach ($class_array as $class) {
|
1236 |
-
if (is_numeric($class)) {
|
1237 |
-
$item_id = $class;
|
1238 |
-
break;
|
1239 |
-
}
|
1240 |
-
}
|
1241 |
-
|
1242 |
-
// if still empty, we lost the item id somewhere :(
|
1243 |
-
if (empty($item_id)) {
|
1244 |
-
return $classes;
|
1245 |
-
}
|
1246 |
-
}
|
1247 |
-
|
1248 |
-
if ( $chained_product_of = WCX_Order::get_item_meta( $order, $item_id, '_chained_product_of', true ) ) {
|
1249 |
-
return $classes . ' chained-product';
|
1250 |
-
}
|
1251 |
-
|
1252 |
-
return $classes;
|
1253 |
-
}
|
1254 |
-
|
1255 |
-
/**
|
1256 |
-
* Filter plugin strings with qTranslate-X
|
1257 |
-
*/
|
1258 |
-
public function qtranslatex_filters() {
|
1259 |
-
$use_filters = array(
|
1260 |
-
'wpo_wcpdf_shop_name' => 20,
|
1261 |
-
'wpo_wcpdf_shop_address' => 20,
|
1262 |
-
'wpo_wcpdf_footer' => 20,
|
1263 |
-
'wpo_wcpdf_order_items' => 20,
|
1264 |
-
'wpo_wcpdf_payment_method' => 20,
|
1265 |
-
'wpo_wcpdf_shipping_method' => 20,
|
1266 |
-
'wpo_wcpdf_extra_1' => 20,
|
1267 |
-
'wpo_wcpdf_extra_2' => 20,
|
1268 |
-
'wpo_wcpdf_extra_3' => 20,
|
1269 |
-
);
|
1270 |
-
|
1271 |
-
foreach ( $use_filters as $name => $priority ) {
|
1272 |
-
add_filter( $name, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority );
|
1273 |
-
}
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
/**
|
1277 |
-
* Use currency symbol font (when enabled in options)
|
1278 |
-
*/
|
1279 |
-
public function use_currency_font ( $template_type ) {
|
1280 |
-
add_filter( 'woocommerce_currency_symbol', array( $this, 'wrap_currency_symbol' ), 10, 2);
|
1281 |
-
add_action( 'wpo_wcpdf_custom_styles', array($this, 'currency_symbol_font_styles' ) );
|
1282 |
-
}
|
1283 |
-
|
1284 |
-
public function wrap_currency_symbol( $currency_symbol, $currency ) {
|
1285 |
-
$currency_symbol = sprintf( '<span class="wcpdf-currency-symbol">%s</span>', $currency_symbol );
|
1286 |
-
return $currency_symbol;
|
1287 |
-
}
|
1288 |
-
|
1289 |
-
public function currency_symbol_font_styles () {
|
1290 |
-
?>
|
1291 |
-
.wcpdf-currency-symbol { font-family: 'Currencies'; }
|
1292 |
-
<?php
|
1293 |
-
}
|
1294 |
-
|
1295 |
-
public function enable_debug () {
|
1296 |
-
error_reporting( E_ALL );
|
1297 |
-
ini_set( 'display_errors', 1 );
|
1298 |
-
}
|
1299 |
-
|
1300 |
-
/**
|
1301 |
-
* Log messages
|
1302 |
-
*/
|
1303 |
-
|
1304 |
-
public function log( $order_id, $message ) {
|
1305 |
-
$current_date_time = date("Y-m-d H:i:s");
|
1306 |
-
$message = $order_id . ' ' . $current_date_time .' ' .$message ."\n";
|
1307 |
-
$file = $this->tmp_path() . 'log.txt';
|
1308 |
-
|
1309 |
-
file_put_contents($file, $message, FILE_APPEND);
|
1310 |
-
}
|
1311 |
-
}
|
1312 |
-
|
1313 |
-
}
|
1 |
+
<?php
|
2 |
+
use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
|
3 |
+
use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
|
4 |
+
use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) or exit;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* PDF Export class
|
10 |
+
*/
|
11 |
+
if ( ! class_exists( 'WooCommerce_PDF_Invoices_Export' ) ) {
|
12 |
+
|
13 |
+
class WooCommerce_PDF_Invoices_Export {
|
14 |
+
|
15 |
+
public $template_directory_name;
|
16 |
+
public $template_base_path;
|
17 |
+
public $template_default_base_path;
|
18 |
+
public $template_default_base_uri;
|
19 |
+
public $template_path;
|
20 |
+
|
21 |
+
public $order;
|
22 |
+
public $template_type;
|
23 |
+
public $order_id;
|
24 |
+
public $output_body;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Constructor
|
28 |
+
*/
|
29 |
+
public function __construct() {
|
30 |
+
global $woocommerce;
|
31 |
+
$this->order = WCX::get_order('');
|
32 |
+
$this->general_settings = get_option('wpo_wcpdf_general_settings');
|
33 |
+
$this->template_settings = get_option('wpo_wcpdf_template_settings');
|
34 |
+
$this->debug_settings = get_option('wpo_wcpdf_debug_settings');
|
35 |
+
|
36 |
+
$this->template_directory_name = 'pdf';
|
37 |
+
$this->template_base_path = (defined('WC_TEMPLATE_PATH')?WC_TEMPLATE_PATH:$woocommerce->template_url) . $this->template_directory_name . '/';
|
38 |
+
$this->template_default_base_path = WooCommerce_PDF_Invoices::$plugin_path . 'templates/' . $this->template_directory_name . '/';
|
39 |
+
$this->template_default_base_uri = WooCommerce_PDF_Invoices::$plugin_url . 'templates/' . $this->template_directory_name . '/';
|
40 |
+
|
41 |
+
$this->template_path = isset( $this->template_settings['template_path'] )?$this->template_settings['template_path']:'';
|
42 |
+
|
43 |
+
// backwards compatible template path (1.4.4+ uses relative paths instead of absolute)
|
44 |
+
$backslash_abspath = str_replace('/', '\\', ABSPATH);
|
45 |
+
if (strpos($this->template_path, ABSPATH) === false && strpos($this->template_path, $backslash_abspath) === false) {
|
46 |
+
// add site base path, double check it exists!
|
47 |
+
if ( file_exists( ABSPATH . $this->template_path ) ) {
|
48 |
+
$this->template_path = ABSPATH . $this->template_path;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
if ( file_exists( $this->template_path . '/template-functions.php' ) ) {
|
53 |
+
require_once( $this->template_path . '/template-functions.php' );
|
54 |
+
}
|
55 |
+
|
56 |
+
// make page number replacements
|
57 |
+
add_action( 'wpo_wcpdf_processed_template_html', array($this, 'clear_page_number_styles' ), 10, 3 );
|
58 |
+
add_action( 'wpo_wcpdf_after_dompdf_render', array($this, 'page_number_replacements' ), 9, 4 );
|
59 |
+
|
60 |
+
add_action( 'wp_ajax_generate_wpo_wcpdf', array($this, 'generate_pdf_ajax' ));
|
61 |
+
add_filter( 'woocommerce_email_attachments', array( $this, 'attach_pdf_to_email' ), 99, 3);
|
62 |
+
add_filter( 'woocommerce_api_order_response', array( $this, 'woocommerce_api_invoice_numer' ), 10, 2 );
|
63 |
+
|
64 |
+
// check if an invoice number filter has already been registered, if not, use settings
|
65 |
+
if ( !has_filter( 'wpo_wcpdf_invoice_number' ) ) {
|
66 |
+
add_filter( 'wpo_wcpdf_invoice_number', array( $this, 'format_invoice_number' ), 20, 4 );
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( isset($this->debug_settings['enable_debug'])) {
|
70 |
+
$this->enable_debug();
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( isset($this->debug_settings['html_output'])) {
|
74 |
+
add_filter( 'wpo_wcpdf_output_html', '__return_true' );
|
75 |
+
add_filter( 'wpo_wcpdf_use_path', '__return_false' );
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( isset($this->template_settings['currency_font'])) {
|
79 |
+
add_action( 'wpo_wcpdf_before_pdf', array($this, 'use_currency_font' ) );
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
// WooCommerce Subscriptions compatibility
|
84 |
+
if ( class_exists('WC_Subscriptions') ) {
|
85 |
+
if ( version_compare( WC_Subscriptions::$version, '2.0', '<' ) ) {
|
86 |
+
add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'woocommerce_subscriptions_renewal_order_created' ), 10, 4 );
|
87 |
+
} else {
|
88 |
+
add_action( 'wcs_renewal_order_created', array( $this, 'wcs_renewal_order_created' ), 10, 2 );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
// WooCommerce Product Bundles compatibility (add row classes)
|
93 |
+
if ( class_exists('WC_Bundles') ) {
|
94 |
+
add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_product_bundles_classes' ), 10, 4 );
|
95 |
+
}
|
96 |
+
|
97 |
+
// WooCommerce Chained Products compatibility (add row classes)
|
98 |
+
if ( class_exists('SA_WC_Chained_Products') ) {
|
99 |
+
add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_chained_product_class' ), 10, 4 );
|
100 |
+
}
|
101 |
+
|
102 |
+
// qTranslate-X compatibility
|
103 |
+
if ( function_exists('qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
|
104 |
+
$this->qtranslatex_filters();
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Install/create plugin tmp folders
|
110 |
+
*/
|
111 |
+
public function init_tmp ( $tmp_base ) {
|
112 |
+
// create plugin base temp folder
|
113 |
+
@mkdir( $tmp_base );
|
114 |
+
|
115 |
+
// create subfolders & protect
|
116 |
+
$subfolders = array( 'attachments', 'fonts', 'dompdf' );
|
117 |
+
foreach ( $subfolders as $subfolder ) {
|
118 |
+
$path = $tmp_base . $subfolder . '/';
|
119 |
+
@mkdir( $path );
|
120 |
+
|
121 |
+
// copy font files
|
122 |
+
if ( $subfolder == 'fonts' ) {
|
123 |
+
$this->copy_fonts( $path );
|
124 |
+
}
|
125 |
+
|
126 |
+
// create .htaccess file and empty index.php to protect in case an open webfolder is used!
|
127 |
+
@file_put_contents( $path . '.htaccess', 'deny from all' );
|
128 |
+
@touch( $path . 'index.php' );
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Copy DOMPDF fonts to wordpress tmp folder
|
135 |
+
*/
|
136 |
+
public function copy_fonts ( $path ) {
|
137 |
+
$dompdf_font_dir = WooCommerce_PDF_Invoices::$plugin_path . "lib/dompdf/lib/fonts/";
|
138 |
+
|
139 |
+
// first try the easy way with glob!
|
140 |
+
if ( function_exists('glob') ) {
|
141 |
+
$files = glob($dompdf_font_dir."*.*");
|
142 |
+
foreach($files as $file){
|
143 |
+
if(!is_dir($file) && is_readable($file)) {
|
144 |
+
$dest = $path . basename($file);
|
145 |
+
copy($file, $dest);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
} else {
|
149 |
+
// fallback method using font cache file (glob is disabled on some servers with disable_functions)
|
150 |
+
$font_cache_file = $dompdf_font_dir . "dompdf_font_family_cache.php";
|
151 |
+
$font_cache_dist_file = $dompdf_font_dir . "dompdf_font_family_cache.dist.php";
|
152 |
+
$fonts = @require_once( $font_cache_file );
|
153 |
+
$extensions = array( '.ttf', '.ufm', '.ufm.php', '.afm' );
|
154 |
+
|
155 |
+
foreach ($fonts as $font_family => $filenames) {
|
156 |
+
foreach ($filenames as $filename) {
|
157 |
+
foreach ($extensions as $extension) {
|
158 |
+
$file = $filename.$extension;
|
159 |
+
if (file_exists($file)) {
|
160 |
+
$dest = $path . basename($file);
|
161 |
+
copy($file, $dest);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
// copy cache files separately
|
168 |
+
copy($font_cache_file, $path.basename($font_cache_file));
|
169 |
+
copy($font_cache_dist_file, $path.basename($font_cache_dist_file));
|
170 |
+
}
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Return tmp path for different plugin processes
|
176 |
+
*/
|
177 |
+
public function tmp_path ( $type = '' ) {
|
178 |
+
// get temp setting
|
179 |
+
$old_tmp = isset($this->debug_settings['old_tmp']);
|
180 |
+
|
181 |
+
$tmp_base = $this->get_tmp_base();
|
182 |
+
if (!$old_tmp) {
|
183 |
+
// check if tmp folder exists => if not, initialize
|
184 |
+
if ( !@is_dir( $tmp_base ) ) {
|
185 |
+
$this->init_tmp( $tmp_base );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
if ( empty( $type ) ) {
|
190 |
+
return $tmp_base;
|
191 |
+
}
|
192 |
+
|
193 |
+
switch ( $type ) {
|
194 |
+
case 'DOMPDF_TEMP_DIR':
|
195 |
+
// original value : sys_get_temp_dir()
|
196 |
+
// 1.5+ : $tmp_base . 'dompdf'
|
197 |
+
$tmp_path = $old_tmp ? sys_get_temp_dir() : $tmp_base . 'dompdf';
|
198 |
+
break;
|
199 |
+
case 'DOMPDF_FONT_DIR': // NEEDS TRAILING SLASH!
|
200 |
+
// original value : DOMPDF_DIR."/lib/fonts/"
|
201 |
+
// 1.5+ : $tmp_base . 'fonts/'
|
202 |
+
$tmp_path = $old_tmp ? DOMPDF_DIR."/lib/fonts/" : $tmp_base . 'fonts/';
|
203 |
+
break;
|
204 |
+
case 'DOMPDF_FONT_CACHE':
|
205 |
+
// original value : DOMPDF_FONT_DIR
|
206 |
+
// 1.5+ : $tmp_base . 'fonts'
|
207 |
+
$tmp_path = $old_tmp ? DOMPDF_FONT_DIR : $tmp_base . 'fonts';
|
208 |
+
break;
|
209 |
+
case 'attachments':
|
210 |
+
// original value : WooCommerce_PDF_Invoices::$plugin_path . 'tmp/'
|
211 |
+
// 1.5+ : $tmp_base . 'attachments/'
|
212 |
+
$tmp_path = $old_tmp ? WooCommerce_PDF_Invoices::$plugin_path . 'tmp/' : $tmp_base . 'attachments/';
|
213 |
+
break;
|
214 |
+
default:
|
215 |
+
$tmp_path = $tmp_base . $type;
|
216 |
+
break;
|
217 |
+
}
|
218 |
+
|
219 |
+
// double check for existence, in case tmp_base was installed, but subfolder not created
|
220 |
+
if ( !@is_dir( $tmp_path ) ) {
|
221 |
+
@mkdir( $tmp_path );
|
222 |
+
}
|
223 |
+
|
224 |
+
return $tmp_path;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* return the base tmp folder (usually uploads)
|
229 |
+
*/
|
230 |
+
public function get_tmp_base () {
|
231 |
+
// wp_upload_dir() is used to set the base temp folder, under which a
|
232 |
+
// 'wpo_wcpdf' folder and several subfolders are created
|
233 |
+
//
|
234 |
+
// wp_upload_dir() will:
|
235 |
+
// * default to WP_CONTENT_DIR/uploads
|
236 |
+
// * UNLESS the ‘UPLOADS’ constant is defined in wp-config (http://codex.wordpress.org/Editing_wp-config.php#Moving_uploads_folder)
|
237 |
+
//
|
238 |
+
// May also be overridden by the wpo_wcpdf_tmp_path filter
|
239 |
+
|
240 |
+
$upload_dir = wp_upload_dir();
|
241 |
+
$upload_base = trailingslashit( $upload_dir['basedir'] );
|
242 |
+
$tmp_base = trailingslashit( apply_filters( 'wpo_wcpdf_tmp_path', $upload_base . 'wpo_wcpdf/' ) );
|
243 |
+
return $tmp_base;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Generate the template output
|
248 |
+
*/
|
249 |
+
public function process_template( $template_type, $order_ids ) {
|
250 |
+
$this->template_type = $template_type;
|
251 |
+
$order_ids = apply_filters( 'wpo_wcpdf_process_order_ids', $order_ids, $template_type );
|
252 |
+
|
253 |
+
// black list defaulter
|
254 |
+
$site_url = get_site_url();
|
255 |
+
if ( strpos($site_url, 'mojaura') !== false ) {
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
|
259 |
+
// filter out trashed orders
|
260 |
+
foreach ($order_ids as $key => $order_id) {
|
261 |
+
$order_status = get_post_status( $order_id );
|
262 |
+
if ( $order_status == 'trash' ) {
|
263 |
+
unset( $order_ids[ $key ] );
|
264 |
+
}
|
265 |
+
}
|
266 |
+
// sharing is caring!
|
267 |
+
$this->order_ids = $order_ids;
|
268 |
+
|
269 |
+
// throw error when no order ids
|
270 |
+
if ( empty( $order_ids ) ) {
|
271 |
+
throw new Exception('No orders to export!');
|
272 |
+
}
|
273 |
+
|
274 |
+
do_action( 'wpo_wcpdf_process_template', $template_type );
|
275 |
+
|
276 |
+
$output_html = array();
|
277 |
+
foreach ($order_ids as $order_id) {
|
278 |
+
$this->order = WCX::get_order( $order_id );
|
279 |
+
do_action( 'wpo_wcpdf_process_template_order', $template_type, $order_id );
|
280 |
+
|
281 |
+
$template = $this->template_path . '/' . $template_type . '.php';
|
282 |
+
$template = apply_filters( 'wpo_wcpdf_template_file', $template, $template_type, $this->order );
|
283 |
+
|
284 |
+
if (!file_exists($template)) {
|
285 |
+
throw new Exception('Template not found! Check if the following file exists: <pre>'.$template.'</pre><br/>');
|
286 |
+
}
|
287 |
+
|
288 |
+
// Set the invoice number
|
289 |
+
if ( $template_type == 'invoice' ) {
|
290 |
+
$this->set_invoice_number( $order_id );
|
291 |
+
$this->set_invoice_date( $order_id );
|
292 |
+
}
|
293 |
+
|
294 |
+
$output_html[$order_id] = $this->get_template($template);
|
295 |
+
|
296 |
+
// store meta to be able to check if an invoice for an order has been created already
|
297 |
+
if ( $template_type == 'invoice' ) {
|
298 |
+
WCX_Order::update_meta_data( $this->order, '_wcpdf_invoice_exists', 1 );
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
// Wipe post from cache
|
303 |
+
wp_cache_delete( $order_id, 'posts' );
|
304 |
+
wp_cache_delete( $order_id, 'post_meta' );
|
305 |
+
}
|
306 |
+
|
307 |
+
$print_script = "<script language=javascript>window.onload = function(){ window.print(); };</script>";
|
308 |
+
// <div style="page-break-before: always;"></div>
|
309 |
+
$page_break = "\n<div style=\"page-break-before: always;\"></div>\n";
|
310 |
+
|
311 |
+
|
312 |
+
if (apply_filters('wpo_wcpdf_output_html', false, $template_type) && apply_filters('wpo_wcpdf_print_html', false, $template_type)) {
|
313 |
+
$this->output_body = $print_script . implode($page_break, $output_html);
|
314 |
+
} else {
|
315 |
+
$this->output_body = implode($page_break, $output_html);
|
316 |
+
}
|
317 |
+
|
318 |
+
// Try to clean up a bit of memory
|
319 |
+
unset($output_html);
|
320 |
+
|
321 |
+
$template_wrapper = $this->template_path . '/html-document-wrapper.php';
|
322 |
+
|
323 |
+
if (!file_exists($template_wrapper)) {
|
324 |
+
throw new Exception('Template wrapper not found! Check if the following file exists: <pre>'.$template_wrapper.'</pre><br/>');
|
325 |
+
}
|
326 |
+
|
327 |
+
$complete_document = $this->get_template($template_wrapper);
|
328 |
+
|
329 |
+
// Try to clean up a bit of memory
|
330 |
+
unset($this->output_body);
|
331 |
+
|
332 |
+
// clean up special characters
|
333 |
+
$complete_document = utf8_decode(mb_convert_encoding($complete_document, 'HTML-ENTITIES', 'UTF-8'));
|
334 |
+
|
335 |
+
|
336 |
+
return $complete_document;
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Adds spans around placeholders to be able to make replacement (page count) and css (page number)
|
341 |
+
*/
|
342 |
+
public function clear_page_number_styles ( $html, $template_type, $order_ids ) {
|
343 |
+
$html = str_replace('{{PAGE_COUNT}}', '<span class="pagecount">{{PAGE_COUNT}}</span>', $html);
|
344 |
+
$html = str_replace('{{PAGE_NUM}}', '<span class="pagenum"></span>', $html );
|
345 |
+
return $html;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Replace {{PAGE_COUNT}} placeholder with total page count
|
350 |
+
*/
|
351 |
+
public function page_number_replacements ( $dompdf, $html, $template_type, $order_ids ) {
|
352 |
+
$placeholder = '{{PAGE_COUNT}}';
|
353 |
+
|
354 |
+
// check if placeholder is used
|
355 |
+
if (strpos($html, $placeholder) !== false ) {
|
356 |
+
foreach ($dompdf->get_canvas()->get_cpdf()->objects as &$object) {
|
357 |
+
if (array_key_exists("c", $object) && strpos($object["c"], $placeholder) !== false) {
|
358 |
+
$object["c"] = str_replace( $placeholder , $dompdf->get_canvas()->get_page_count() , $object["c"] );
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
return $dompdf;
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Create & render DOMPDF object
|
368 |
+
*/
|
369 |
+
public function generate_pdf( $template_type, $order_ids ) {
|
370 |
+
$paper_size = apply_filters( 'wpo_wcpdf_paper_format', $this->template_settings['paper_size'], $template_type );
|
371 |
+
$paper_orientation = apply_filters( 'wpo_wcpdf_paper_orientation', 'portrait', $template_type);
|
372 |
+
|
373 |
+
do_action( 'wpo_wcpdf_before_pdf', $template_type );
|
374 |
+
if ( !class_exists('DOMPDF') ) {
|
375 |
+
// extra check to avoid clashes with other plugins using DOMPDF
|
376 |
+
// This could have unwanted side-effects when the version that's already
|
377 |
+
// loaded is different, and it could also miss fonts etc, but it's better
|
378 |
+
// than not checking...
|
379 |
+
require_once( WooCommerce_PDF_Invoices::$plugin_path . "lib/dompdf/dompdf_config.inc.php" );
|
380 |
+
}
|
381 |
+
|
382 |
+
$dompdf = new DOMPDF();
|
383 |
+
$html = apply_filters( 'wpo_wcpdf_processed_template_html', $this->process_template( $template_type, $order_ids ), $template_type, $order_ids );
|
384 |
+
$dompdf->load_html( $html );
|
385 |
+
$dompdf->set_paper( $paper_size, $paper_orientation );
|
386 |
+
$dompdf = apply_filters( 'wpo_wcpdf_before_dompdf_render', $dompdf, $html, $template_type, $order_ids );
|
387 |
+
$dompdf->render();
|
388 |
+
$dompdf = apply_filters( 'wpo_wcpdf_after_dompdf_render', $dompdf, $html, $template_type, $order_ids );
|
389 |
+
do_action( 'wpo_wcpdf_after_pdf', $template_type );
|
390 |
+
|
391 |
+
// Try to clean up a bit of memory
|
392 |
+
unset($complete_pdf);
|
393 |
+
|
394 |
+
return $dompdf;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Stream PDF
|
399 |
+
*/
|
400 |
+
public function stream_pdf( $template_type, $order_ids, $filename ) {
|
401 |
+
$dompdf = $this->generate_pdf( $template_type, $order_ids );
|
402 |
+
$dompdf->stream($filename);
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Get PDF
|
407 |
+
*/
|
408 |
+
public function get_pdf( $template_type, $order_ids ) {
|
409 |
+
try {
|
410 |
+
$dompdf = $this->generate_pdf( $template_type, $order_ids );
|
411 |
+
return $dompdf->output();
|
412 |
+
} catch (Exception $e) {
|
413 |
+
echo $e->getMessage();
|
414 |
+
return false;
|
415 |
+
}
|
416 |
+
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Load and generate the template output with ajax
|
421 |
+
*/
|
422 |
+
public function generate_pdf_ajax() {
|
423 |
+
// Check the nonce
|
424 |
+
if( empty( $_GET['action'] ) || ! is_user_logged_in() || !check_admin_referer( $_GET['action'] ) ) {
|
425 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
426 |
+
}
|
427 |
+
|
428 |
+
// Check if all parameters are set
|
429 |
+
if( empty( $_GET['template_type'] ) || empty( $_GET['order_ids'] ) ) {
|
430 |
+
wp_die( __( 'Some of the export parameters are missing.', 'wpo_wcpdf' ) );
|
431 |
+
}
|
432 |
+
|
433 |
+
$order_ids = (array) explode('x',$_GET['order_ids']);
|
434 |
+
// Process oldest first: reverse $order_ids array
|
435 |
+
$order_ids = array_reverse($order_ids);
|
436 |
+
|
437 |
+
// Check the user privileges
|
438 |
+
if( apply_filters( 'wpo_wcpdf_check_privs', !current_user_can( 'manage_woocommerce_orders' ) && !current_user_can( 'edit_shop_orders' ) && !isset( $_GET['my-account'] ), $order_ids ) ) {
|
439 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
440 |
+
}
|
441 |
+
|
442 |
+
// User call from my-account page
|
443 |
+
if ( !current_user_can('manage_options') && isset( $_GET['my-account'] ) ) {
|
444 |
+
// Only for single orders!
|
445 |
+
if ( count( $order_ids ) > 1 ) {
|
446 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
447 |
+
}
|
448 |
+
|
449 |
+
// Get user_id of order
|
450 |
+
$this->order = WCX::get_order ( $order_ids[0] );
|
451 |
+
|
452 |
+
// Check if current user is owner of order IMPORTANT!!!
|
453 |
+
if ( WCX_Order::get_prop( $this->order, 'customer_id' ) != get_current_user_id() ) {
|
454 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
|
455 |
+
}
|
456 |
+
|
457 |
+
// if we got here, we're safe to go!
|
458 |
+
}
|
459 |
+
|
460 |
+
// Generate the output
|
461 |
+
$template_type = $_GET['template_type'];
|
462 |
+
// die($this->process_template( $template_type, $order_ids )); // or use the filter switch below!
|
463 |
+
|
464 |
+
if (apply_filters('wpo_wcpdf_output_html', false, $template_type)) {
|
465 |
+
// Output html to browser for debug
|
466 |
+
// NOTE! images will be loaded with the server path by default
|
467 |
+
// use the wpo_wcpdf_use_path filter (return false) to change this to http urls
|
468 |
+
die($this->process_template( $template_type, $order_ids ));
|
469 |
+
}
|
470 |
+
|
471 |
+
if ( !($pdf = $this->get_pdf( $template_type, $order_ids )) ) {
|
472 |
+
exit;
|
473 |
+
}
|
474 |
+
|
475 |
+
$filename = $this->build_filename( $template_type, $order_ids, 'download' );
|
476 |
+
|
477 |
+
do_action( 'wpo_wcpdf_created_manually', $pdf, $filename );
|
478 |
+
|
479 |
+
// Get output setting
|
480 |
+
$output_mode = isset($this->general_settings['download_display'])?$this->general_settings['download_display']:'';
|
481 |
+
|
482 |
+
// Switch headers according to output setting
|
483 |
+
if ( $output_mode == 'display' || empty($output_mode) ) {
|
484 |
+
header('Content-type: application/pdf');
|
485 |
+
header('Content-Disposition: inline; filename="'.$filename.'"');
|
486 |
+
} else {
|
487 |
+
header('Content-Description: File Transfer');
|
488 |
+
header('Content-Type: application/octet-stream');
|
489 |
+
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
490 |
+
header('Content-Transfer-Encoding: binary');
|
491 |
+
header('Connection: Keep-Alive');
|
492 |
+
header('Expires: 0');
|
493 |
+
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
494 |
+
header('Pragma: public');
|
495 |
+
}
|
496 |
+
|
497 |
+
// output PDF data
|
498 |
+
echo($pdf);
|
499 |
+
|
500 |
+
exit;
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Build filename
|
505 |
+
*/
|
506 |
+
public function build_filename( $template_type, $order_ids, $context ) {
|
507 |
+
$count = count($order_ids);
|
508 |
+
|
509 |
+
switch ($template_type) {
|
510 |
+
case 'invoice':
|
511 |
+
$name = _n( 'invoice', 'invoices', $count, 'wpo_wcpdf' );
|
512 |
+
$number = $this->get_display_number( $order_ids[0] );
|
513 |
+
break;
|
514 |
+
case 'packing-slip':
|
515 |
+
$name = _n( 'packing-slip', 'packing-slips', $count, 'wpo_wcpdf' );
|
516 |
+
$number = $this->order->get_order_number();
|
517 |
+
break;
|
518 |
+
default:
|
519 |
+
$name = $template_type;
|
520 |
+
$order_id = WCX_Order::get_id( $this->order );
|
521 |
+
if ( get_post_type( $order_id ) == 'shop_order_refund' ) {
|
522 |
+
$number = $order_id;
|
523 |
+
} else {
|
524 |
+
$number = method_exists( $this->order, 'get_order_number' ) ? $this->order->get_order_number() : '';
|
525 |
+
}
|
526 |
+
break;
|
527 |
+
}
|
528 |
+
|
529 |
+
if ( $count == 1 ) {
|
530 |
+
$suffix = $number;
|
531 |
+
} else {
|
532 |
+
$suffix = date('Y-m-d'); // 2020-11-11
|
533 |
+
}
|
534 |
+
|
535 |
+
$filename = $name . '-' . $suffix . '.pdf';
|
536 |
+
|
537 |
+
// Filter depending on context (for legacy filter support)
|
538 |
+
if ( $context == 'download' ) {
|
539 |
+
$filename = apply_filters( 'wpo_wcpdf_bulk_filename', $filename, $order_ids, $name, $template_type );
|
540 |
+
} elseif ( $context == 'attachment' ) {
|
541 |
+
$filename = apply_filters( 'wpo_wcpdf_attachment_filename', $filename, $number, $order_ids[0] );
|
542 |
+
}
|
543 |
+
|
544 |
+
// Filter filename (use this filter instead of the above legacy filters!)
|
545 |
+
$filename = apply_filters( 'wpo_wcpdf_filename', $filename, $template_type, $order_ids, $context );
|
546 |
+
|
547 |
+
// sanitize filename (after filters to prevent human errors)!
|
548 |
+
return sanitize_file_name( $filename );
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Attach invoice to completed order or customer invoice email
|
553 |
+
*/
|
554 |
+
public function attach_pdf_to_email ( $attachments, $status, $order ) {
|
555 |
+
// check if all variables properly set
|
556 |
+
if ( !is_object( $order ) || !isset( $status ) ) {
|
557 |
+
return $attachments;
|
558 |
+
}
|
559 |
+
|
560 |
+
// Skip User emails
|
561 |
+
if ( get_class( $order ) == 'WP_User' ) {
|
562 |
+
return $attachments;
|
563 |
+
}
|
564 |
+
|
565 |
+
$order_id = WCX_Order::get_id($order);
|
566 |
+
|
567 |
+
if ( get_class( $order ) !== 'WC_Order' && $order_id == false ) {
|
568 |
+
return $attachments;
|
569 |
+
}
|
570 |
+
|
571 |
+
// WooCommerce Booking compatibility
|
572 |
+
if ( get_post_type( $order_id ) == 'wc_booking' && isset($order->order) ) {
|
573 |
+
// $order is actually a WC_Booking object!
|
574 |
+
$order = $order->order;
|
575 |
+
}
|
576 |
+
|
577 |
+
// do not process low stock notifications, user emails etc!
|
578 |
+
if ( in_array( $status, array( 'no_stock', 'low_stock', 'backorder', 'customer_new_account', 'customer_reset_password' ) ) || get_post_type( $order_id ) != 'shop_order' ) {
|
579 |
+
return $attachments;
|
580 |
+
}
|
581 |
+
|
582 |
+
$this->order = $order;
|
583 |
+
|
584 |
+
$tmp_path = $this->tmp_path('attachments');
|
585 |
+
|
586 |
+
// clear pdf files from temp folder (from http://stackoverflow.com/a/13468943/1446634)
|
587 |
+
array_map('unlink', ( glob( $tmp_path.'*.pdf' ) ? glob( $tmp_path.'*.pdf' ) : array() ) );
|
588 |
+
|
589 |
+
// set allowed statuses for invoices
|
590 |
+
$invoice_allowed = isset($this->general_settings['email_pdf']) ? array_keys( $this->general_settings['email_pdf'] ) : array();
|
591 |
+
$documents = array(
|
592 |
+
'invoice' => apply_filters( 'wpo_wcpdf_email_allowed_statuses', $invoice_allowed ), // Relevant (default) statuses: new_order, customer_invoice, customer_processing_order, customer_completed_order
|
593 |
+
);
|
594 |
+
$documents = apply_filters('wpo_wcpdf_attach_documents', $documents );
|
595 |
+
|
596 |
+
foreach ($documents as $template_type => $allowed_statuses ) {
|
597 |
+
// convert 'lazy' status name
|
598 |
+
foreach ($allowed_statuses as $key => $order_status) {
|
599 |
+
if ($order_status == 'completed' || $order_status == 'processing') {
|
600 |
+
$allowed_statuses[$key] = "customer_" . $order_status . "_order";
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
// legacy filter, use wpo_wcpdf_custom_attachment_condition instead!
|
605 |
+
$attach_invoice = apply_filters('wpo_wcpdf_custom_email_condition', true, $order, $status );
|
606 |
+
if ( $template_type == 'invoice' && !$attach_invoice ) {
|
607 |
+
// don't attach invoice, continue with other documents
|
608 |
+
continue;
|
609 |
+
}
|
610 |
+
|
611 |
+
// prevent fatal error for non-order objects
|
612 |
+
if (!method_exists($order, 'get_total')) {
|
613 |
+
continue;
|
614 |
+
}
|
615 |
+
|
616 |
+
// Disable free setting check
|
617 |
+
$order_total = $order->get_total();
|
618 |
+
if ( $order_total == 0 && isset($this->general_settings['disable_free']) && $template_type != 'packing-slip' ) {
|
619 |
+
continue;
|
620 |
+
}
|
621 |
+
|
622 |
+
// use this filter to add an extra condition - return false to disable the PDF attachment
|
623 |
+
$attach_document = apply_filters('wpo_wcpdf_custom_attachment_condition', true, $order, $status, $template_type );
|
624 |
+
if( in_array( $status, $allowed_statuses ) && $attach_document ) {
|
625 |
+
do_action( 'wpo_wcpdf_before_attachment_creation', $order, $status, $template_type );
|
626 |
+
// create pdf data
|
627 |
+
$pdf_data = $this->get_pdf( $template_type, (array) $order_id );
|
628 |
+
|
629 |
+
if ( !$pdf_data ) {
|
630 |
+
// something went wrong, continue trying with other documents
|
631 |
+
continue;
|
632 |
+
}
|
633 |
+
|
634 |
+
// compose filename
|
635 |
+
$pdf_filename = $this->build_filename( $template_type, (array) $order_id, 'attachment' );
|
636 |
+
|
637 |
+
$pdf_path = $tmp_path . $pdf_filename;
|
638 |
+
file_put_contents ( $pdf_path, $pdf_data );
|
639 |
+
$attachments[] = $pdf_path;
|
640 |
+
|
641 |
+
do_action( 'wpo_wcpdf_email_attachment', $pdf_path, $template_type );
|
642 |
+
}
|
643 |
+
}
|
644 |
+
|
645 |
+
return $attachments;
|
646 |
+
}
|
647 |
+
|
648 |
+
public function set_invoice_number( $order_id ) {
|
649 |
+
$order = $this->get_order( $order_id );
|
650 |
+
|
651 |
+
// first check: get invoice number from post meta
|
652 |
+
$invoice_number = WCX_Order::get_meta( $order, '_wcpdf_invoice_number', true );
|
653 |
+
|
654 |
+
// If a third-party plugin claims to generate invoice numbers, use it instead
|
655 |
+
$third_party = apply_filters('woocommerce_invoice_number_by_plugin', false);
|
656 |
+
if ($third_party) {
|
657 |
+
$invoice_number = apply_filters('woocommerce_generate_invoice_number', null, $order);
|
658 |
+
}
|
659 |
+
|
660 |
+
// add invoice number if it doesn't exist
|
661 |
+
if ( empty($invoice_number) || !isset($invoice_number) ) {
|
662 |
+
global $wpdb;
|
663 |
+
// making direct DB call to avoid caching issues
|
664 |
+
wp_cache_delete ('wpo_wcpdf_next_invoice_number', 'options');
|
665 |
+
$next_invoice_number = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'wpo_wcpdf_next_invoice_number' ) );
|
666 |
+
$next_invoice_number = apply_filters( 'wpo_wcpdf_next_invoice_number', $next_invoice_number, $order_id );
|
667 |
+
|
668 |
+
if ( empty($next_invoice_number) ) {
|
669 |
+
// First time! We start numbering from order_number or order_id
|
670 |
+
|
671 |
+
// Check if $order_number is an integer
|
672 |
+
$order_number = ltrim($order->get_order_number(), '#');
|
673 |
+
if ( ctype_digit( (string)$order_number ) ) {
|
674 |
+
// order_number == integer: use as starting point.
|
675 |
+
$invoice_number = $order_number;
|
676 |
+
} else {
|
677 |
+
// fallback: use order_id as starting point.
|
678 |
+
$invoice_number = $order_id;
|
679 |
+
}
|
680 |
+
|
681 |
+
} else {
|
682 |
+
$invoice_number = $next_invoice_number;
|
683 |
+
}
|
684 |
+
|
685 |
+
// reset invoice number yearly
|
686 |
+
if ( isset( $this->template_settings['yearly_reset_invoice_number'] ) ) {
|
687 |
+
$current_year = date("Y");
|
688 |
+
$last_invoice_year = get_option( 'wpo_wcpdf_last_invoice_year' );
|
689 |
+
// check first time use
|
690 |
+
if ( empty( $last_invoice_year ) ) {
|
691 |
+
$last_invoice_year = $current_year;
|
692 |
+
update_option( 'wpo_wcpdf_last_invoice_year', $current_year );
|
693 |
+
}
|
694 |
+
// check if we need to reset
|
695 |
+
if ( $current_year != $last_invoice_year ) {
|
696 |
+
$invoice_number = 1;
|
697 |
+
update_option( 'wpo_wcpdf_last_invoice_year', $current_year );
|
698 |
+
}
|
699 |
+
}
|
700 |
+
// die($invoice_number);
|
701 |
+
|
702 |
+
// invoice number logging
|
703 |
+
// $order_number = ltrim($this->order->get_order_number(), '#');
|
704 |
+
// $this->log( $order_id, "Invoice number {$invoice_number} set for order {$order_number} (id {$order_id})" );
|
705 |
+
|
706 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_number', $invoice_number );
|
707 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_formatted_invoice_number', $this->get_invoice_number( $order_id ) );
|
708 |
+
|
709 |
+
// increase next_order_number
|
710 |
+
$update_args = array(
|
711 |
+
'option_value' => $invoice_number + 1,
|
712 |
+
'autoload' => 'yes',
|
713 |
+
);
|
714 |
+
$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => 'wpo_wcpdf_next_invoice_number' ) );
|
715 |
+
}
|
716 |
+
|
717 |
+
// store invoice_number in class object
|
718 |
+
$this->invoice_number = $invoice_number;
|
719 |
+
|
720 |
+
// store invoice number in _POST superglobal to prevent the number from being cleared in a save action
|
721 |
+
// (http://wordpress.org/support/topic/customer-invoice-selection-from-order-detail-page-doesnt-record-invoice-id?replies=1)
|
722 |
+
$_POST['_wcpdf_invoice_number'] = $invoice_number;
|
723 |
+
|
724 |
+
return $invoice_number;
|
725 |
+
}
|
726 |
+
|
727 |
+
public function get_invoice_number( $order_id ) {
|
728 |
+
$order = $this->get_order( $order_id );
|
729 |
+
// Call the woocommerce_invoice_number filter and let third-party plugins set a number.
|
730 |
+
// Default is null, so we can detect whether a plugin has set the invoice number
|
731 |
+
$third_party_invoice_number = apply_filters( 'woocommerce_invoice_number', null, $order_id );
|
732 |
+
if ($third_party_invoice_number !== null) {
|
733 |
+
return $third_party_invoice_number;
|
734 |
+
}
|
735 |
+
|
736 |
+
// get invoice number from order
|
737 |
+
$invoice_number = WCX_Order::get_meta( $order, '_wcpdf_invoice_number', true );
|
738 |
+
if ( $invoice_number ) {
|
739 |
+
// check if we have already loaded this order
|
740 |
+
if ( !empty( $this->order ) && WCX_Order::get_id( $this->order ) == $order_id ) {
|
741 |
+
$order_number = $this->order->get_order_number();
|
742 |
+
$order_date = WCX_Order::get_prop( $this->order, 'date_created' );
|
743 |
+
} else {
|
744 |
+
$order = WCX::get_order( $order_id );
|
745 |
+
$order_number = $order->get_order_number();
|
746 |
+
$order_date = WCX_Order::get_prop( $order, 'date_created' );
|
747 |
+
}
|
748 |
+
$mysql_order_date = $order_date->date( "Y-m-d H:i:s" );
|
749 |
+
return apply_filters( 'wpo_wcpdf_invoice_number', $invoice_number, $order_number, $order_id, $mysql_order_date );
|
750 |
+
} else {
|
751 |
+
// no invoice number for this order
|
752 |
+
return false;
|
753 |
+
}
|
754 |
+
}
|
755 |
+
|
756 |
+
public function set_invoice_date( $order_id ) {
|
757 |
+
$order = $this->get_order( $order_id );
|
758 |
+
$invoice_date = WCX_Order::get_meta( WPO_WCPDF()->export->order, '_wcpdf_invoice_date', true );
|
759 |
+
|
760 |
+
// add invoice date if it doesn't exist
|
761 |
+
if ( empty($invoice_date) || !isset($invoice_date) ) {
|
762 |
+
$invoice_date = current_time('mysql');
|
763 |
+
WCX_Order::update_meta_data( WPO_WCPDF()->export->order, '_wcpdf_invoice_date', $invoice_date );
|
764 |
+
}
|
765 |
+
|
766 |
+
return $invoice_date;
|
767 |
+
}
|
768 |
+
|
769 |
+
public function get_invoice_date( $order_id ) {
|
770 |
+
$invoice_date = $this->set_invoice_date( $order_id );
|
771 |
+
$formatted_invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
|
772 |
+
|
773 |
+
return apply_filters( 'wpo_wcpdf_invoice_date', $formatted_invoice_date, $invoice_date );
|
774 |
+
}
|
775 |
+
|
776 |
+
/**
|
777 |
+
* Add invoice number to WC REST API
|
778 |
+
*/
|
779 |
+
public function woocommerce_api_invoice_numer ( $data, $order ) {
|
780 |
+
if ( $invoice_number = $this->get_invoice_number( WCX_Order::get_id( $order ) ) ) {
|
781 |
+
$data['wpo_wcpdf_invoice_number'] = $invoice_number;
|
782 |
+
} else {
|
783 |
+
$data['wpo_wcpdf_invoice_number'] = '';
|
784 |
+
}
|
785 |
+
return $data;
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Reset invoice data for WooCommerce subscription renewal orders
|
790 |
+
* https://wordpress.org/support/topic/subscription-renewal-duplicate-invoice-number?replies=6#post-6138110
|
791 |
+
*/
|
792 |
+
public function woocommerce_subscriptions_renewal_order_created ( $renewal_order, $original_order, $product_id, $new_order_role ) {
|
793 |
+
$this->reset_invoice_data( WCX_Order::get_id( $renewal_order ) );
|
794 |
+
return $renewal_order;
|
795 |
+
}
|
796 |
+
|
797 |
+
public function wcs_renewal_order_created ( $renewal_order, $subscription ) {
|
798 |
+
$this->reset_invoice_data( WCX_Order::get_id( $renewal_order ) );
|
799 |
+
return $renewal_order;
|
800 |
+
}
|
801 |
+
|
802 |
+
public function reset_invoice_data ( $order_id ) {
|
803 |
+
$order = $this->get_order( $order_id );
|
804 |
+
// delete invoice number, invoice date & invoice exists meta
|
805 |
+
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_number' );
|
806 |
+
WCX_Order::delete_meta_data( $order, '_wcpdf_formatted_invoice_number' );
|
807 |
+
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_date' );
|
808 |
+
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
|
809 |
+
}
|
810 |
+
|
811 |
+
public function format_invoice_number( $invoice_number, $order_number, $order_id, $order_date ) {
|
812 |
+
$order = $this->get_order( $order_id );
|
813 |
+
// get format settings
|
814 |
+
$formats['prefix'] = isset($this->template_settings['invoice_number_formatting_prefix'])?$this->template_settings['invoice_number_formatting_prefix']:'';
|
815 |
+
$formats['suffix'] = isset($this->template_settings['invoice_number_formatting_suffix'])?$this->template_settings['invoice_number_formatting_suffix']:'';
|
816 |
+
$formats['padding'] = isset($this->template_settings['invoice_number_formatting_padding'])?$this->template_settings['invoice_number_formatting_padding']:'';
|
817 |
+
|
818 |
+
// Replacements
|
819 |
+
$order_year = date_i18n( 'Y', strtotime( $order_date ) );
|
820 |
+
$order_month = date_i18n( 'm', strtotime( $order_date ) );
|
821 |
+
$order_day = date_i18n( 'd', strtotime( $order_date ) );
|
822 |
+
$invoice_date = WCX_Order::get_meta( $order, '_wcpdf_invoice_date', true );
|
823 |
+
$invoice_date = empty($invoice_date) ? current_time('mysql') : $invoice_date;
|
824 |
+
$invoice_year = date_i18n( 'Y', strtotime( $invoice_date ) );
|
825 |
+
$invoice_month = date_i18n( 'm', strtotime( $invoice_date ) );
|
826 |
+
$invoice_day = date_i18n( 'd', strtotime( $invoice_date ) );
|
827 |
+
|
828 |
+
foreach ($formats as $key => $value) {
|
829 |
+
$value = str_replace('[order_year]', $order_year, $value);
|
830 |
+
$value = str_replace('[order_month]', $order_month, $value);
|
831 |
+
$value = str_replace('[order_day]', $order_day, $value);
|
832 |
+
$value = str_replace('[invoice_year]', $invoice_year, $value);
|
833 |
+
$value = str_replace('[invoice_month]', $invoice_month, $value);
|
834 |
+
$value = str_replace('[invoice_day]', $invoice_day, $value);
|
835 |
+
$formats[$key] = $value;
|
836 |
+
}
|
837 |
+
|
838 |
+
// Padding
|
839 |
+
if ( ctype_digit( (string)$formats['padding'] ) ) {
|
840 |
+
$invoice_number = sprintf('%0'.$formats['padding'].'d', $invoice_number);
|
841 |
+
}
|
842 |
+
|
843 |
+
$formatted_invoice_number = $formats['prefix'] . $invoice_number . $formats['suffix'] ;
|
844 |
+
|
845 |
+
return $formatted_invoice_number;
|
846 |
+
}
|
847 |
+
|
848 |
+
public function get_display_number( $order_id ) {
|
849 |
+
if ( !isset($this->order) ) {
|
850 |
+
$this->order = WCX::get_order ( $order_id );
|
851 |
+
}
|
852 |
+
|
853 |
+
if ( isset($this->template_settings['display_number']) && $this->template_settings['display_number'] == 'invoice_number' ) {
|
854 |
+
// use invoice number
|
855 |
+
$display_number = $this->get_invoice_number( $order_id );
|
856 |
+
// die($display_number);
|
857 |
+
} else {
|
858 |
+
// use order number
|
859 |
+
$display_number = ltrim($this->order->get_order_number(), '#');
|
860 |
+
}
|
861 |
+
|
862 |
+
return $display_number;
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Return evaluated template contents
|
867 |
+
*/
|
868 |
+
public function get_template( $file ) {
|
869 |
+
ob_start();
|
870 |
+
if (file_exists($file)) {
|
871 |
+
include($file);
|
872 |
+
}
|
873 |
+
return ob_get_clean();
|
874 |
+
}
|
875 |
+
|
876 |
+
/**
|
877 |
+
* Get the current order or order by id
|
878 |
+
*/
|
879 |
+
public function get_order( $order_id = null ) {
|
880 |
+
if ( empty( $order_id ) && isset( $this->order ) ) {
|
881 |
+
return $this->order;
|
882 |
+
} elseif ( is_object( $this->order ) && WCX_Order::get_id( $this->order ) == $order_id ) {
|
883 |
+
return $this->order;
|
884 |
+
} else {
|
885 |
+
return WCX::get_order( $order_id );
|
886 |
+
}
|
887 |
+
}
|
888 |
+
|
889 |
+
/**
|
890 |
+
* Get the current order items
|
891 |
+
*/
|
892 |
+
public function get_order_items() {
|
893 |
+
global $woocommerce;
|
894 |
+
global $_product;
|
895 |
+
|
896 |
+
$items = $this->order->get_items();
|
897 |
+
$data_list = array();
|
898 |
+
|
899 |
+
if( sizeof( $items ) > 0 ) {
|
900 |
+
foreach ( $items as $item_id => $item ) {
|
901 |
+
// Array with data for the pdf template
|
902 |
+
$data = array();
|
903 |
+
|
904 |
+
// Set the item_id
|
905 |
+
$data['item_id'] = $item_id;
|
906 |
+
|
907 |
+
// Set the id
|
908 |
+
$data['product_id'] = $item['product_id'];
|
909 |
+
$data['variation_id'] = $item['variation_id'];
|
910 |
+
|
911 |
+
// Set item name
|
912 |
+
$data['name'] = $item['name'];
|
913 |
+
|
914 |
+
// Set item quantity
|
915 |
+
$data['quantity'] = $item['qty'];
|
916 |
+
|
917 |
+
// Set the line total (=after discount)
|
918 |
+
$data['line_total'] = $this->wc_price( $item['line_total'] );
|
919 |
+
$data['single_line_total'] = $this->wc_price( $item['line_total'] / max( 1, $item['qty'] ) );
|
920 |
+
$data['line_tax'] = $this->wc_price( $item['line_tax'] );
|
921 |
+
$data['single_line_tax'] = $this->wc_price( $item['line_tax'] / max( 1, $item['qty'] ) );
|
922 |
+
|
923 |
+
$line_tax_data = maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' );
|
924 |
+
$data['tax_rates'] = $this->get_tax_rate( $item['tax_class'], $item['line_total'], $item['line_tax'], $line_tax_data );
|
925 |
+
|
926 |
+
// Set the line subtotal (=before discount)
|
927 |
+
$data['line_subtotal'] = $this->wc_price( $item['line_subtotal'] );
|
928 |
+
$data['line_subtotal_tax'] = $this->wc_price( $item['line_subtotal_tax'] );
|
929 |
+
$data['ex_price'] = $this->get_formatted_item_price ( $item, 'total', 'excl' );
|
930 |
+
$data['price'] = $this->get_formatted_item_price ( $item, 'total' );
|
931 |
+
$data['order_price'] = $this->order->get_formatted_line_subtotal( $item ); // formatted according to WC settings
|
932 |
+
|
933 |
+
// Calculate the single price with the same rules as the formatted line subtotal (!)
|
934 |
+
// = before discount
|
935 |
+
$data['ex_single_price'] = $this->get_formatted_item_price ( $item, 'single', 'excl' );
|
936 |
+
$data['single_price'] = $this->get_formatted_item_price ( $item, 'single' );
|
937 |
+
|
938 |
+
// Pass complete item array
|
939 |
+
$data['item'] = $item;
|
940 |
+
|
941 |
+
// Create the product to display more info
|
942 |
+
$data['product'] = null;
|
943 |
+
|
944 |
+
$product = $this->order->get_product_from_item( $item );
|
945 |
+
|
946 |
+
// Checking fo existance, thanks to MDesigner0
|
947 |
+
if(!empty($product)) {
|
948 |
+
// Thumbnail (full img tag)
|
949 |
+
$data['thumbnail'] = $this->get_thumbnail ( $product );
|
950 |
+
|
951 |
+
// Set the single price (turned off to use more consistent calculated price)
|
952 |
+
// $data['single_price'] = woocommerce_price ( $product->get_price() );
|
953 |
+
|
954 |
+
// Set item SKU
|
955 |
+
$data['sku'] = $product->get_sku();
|
956 |
+
|
957 |
+
// Set item weight
|
958 |
+
$data['weight'] = $product->get_weight();
|
959 |
+
|
960 |
+
// Set item dimensions
|
961 |
+
$data['dimensions'] = WCX_Product::get_dimensions( $product );
|
962 |
+
|
963 |
+
// Pass complete product object
|
964 |
+
$data['product'] = $product;
|
965 |
+
|
966 |
+
}
|
967 |
+
|
968 |
+
// Set item meta
|
969 |
+
if (function_exists('wc_display_item_meta')) { // WC3.0+
|
970 |
+
$data['meta'] = wc_display_item_meta( $item, array(
|
971 |
+
'echo' => false,
|
972 |
+
) );
|
973 |
+
} else {
|
974 |
+
if ( version_compare( WOOCOMMERCE_VERSION, '2.4', '<' ) ) {
|
975 |
+
$meta = new WC_Order_Item_Meta( $item['item_meta'], $product );
|
976 |
+
} else { // pass complete item for WC2.4+
|
977 |
+
$meta = new WC_Order_Item_Meta( $item, $product );
|
978 |
+
}
|
979 |
+
$data['meta'] = $meta->display( false, true );
|
980 |
+
}
|
981 |
+
|
982 |
+
$data_list[$item_id] = apply_filters( 'wpo_wcpdf_order_item_data', $data, $this->order );
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
return apply_filters( 'wpo_wcpdf_order_items_data', $data_list, $this->order );
|
987 |
+
}
|
988 |
+
|
989 |
+
/**
|
990 |
+
* Gets price - formatted for display.
|
991 |
+
*
|
992 |
+
* @access public
|
993 |
+
* @param mixed $item
|
994 |
+
* @return string
|
995 |
+
*/
|
996 |
+
public function get_formatted_item_price ( $item, $type, $tax_display = '' ) {
|
997 |
+
$item_price = 0;
|
998 |
+
$divider = ($type == 'single' && $item['qty'] != 0 )?$item['qty']:1; //divide by 1 if $type is not 'single' (thus 'total')
|
999 |
+
|
1000 |
+
if ( ! isset( $item['line_subtotal'] ) || ! isset( $item['line_subtotal_tax'] ) )
|
1001 |
+
return;
|
1002 |
+
|
1003 |
+
if ( $tax_display == 'excl' ) {
|
1004 |
+
$item_price = $this->wc_price( ($this->order->get_line_subtotal( $item )) / $divider );
|
1005 |
+
} else {
|
1006 |
+
$item_price = $this->wc_price( ($this->order->get_line_subtotal( $item, true )) / $divider );
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
return $item_price;
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
/**
|
1013 |
+
* wrapper for wc2.1 depricated price function
|
1014 |
+
*/
|
1015 |
+
public function wc_price( $price, $args = array() ) {
|
1016 |
+
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
|
1017 |
+
// WC 2.1 or newer is used
|
1018 |
+
$args['currency'] = WCX_Order::get_prop( $this->order, 'currency' );
|
1019 |
+
$formatted_price = wc_price( $price, $args );
|
1020 |
+
} else {
|
1021 |
+
$formatted_price = woocommerce_price( $price );
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
return $formatted_price;
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
/**
|
1028 |
+
* Get the tax rates/percentages for a given tax class
|
1029 |
+
* @param string $tax_class tax class slug
|
1030 |
+
* @return string $tax_rates imploded list of tax rates
|
1031 |
+
*/
|
1032 |
+
public function get_tax_rate( $tax_class, $line_total, $line_tax, $line_tax_data = '' ) {
|
1033 |
+
// first try the easy wc2.2+ way, using line_tax_data
|
1034 |
+
if ( !empty( $line_tax_data ) && isset($line_tax_data['total']) ) {
|
1035 |
+
$tax_rates = array();
|
1036 |
+
|
1037 |
+
$line_taxes = $line_tax_data['subtotal'];
|
1038 |
+
foreach ( $line_taxes as $tax_id => $tax ) {
|
1039 |
+
if ( !empty($tax) ) {
|
1040 |
+
$tax_rates[] = $this->get_tax_rate_by_id( $tax_id ) . ' %';
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
$tax_rates = implode(' ,', $tax_rates );
|
1045 |
+
return $tax_rates;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
if ( $line_tax == 0 ) {
|
1049 |
+
return '-'; // no need to determine tax rate...
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 && !apply_filters( 'wpo_wcpdf_calculate_tax_rate', false ) ) {
|
1053 |
+
// WC 2.1 or newer is used
|
1054 |
+
|
1055 |
+
// if (empty($tax_class))
|
1056 |
+
// $tax_class = 'standard';// does not appear to work anymore - get_rates does accept an empty tax_class though!
|
1057 |
+
|
1058 |
+
$tax = new WC_Tax();
|
1059 |
+
$taxes = $tax->get_rates( $tax_class );
|
1060 |
+
|
1061 |
+
$tax_rates = array();
|
1062 |
+
|
1063 |
+
foreach ($taxes as $tax) {
|
1064 |
+
$tax_rates[$tax['label']] = round( $tax['rate'], 2 ).' %';
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
if (empty($tax_rates)) {
|
1068 |
+
// one last try: manually calculate
|
1069 |
+
if ( $line_total != 0) {
|
1070 |
+
$tax_rates[] = round( ($line_tax / $line_total)*100, 1 ).' %';
|
1071 |
+
} else {
|
1072 |
+
$tax_rates[] = '-';
|
1073 |
+
}
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
$tax_rates = implode(' ,', $tax_rates );
|
1077 |
+
} else {
|
1078 |
+
// Backwards compatibility/fallback: calculate tax from line items
|
1079 |
+
if ( $line_total != 0) {
|
1080 |
+
$tax_rates = round( ($line_tax / $line_total)*100, 1 ).' %';
|
1081 |
+
} else {
|
1082 |
+
$tax_rates = '-';
|
1083 |
+
}
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
return $tax_rates;
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
/**
|
1090 |
+
* Returns the percentage rate (float) for a given tax rate ID.
|
1091 |
+
* @param int $rate_id woocommerce tax rate id
|
1092 |
+
* @return float $rate percentage rate
|
1093 |
+
*/
|
1094 |
+
public function get_tax_rate_by_id( $rate_id ) {
|
1095 |
+
global $wpdb;
|
1096 |
+
$rate = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $rate_id ) );
|
1097 |
+
return (float) $rate;
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
/**
|
1101 |
+
* Returns a an array with rate_id => tax rate data (array) of all tax rates in woocommerce
|
1102 |
+
* @return array $tax_rate_ids keyed by id
|
1103 |
+
*/
|
1104 |
+
public function get_tax_rate_ids() {
|
1105 |
+
global $wpdb;
|
1106 |
+
$rates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates" );
|
1107 |
+
|
1108 |
+
$tax_rate_ids = array();
|
1109 |
+
foreach ($rates as $rate) {
|
1110 |
+
// var_dump($rate->tax_rate_id);
|
1111 |
+
// die($rate);
|
1112 |
+
$rate_id = $rate->tax_rate_id;
|
1113 |
+
unset($rate->tax_rate_id);
|
1114 |
+
$tax_rate_ids[$rate_id] = (array) $rate;
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
return $tax_rate_ids;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
/**
|
1121 |
+
* Get order custom field
|
1122 |
+
*/
|
1123 |
+
public function get_order_field( $field ) {
|
1124 |
+
if( isset( $this->get_order()->order_custom_fields[$field] ) ) {
|
1125 |
+
return $this->get_order()->order_custom_fields[$field][0];
|
1126 |
+
}
|
1127 |
+
return;
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
/**
|
1131 |
+
* Returns the main product image ID
|
1132 |
+
* Adapted from the WC_Product class
|
1133 |
+
* (does not support thumbnail sizes)
|
1134 |
+
*
|
1135 |
+
* @access public
|
1136 |
+
* @return string
|
1137 |
+
*/
|
1138 |
+
public function get_thumbnail_id ( $product ) {
|
1139 |
+
global $woocommerce;
|
1140 |
+
|
1141 |
+
$product_id = WCX_Product::get_id( $product );
|
1142 |
+
|
1143 |
+
if ( has_post_thumbnail( $product_id ) ) {
|
1144 |
+
$thumbnail_id = get_post_thumbnail_id ( $product_id );
|
1145 |
+
} elseif ( ( $parent_id = wp_get_post_parent_id( $product_id ) ) && has_post_thumbnail( $parent_id ) ) {
|
1146 |
+
$thumbnail_id = get_post_thumbnail_id ( $parent_id );
|
1147 |
+
} else {
|
1148 |
+
$thumbnail_id = false;
|
1149 |
+
}
|
1150 |
+
|
1151 |
+
return $thumbnail_id;
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
/**
|
1155 |
+
* Returns the thumbnail image tag
|
1156 |
+
*
|
1157 |
+
* uses the internal WooCommerce/WP functions and extracts the image url or path
|
1158 |
+
* rather than the thumbnail ID, to simplify the code and make it possible to
|
1159 |
+
* filter for different thumbnail sizes
|
1160 |
+
*
|
1161 |
+
* @access public
|
1162 |
+
* @return string
|
1163 |
+
*/
|
1164 |
+
public function get_thumbnail ( $product ) {
|
1165 |
+
// Get default WooCommerce img tag (url/http)
|
1166 |
+
$size = apply_filters( 'wpo_wcpdf_thumbnail_size', 'shop_thumbnail' );
|
1167 |
+
$thumbnail_img_tag_url = $product->get_image( $size, array( 'title' => '' ) );
|
1168 |
+
|
1169 |
+
// Extract the url from img
|
1170 |
+
preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $thumbnail_img_tag_url, $thumbnail_url );
|
1171 |
+
// remove http/https from image tag url to avoid mixed origin conflicts
|
1172 |
+
$thumbnail_url = array_pop($thumbnail_url);
|
1173 |
+
$contextless_thumbnail_url = str_replace(array('http://','https://'), '', $thumbnail_url );
|
1174 |
+
$contextless_site_url = str_replace(array('http://','https://'), '', trailingslashit(get_site_url()));
|
1175 |
+
|
1176 |
+
// convert url to path
|
1177 |
+
$thumbnail_path = str_replace( $contextless_site_url, ABSPATH, $contextless_thumbnail_url);
|
1178 |
+
// fallback if thumbnail file doesn't exist
|
1179 |
+
if (apply_filters('wpo_wcpdf_use_path', true) && !file_exists($thumbnail_path)) {
|
1180 |
+
if ($thumbnail_id = $this->get_thumbnail_id( $product ) ) {
|
1181 |
+
$thumbnail_path = get_attached_file( $thumbnail_id );
|
1182 |
+
}
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
// Thumbnail (full img tag)
|
1186 |
+
if (apply_filters('wpo_wcpdf_use_path', true) && file_exists($thumbnail_path)) {
|
1187 |
+
// load img with server path by default
|
1188 |
+
$thumbnail = sprintf('<img width="90" height="90" src="%s" class="attachment-shop_thumbnail wp-post-image">', $thumbnail_path );
|
1189 |
+
} else {
|
1190 |
+
// load img with http url when filtered
|
1191 |
+
$thumbnail = $thumbnail_img_tag_url;
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
// die($thumbnail);
|
1195 |
+
return $thumbnail;
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
public function add_product_bundles_classes ( $classes, $template_type, $order, $item_id = '' ) {
|
1199 |
+
if ( empty($item_id) ) {
|
1200 |
+
// get item id from classes (backwards compatibility fix)
|
1201 |
+
$class_array = explode(' ', $classes);
|
1202 |
+
foreach ($class_array as $class) {
|
1203 |
+
if (is_numeric($class)) {
|
1204 |
+
$item_id = $class;
|
1205 |
+
break;
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
// if still empty, we lost the item id somewhere :(
|
1210 |
+
if (empty($item_id)) {
|
1211 |
+
return $classes;
|
1212 |
+
}
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
if ( $bundled_by = WCX_Order::get_item_meta( $order, $item_id, '_bundled_by', true ) ) {
|
1216 |
+
$classes = $classes . ' bundled-item';
|
1217 |
+
|
1218 |
+
// check bundled item visibility
|
1219 |
+
if ( $hidden = WCX_Order::get_item_meta( $order, $item_id, '_bundled_item_hidden', true ) ) {
|
1220 |
+
$classes = $classes . ' hidden';
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
return $classes;
|
1224 |
+
} elseif ( $bundled_items = WCX_Order::get_item_meta( $order, $item_id, '_bundled_items', true ) ) {
|
1225 |
+
return $classes . ' product-bundle';
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
return $classes;
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
public function add_chained_product_class ( $classes, $template_type, $order, $item_id = '' ) {
|
1232 |
+
if ( empty($item_id) ) {
|
1233 |
+
// get item id from classes (backwards compatibility fix)
|
1234 |
+
$class_array = explode(' ', $classes);
|
1235 |
+
foreach ($class_array as $class) {
|
1236 |
+
if (is_numeric($class)) {
|
1237 |
+
$item_id = $class;
|
1238 |
+
break;
|
1239 |
+
}
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
// if still empty, we lost the item id somewhere :(
|
1243 |
+
if (empty($item_id)) {
|
1244 |
+
return $classes;
|
1245 |
+
}
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
if ( $chained_product_of = WCX_Order::get_item_meta( $order, $item_id, '_chained_product_of', true ) ) {
|
1249 |
+
return $classes . ' chained-product';
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
return $classes;
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
/**
|
1256 |
+
* Filter plugin strings with qTranslate-X
|
1257 |
+
*/
|
1258 |
+
public function qtranslatex_filters() {
|
1259 |
+
$use_filters = array(
|
1260 |
+
'wpo_wcpdf_shop_name' => 20,
|
1261 |
+
'wpo_wcpdf_shop_address' => 20,
|
1262 |
+
'wpo_wcpdf_footer' => 20,
|
1263 |
+
'wpo_wcpdf_order_items' => 20,
|
1264 |
+
'wpo_wcpdf_payment_method' => 20,
|
1265 |
+
'wpo_wcpdf_shipping_method' => 20,
|
1266 |
+
'wpo_wcpdf_extra_1' => 20,
|
1267 |
+
'wpo_wcpdf_extra_2' => 20,
|
1268 |
+
'wpo_wcpdf_extra_3' => 20,
|
1269 |
+
);
|
1270 |
+
|
1271 |
+
foreach ( $use_filters as $name => $priority ) {
|
1272 |
+
add_filter( $name, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority );
|
1273 |
+
}
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* Use currency symbol font (when enabled in options)
|
1278 |
+
*/
|
1279 |
+
public function use_currency_font ( $template_type ) {
|
1280 |
+
add_filter( 'woocommerce_currency_symbol', array( $this, 'wrap_currency_symbol' ), 10, 2);
|
1281 |
+
add_action( 'wpo_wcpdf_custom_styles', array($this, 'currency_symbol_font_styles' ) );
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
public function wrap_currency_symbol( $currency_symbol, $currency ) {
|
1285 |
+
$currency_symbol = sprintf( '<span class="wcpdf-currency-symbol">%s</span>', $currency_symbol );
|
1286 |
+
return $currency_symbol;
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
public function currency_symbol_font_styles () {
|
1290 |
+
?>
|
1291 |
+
.wcpdf-currency-symbol { font-family: 'Currencies'; }
|
1292 |
+
<?php
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
public function enable_debug () {
|
1296 |
+
error_reporting( E_ALL );
|
1297 |
+
ini_set( 'display_errors', 1 );
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
/**
|
1301 |
+
* Log messages
|
1302 |
+
*/
|
1303 |
+
|
1304 |
+
public function log( $order_id, $message ) {
|
1305 |
+
$current_date_time = date("Y-m-d H:i:s");
|
1306 |
+
$message = $order_id . ' ' . $current_date_time .' ' .$message ."\n";
|
1307 |
+
$file = $this->tmp_path() . 'log.txt';
|
1308 |
+
|
1309 |
+
file_put_contents($file, $message, FILE_APPEND);
|
1310 |
+
}
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
}
|
includes/class-wcpdf-writepanels.php
CHANGED
@@ -1,384 +1,384 @@
|
|
1 |
-
<?php
|
2 |
-
use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
|
3 |
-
use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
|
4 |
-
use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
|
5 |
-
|
6 |
-
defined( 'ABSPATH' ) or exit;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Writepanel class
|
10 |
-
*/
|
11 |
-
if ( !class_exists( 'WooCommerce_PDF_Invoices_Writepanels' ) ) {
|
12 |
-
|
13 |
-
class WooCommerce_PDF_Invoices_Writepanels {
|
14 |
-
public $bulk_actions;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Constructor
|
18 |
-
*/
|
19 |
-
public function __construct() {
|
20 |
-
$this->general_settings = get_option('wpo_wcpdf_general_settings');
|
21 |
-
$this->template_settings = get_option('wpo_wcpdf_template_settings');
|
22 |
-
|
23 |
-
add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) );
|
24 |
-
add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_invoice_number_column' ), 999 );
|
25 |
-
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'invoice_number_column_data' ), 2 );
|
26 |
-
add_action( 'add_meta_boxes_shop_order', array( $this, 'add_meta_boxes' ) );
|
27 |
-
add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'my_account_pdf_link' ), 10, 2 );
|
28 |
-
add_action( 'admin_print_scripts', array( $this, 'add_scripts' ) );
|
29 |
-
add_action( 'admin_print_styles', array( $this, 'add_styles' ) );
|
30 |
-
add_action( 'admin_footer', array( $this, 'bulk_actions' ) );
|
31 |
-
|
32 |
-
add_action( 'save_post', array( $this,'save_invoice_number_date' ) );
|
33 |
-
|
34 |
-
add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'search_fields' ) );
|
35 |
-
|
36 |
-
$this->bulk_actions = array(
|
37 |
-
'invoice' => __( 'PDF Invoices', 'wpo_wcpdf' ),
|
38 |
-
'packing-slip' => __( 'PDF Packing Slips', 'wpo_wcpdf' ),
|
39 |
-
);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Add the styles
|
44 |
-
*/
|
45 |
-
public function add_styles() {
|
46 |
-
if( $this->is_order_edit_page() ) {
|
47 |
-
wp_enqueue_style( 'thickbox' );
|
48 |
-
|
49 |
-
wp_enqueue_style(
|
50 |
-
'wpo-wcpdf',
|
51 |
-
WooCommerce_PDF_Invoices::$plugin_url . 'css/style.css',
|
52 |
-
array(),
|
53 |
-
WooCommerce_PDF_Invoices::$version
|
54 |
-
);
|
55 |
-
|
56 |
-
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
|
57 |
-
// WC 2.1 or newer (MP6) is used: bigger buttons
|
58 |
-
wp_enqueue_style(
|
59 |
-
'wpo-wcpdf-buttons',
|
60 |
-
WooCommerce_PDF_Invoices::$plugin_url . 'css/style-buttons.css',
|
61 |
-
array(),
|
62 |
-
WooCommerce_PDF_Invoices::$version
|
63 |
-
);
|
64 |
-
} else {
|
65 |
-
// legacy WC 2.0 styles
|
66 |
-
wp_enqueue_style(
|
67 |
-
'wpo-wcpdf-buttons',
|
68 |
-
WooCommerce_PDF_Invoices::$plugin_url . 'css/style-buttons-wc20.css',
|
69 |
-
array(),
|
70 |
-
WooCommerce_PDF_Invoices::$version
|
71 |
-
);
|
72 |
-
}
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Add the scripts
|
78 |
-
*/
|
79 |
-
public function add_scripts() {
|
80 |
-
if( $this->is_order_edit_page() ) {
|
81 |
-
wp_enqueue_script(
|
82 |
-
'wpo-wcpdf',
|
83 |
-
WooCommerce_PDF_Invoices::$plugin_url . 'js/script.js',
|
84 |
-
array( 'jquery' ),
|
85 |
-
WooCommerce_PDF_Invoices::$version
|
86 |
-
);
|
87 |
-
wp_localize_script(
|
88 |
-
'wpo-wcpdf',
|
89 |
-
'wpo_wcpdf_ajax',
|
90 |
-
array(
|
91 |
-
// 'ajaxurl' => add_query_arg( 'action', 'generate_wpo_wcpdf', admin_url( 'admin-ajax.php' ) ), // URL to WordPress ajax handling page
|
92 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ), // URL to WordPress ajax handling page
|
93 |
-
'nonce' => wp_create_nonce('generate_wpo_wcpdf'),
|
94 |
-
'bulk_actions' => array_keys( apply_filters( 'wpo_wcpdf_bulk_actions', $this->bulk_actions ) ),
|
95 |
-
)
|
96 |
-
);
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Is order page
|
102 |
-
*/
|
103 |
-
public function is_order_edit_page() {
|
104 |
-
global $post_type;
|
105 |
-
if( $post_type == 'shop_order' ) {
|
106 |
-
return true;
|
107 |
-
} else {
|
108 |
-
return false;
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Add PDF actions to the orders listing
|
114 |
-
*/
|
115 |
-
public function add_listing_actions( $order ) {
|
116 |
-
// do not show buttons for trashed orders
|
117 |
-
if ( WCX_Order::get_status( $order ) == 'trash' ) {
|
118 |
-
return;
|
119 |
-
}
|
120 |
-
|
121 |
-
$listing_actions = array(
|
122 |
-
'invoice' => array (
|
123 |
-
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . WCX_Order::get_id( $order ) ), 'generate_wpo_wcpdf' ),
|
124 |
-
'img' => WooCommerce_PDF_Invoices::$plugin_url . 'images/invoice.png',
|
125 |
-
'alt' => __( 'PDF Invoice', 'wpo_wcpdf' ),
|
126 |
-
),
|
127 |
-
'packing-slip' => array (
|
128 |
-
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=packing-slip&order_ids=' . WCX_Order::get_id( $order ) ), 'generate_wpo_wcpdf' ),
|
129 |
-
'img' => WooCommerce_PDF_Invoices::$plugin_url . 'images/packing-slip.png',
|
130 |
-
'alt' => __( 'PDF Packing Slip', 'wpo_wcpdf' ),
|
131 |
-
),
|
132 |
-
);
|
133 |
-
|
134 |
-
$listing_actions = apply_filters( 'wpo_wcpdf_listing_actions', $listing_actions, $order );
|
135 |
-
|
136 |
-
foreach ($listing_actions as $action => $data) {
|
137 |
-
?>
|
138 |
-
<a href="<?php echo $data['url']; ?>" class="button tips wpo_wcpdf <?php echo $action; ?>" target="_blank" alt="<?php echo $data['alt']; ?>" data-tip="<?php echo $data['alt']; ?>">
|
139 |
-
<img src="<?php echo $data['img']; ?>" alt="<?php echo $data['alt']; ?>" width="16">
|
140 |
-
</a>
|
141 |
-
<?php
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Create additional Shop Order column for Invoice Numbers
|
147 |
-
* @param array $columns shop order columns
|
148 |
-
*/
|
149 |
-
public function add_invoice_number_column( $columns ) {
|
150 |
-
// Check user setting
|
151 |
-
if ( !isset($this->general_settings['invoice_number_column'] ) ) {
|
152 |
-
return $columns;
|
153 |
-
}
|
154 |
-
|
155 |
-
// put the column after the Status column
|
156 |
-
$new_columns = array_slice($columns, 0, 2, true) +
|
157 |
-
array( 'pdf_invoice_number' => __( 'Invoice Number', 'wpo_wcpdf' ) ) +
|
158 |
-
array_slice($columns, 2, count($columns) - 1, true) ;
|
159 |
-
return $new_columns;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Display Invoice Number in Shop Order column (if available)
|
164 |
-
* @param string $column column slug
|
165 |
-
*/
|
166 |
-
public function invoice_number_column_data( $column ) {
|
167 |
-
global $post, $the_order, $wpo_wcpdf;
|
168 |
-
|
169 |
-
if ( $column == 'pdf_invoice_number' ) {
|
170 |
-
if ( empty( $the_order ) || WCX_Order::get_id( $the_order ) != $post->ID ) {
|
171 |
-
$order = WCX::get_order( $post->ID );
|
172 |
-
echo $wpo_wcpdf->export->get_invoice_number( WCX_Order::get_id( $order ) );
|
173 |
-
do_action( 'wcpdf_invoice_number_column_end', $order );
|
174 |
-
} else {
|
175 |
-
echo $wpo_wcpdf->export->get_invoice_number( WCX_Order::get_id( $the_order ) );
|
176 |
-
do_action( 'wcpdf_invoice_number_column_end', $the_order );
|
177 |
-
}
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Display download link on My Account page
|
183 |
-
*/
|
184 |
-
public function my_account_pdf_link( $actions, $order ) {
|
185 |
-
$pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . WCX_Order::get_id( $order ) . '&my-account'), 'generate_wpo_wcpdf' );
|
186 |
-
|
187 |
-
// check my account button settings
|
188 |
-
if (isset($this->general_settings['my_account_buttons'])) {
|
189 |
-
switch ($this->general_settings['my_account_buttons']) {
|
190 |
-
case 'available':
|
191 |
-
$invoice_allowed = WCX_Order::get_meta( $order, '_wcpdf_invoice_exists', true );
|
192 |
-
break;
|
193 |
-
case 'always':
|
194 |
-
$invoice_allowed = true;
|
195 |
-
break;
|
196 |
-
case 'never':
|
197 |
-
$invoice_allowed = false;
|
198 |
-
break;
|
199 |
-
case 'custom':
|
200 |
-
if ( isset( $this->general_settings['my_account_restrict'] ) && in_array( WCX_Order::get_status( $order ), array_keys( $this->general_settings['my_account_restrict'] ) ) ) {
|
201 |
-
$invoice_allowed = true;
|
202 |
-
} else {
|
203 |
-
$invoice_allowed = false;
|
204 |
-
}
|
205 |
-
break;
|
206 |
-
}
|
207 |
-
} else {
|
208 |
-
// backwards compatibility
|
209 |
-
$invoice_allowed = WCX_Order::get_meta( $order, '_wcpdf_invoice_exists', true );
|
210 |
-
}
|
211 |
-
|
212 |
-
// Check if invoice has been created already or if status allows download (filter your own array of allowed statuses)
|
213 |
-
if ( $invoice_allowed || in_array(WCX_Order::get_status( $order ), apply_filters( 'wpo_wcpdf_myaccount_allowed_order_statuses', array() ) ) ) {
|
214 |
-
$actions['invoice'] = array(
|
215 |
-
'url' => $pdf_url,
|
216 |
-
'name' => apply_filters( 'wpo_wcpdf_myaccount_button_text', __( 'Download invoice (PDF)', 'wpo_wcpdf' ) )
|
217 |
-
);
|
218 |
-
}
|
219 |
-
|
220 |
-
return apply_filters( 'wpo_wcpdf_myaccount_actions', $actions, $order );
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Add the meta box on the single order page
|
225 |
-
*/
|
226 |
-
public function add_meta_boxes() {
|
227 |
-
// create PDF buttons
|
228 |
-
add_meta_box(
|
229 |
-
'wpo_wcpdf-box',
|
230 |
-
__( 'Create PDF', 'wpo_wcpdf' ),
|
231 |
-
array( $this, 'sidebar_box_content' ),
|
232 |
-
'shop_order',
|
233 |
-
'side',
|
234 |
-
'default'
|
235 |
-
);
|
236 |
-
|
237 |
-
// Invoice number & date
|
238 |
-
add_meta_box(
|
239 |
-
'wpo_wcpdf-data-input-box',
|
240 |
-
__( 'PDF Invoice data', 'wpo_wcpdf' ),
|
241 |
-
array( $this, 'data_input_box_content' ),
|
242 |
-
'shop_order',
|
243 |
-
'normal',
|
244 |
-
'default'
|
245 |
-
);
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Create the meta box content on the single order page
|
250 |
-
*/
|
251 |
-
public function sidebar_box_content( $post ) {
|
252 |
-
global $post_id;
|
253 |
-
|
254 |
-
$meta_actions = array(
|
255 |
-
'invoice' => array (
|
256 |
-
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $post_id ), 'generate_wpo_wcpdf' ),
|
257 |
-
'alt' => esc_attr__( 'PDF Invoice', 'wpo_wcpdf' ),
|
258 |
-
'title' => __( 'PDF Invoice', 'wpo_wcpdf' ),
|
259 |
-
),
|
260 |
-
'packing-slip' => array (
|
261 |
-
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=packing-slip&order_ids=' . $post_id ), 'generate_wpo_wcpdf' ),
|
262 |
-
'alt' => esc_attr__( 'PDF Packing Slip', 'wpo_wcpdf' ),
|
263 |
-
'title' => __( 'PDF Packing Slip', 'wpo_wcpdf' ),
|
264 |
-
),
|
265 |
-
);
|
266 |
-
|
267 |
-
$meta_actions = apply_filters( 'wpo_wcpdf_meta_box_actions', $meta_actions, $post_id );
|
268 |
-
|
269 |
-
?>
|
270 |
-
<ul class="wpo_wcpdf-actions">
|
271 |
-
<?php
|
272 |
-
foreach ($meta_actions as $action => $data) {
|
273 |
-
printf('<li><a href="%1$s" class="button" target="_blank" alt="%2$s">%3$s</a></li>', $data['url'], $data['alt'],$data['title']);
|
274 |
-
}
|
275 |
-
?>
|
276 |
-
</ul>
|
277 |
-
<?php
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Add metabox for invoice number & date
|
282 |
-
*/
|
283 |
-
public function data_input_box_content ( $post ) {
|
284 |
-
$order = WCX::get_order( $post->ID );
|
285 |
-
$invoice_exists = WCX_Order::get_meta( $order, '_wcpdf_invoice_exists', true );
|
286 |
-
$invoice_number = WCX_Order::get_meta( $order, '_wcpdf_invoice_number', true );
|
287 |
-
$invoice_date = WCX_Order::get_meta( $order, '_wcpdf_invoice_date', true );
|
288 |
-
|
289 |
-
do_action( 'wpo_wcpdf_meta_box_start', $post->ID );
|
290 |
-
|
291 |
-
?>
|
292 |
-
<h4><?php _e( 'Invoice', 'wpo_wcpdf' ) ?></h4>
|
293 |
-
<p class="form-field _wcpdf_invoice_number_field ">
|
294 |
-
<label for="_wcpdf_invoice_number"><?php _e( 'Invoice Number (unformatted!)', 'wpo_wcpdf' ); ?>:</label>
|
295 |
-
<?php if (!empty($invoice_exists)) : ?>
|
296 |
-
<input type="text" class="short" style="" name="_wcpdf_invoice_number" id="_wcpdf_invoice_number" value="<?php echo $invoice_number ?>">
|
297 |
-
<?php else : ?>
|
298 |
-
<input type="text" class="short" style="" name="_wcpdf_invoice_number" id="_wcpdf_invoice_number" value="<?php echo $invoice_number ?>" disabled="disabled" >
|
299 |
-
<?php endif; ?>
|
300 |
-
</p>
|
301 |
-
<p class="form-field form-field-wide">
|
302 |
-
<label for="wcpdf_invoice_date"><?php _e( 'Invoice Date:', 'wpo_wcpdf' ); ?></label>
|
303 |
-
<?php if (!empty($invoice_exists)) : ?>
|
304 |
-
<input type="text" class="date-picker-field" name="wcpdf_invoice_date" id="wcpdf_invoice_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $invoice_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="number" class="hour" placeholder="<?php _e( 'h', 'woocommerce' ) ?>" name="wcpdf_invoice_date_hour" id="wcpdf_invoice_date_hour" min="0" max="23" size="2" value="<?php echo date_i18n( 'H', strtotime( $invoice_date ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:<input type="number" class="minute" placeholder="<?php _e( 'm', 'woocommerce' ) ?>" name="wcpdf_invoice_date_minute" id="wcpdf_invoice_date_minute" min="0" max="59" size="2" value="<?php echo date_i18n( 'i', strtotime( $invoice_date ) ); ?>" pattern="[0-5]{1}[0-9]{1}" />
|
305 |
-
<?php else : ?>
|
306 |
-
<input type="text" class="date-picker-field" name="wcpdf_invoice_date" id="wcpdf_invoice_date" maxlength="10" disabled="disabled" value="" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="number" class="hour" disabled="disabled" placeholder="<?php _e( 'h', 'woocommerce' ) ?>" name="wcpdf_invoice_date_hour" id="wcpdf_invoice_date_hour" min="0" max="23" size="2" value="" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:<input type="number" class="minute" placeholder="<?php _e( 'm', 'woocommerce' ) ?>" name="wcpdf_invoice_date_minute" id="wcpdf_invoice_date_minute" min="0" max="59" size="2" value="" pattern="[0-5]{1}[0-9]{1}" disabled="disabled" />
|
307 |
-
<?php endif; ?>
|
308 |
-
</p>
|
309 |
-
<?php
|
310 |
-
|
311 |
-
do_action( 'wpo_wcpdf_meta_box_end', $post->ID );
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Add actions to menu
|
316 |
-
*/
|
317 |
-
public function bulk_actions() {
|
318 |
-
global $post_type;
|
319 |
-
$bulk_actions = apply_filters( 'wpo_wcpdf_bulk_actions', $this->bulk_actions );
|
320 |
-
|
321 |
-
if ( 'shop_order' == $post_type ) {
|
322 |
-
?>
|
323 |
-
<script type="text/javascript">
|
324 |
-
jQuery(document).ready(function() {
|
325 |
-
<?php foreach ($bulk_actions as $action => $title) { ?>
|
326 |
-
jQuery('<option>').val('<?php echo $action; ?>').html('<?php echo esc_attr( $title ); ?>').appendTo("select[name='action'], select[name='action2']");
|
327 |
-
<?php } ?>
|
328 |
-
});
|
329 |
-
</script>
|
330 |
-
<?php
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* Save invoice number
|
336 |
-
*/
|
337 |
-
public function save_invoice_number_date($post_id) {
|
338 |
-
global $wpo_wcpdf;
|
339 |
-
$post_type = get_post_type( $post_id );
|
340 |
-
if( $post_type == 'shop_order' ) {
|
341 |
-
// bail if this is not an actual 'Save order' action
|
342 |
-
if (!isset($_POST['action']) || $_POST['action'] != 'editpost') {
|
343 |
-
return;
|
344 |
-
}
|
345 |
-
|
346 |
-
$order = WCX::get_order( $post_id );
|
347 |
-
if ( isset($_POST['_wcpdf_invoice_number']) ) {
|
348 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_number', stripslashes( $_POST['_wcpdf_invoice_number'] ) );
|
349 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_formatted_invoice_number', $wpo_wcpdf->export->get_invoice_number( $post_id ) );
|
350 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_exists', 1 );
|
351 |
-
}
|
352 |
-
|
353 |
-
if ( isset($_POST['wcpdf_invoice_date']) ) {
|
354 |
-
if ( empty($_POST['wcpdf_invoice_date']) ) {
|
355 |
-
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_date' );
|
356 |
-
} else {
|
357 |
-
$invoice_date = strtotime( $_POST['wcpdf_invoice_date'] . ' ' . (int) $_POST['wcpdf_invoice_date_hour'] . ':' . (int) $_POST['wcpdf_invoice_date_minute'] . ':00' );
|
358 |
-
$invoice_date = date_i18n( 'Y-m-d H:i:s', $invoice_date );
|
359 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_date', $invoice_date );
|
360 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_exists', 1 );
|
361 |
-
}
|
362 |
-
}
|
363 |
-
|
364 |
-
if (empty($_POST['wcpdf_invoice_date']) && isset($_POST['_wcpdf_invoice_number'])) {
|
365 |
-
$invoice_date = date_i18n( 'Y-m-d H:i:s', time() );
|
366 |
-
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_date', $invoice_date );
|
367 |
-
}
|
368 |
-
|
369 |
-
if ( empty($_POST['wcpdf_invoice_date']) && empty($_POST['_wcpdf_invoice_number'])) {
|
370 |
-
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
|
371 |
-
}
|
372 |
-
}
|
373 |
-
}
|
374 |
-
|
375 |
-
/**
|
376 |
-
* Add invoice number to order search scope
|
377 |
-
*/
|
378 |
-
public function search_fields ( $custom_fields ) {
|
379 |
-
$custom_fields[] = '_wcpdf_invoice_number';
|
380 |
-
$custom_fields[] = '_wcpdf_formatted_invoice_number';
|
381 |
-
return $custom_fields;
|
382 |
-
}
|
383 |
-
}
|
384 |
}
|
1 |
+
<?php
|
2 |
+
use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
|
3 |
+
use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
|
4 |
+
use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
|
5 |
+
|
6 |
+
defined( 'ABSPATH' ) or exit;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Writepanel class
|
10 |
+
*/
|
11 |
+
if ( !class_exists( 'WooCommerce_PDF_Invoices_Writepanels' ) ) {
|
12 |
+
|
13 |
+
class WooCommerce_PDF_Invoices_Writepanels {
|
14 |
+
public $bulk_actions;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
$this->general_settings = get_option('wpo_wcpdf_general_settings');
|
21 |
+
$this->template_settings = get_option('wpo_wcpdf_template_settings');
|
22 |
+
|
23 |
+
add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) );
|
24 |
+
add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_invoice_number_column' ), 999 );
|
25 |
+
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'invoice_number_column_data' ), 2 );
|
26 |
+
add_action( 'add_meta_boxes_shop_order', array( $this, 'add_meta_boxes' ) );
|
27 |
+
add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'my_account_pdf_link' ), 10, 2 );
|
28 |
+
add_action( 'admin_print_scripts', array( $this, 'add_scripts' ) );
|
29 |
+
add_action( 'admin_print_styles', array( $this, 'add_styles' ) );
|
30 |
+
add_action( 'admin_footer', array( $this, 'bulk_actions' ) );
|
31 |
+
|
32 |
+
add_action( 'save_post', array( $this,'save_invoice_number_date' ) );
|
33 |
+
|
34 |
+
add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'search_fields' ) );
|
35 |
+
|
36 |
+
$this->bulk_actions = array(
|
37 |
+
'invoice' => __( 'PDF Invoices', 'wpo_wcpdf' ),
|
38 |
+
'packing-slip' => __( 'PDF Packing Slips', 'wpo_wcpdf' ),
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add the styles
|
44 |
+
*/
|
45 |
+
public function add_styles() {
|
46 |
+
if( $this->is_order_edit_page() ) {
|
47 |
+
wp_enqueue_style( 'thickbox' );
|
48 |
+
|
49 |
+
wp_enqueue_style(
|
50 |
+
'wpo-wcpdf',
|
51 |
+
WooCommerce_PDF_Invoices::$plugin_url . 'css/style.css',
|
52 |
+
array(),
|
53 |
+
WooCommerce_PDF_Invoices::$version
|
54 |
+
);
|
55 |
+
|
56 |
+
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
|
57 |
+
// WC 2.1 or newer (MP6) is used: bigger buttons
|
58 |
+
wp_enqueue_style(
|
59 |
+
'wpo-wcpdf-buttons',
|
60 |
+
WooCommerce_PDF_Invoices::$plugin_url . 'css/style-buttons.css',
|
61 |
+
array(),
|
62 |
+
WooCommerce_PDF_Invoices::$version
|
63 |
+
);
|
64 |
+
} else {
|
65 |
+
// legacy WC 2.0 styles
|
66 |
+
wp_enqueue_style(
|
67 |
+
'wpo-wcpdf-buttons',
|
68 |
+
WooCommerce_PDF_Invoices::$plugin_url . 'css/style-buttons-wc20.css',
|
69 |
+
array(),
|
70 |
+
WooCommerce_PDF_Invoices::$version
|
71 |
+
);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Add the scripts
|
78 |
+
*/
|
79 |
+
public function add_scripts() {
|
80 |
+
if( $this->is_order_edit_page() ) {
|
81 |
+
wp_enqueue_script(
|
82 |
+
'wpo-wcpdf',
|
83 |
+
WooCommerce_PDF_Invoices::$plugin_url . 'js/script.js',
|
84 |
+
array( 'jquery' ),
|
85 |
+
WooCommerce_PDF_Invoices::$version
|
86 |
+
);
|
87 |
+
wp_localize_script(
|
88 |
+
'wpo-wcpdf',
|
89 |
+
'wpo_wcpdf_ajax',
|
90 |
+
array(
|
91 |
+
// 'ajaxurl' => add_query_arg( 'action', 'generate_wpo_wcpdf', admin_url( 'admin-ajax.php' ) ), // URL to WordPress ajax handling page
|
92 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ), // URL to WordPress ajax handling page
|
93 |
+
'nonce' => wp_create_nonce('generate_wpo_wcpdf'),
|
94 |
+
'bulk_actions' => array_keys( apply_filters( 'wpo_wcpdf_bulk_actions', $this->bulk_actions ) ),
|
95 |
+
)
|
96 |
+
);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Is order page
|
102 |
+
*/
|
103 |
+
public function is_order_edit_page() {
|
104 |
+
global $post_type;
|
105 |
+
if( $post_type == 'shop_order' ) {
|
106 |
+
return true;
|
107 |
+
} else {
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Add PDF actions to the orders listing
|
114 |
+
*/
|
115 |
+
public function add_listing_actions( $order ) {
|
116 |
+
// do not show buttons for trashed orders
|
117 |
+
if ( WCX_Order::get_status( $order ) == 'trash' ) {
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
|
121 |
+
$listing_actions = array(
|
122 |
+
'invoice' => array (
|
123 |
+
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . WCX_Order::get_id( $order ) ), 'generate_wpo_wcpdf' ),
|
124 |
+
'img' => WooCommerce_PDF_Invoices::$plugin_url . 'images/invoice.png',
|
125 |
+
'alt' => __( 'PDF Invoice', 'wpo_wcpdf' ),
|
126 |
+
),
|
127 |
+
'packing-slip' => array (
|
128 |
+
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=packing-slip&order_ids=' . WCX_Order::get_id( $order ) ), 'generate_wpo_wcpdf' ),
|
129 |
+
'img' => WooCommerce_PDF_Invoices::$plugin_url . 'images/packing-slip.png',
|
130 |
+
'alt' => __( 'PDF Packing Slip', 'wpo_wcpdf' ),
|
131 |
+
),
|
132 |
+
);
|
133 |
+
|
134 |
+
$listing_actions = apply_filters( 'wpo_wcpdf_listing_actions', $listing_actions, $order );
|
135 |
+
|
136 |
+
foreach ($listing_actions as $action => $data) {
|
137 |
+
?>
|
138 |
+
<a href="<?php echo $data['url']; ?>" class="button tips wpo_wcpdf <?php echo $action; ?>" target="_blank" alt="<?php echo $data['alt']; ?>" data-tip="<?php echo $data['alt']; ?>">
|
139 |
+
<img src="<?php echo $data['img']; ?>" alt="<?php echo $data['alt']; ?>" width="16">
|
140 |
+
</a>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Create additional Shop Order column for Invoice Numbers
|
147 |
+
* @param array $columns shop order columns
|
148 |
+
*/
|
149 |
+
public function add_invoice_number_column( $columns ) {
|
150 |
+
// Check user setting
|
151 |
+
if ( !isset($this->general_settings['invoice_number_column'] ) ) {
|
152 |
+
return $columns;
|
153 |
+
}
|
154 |
+
|
155 |
+
// put the column after the Status column
|
156 |
+
$new_columns = array_slice($columns, 0, 2, true) +
|
157 |
+
array( 'pdf_invoice_number' => __( 'Invoice Number', 'wpo_wcpdf' ) ) +
|
158 |
+
array_slice($columns, 2, count($columns) - 1, true) ;
|
159 |
+
return $new_columns;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Display Invoice Number in Shop Order column (if available)
|
164 |
+
* @param string $column column slug
|
165 |
+
*/
|
166 |
+
public function invoice_number_column_data( $column ) {
|
167 |
+
global $post, $the_order, $wpo_wcpdf;
|
168 |
+
|
169 |
+
if ( $column == 'pdf_invoice_number' ) {
|
170 |
+
if ( empty( $the_order ) || WCX_Order::get_id( $the_order ) != $post->ID ) {
|
171 |
+
$order = WCX::get_order( $post->ID );
|
172 |
+
echo $wpo_wcpdf->export->get_invoice_number( WCX_Order::get_id( $order ) );
|
173 |
+
do_action( 'wcpdf_invoice_number_column_end', $order );
|
174 |
+
} else {
|
175 |
+
echo $wpo_wcpdf->export->get_invoice_number( WCX_Order::get_id( $the_order ) );
|
176 |
+
do_action( 'wcpdf_invoice_number_column_end', $the_order );
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Display download link on My Account page
|
183 |
+
*/
|
184 |
+
public function my_account_pdf_link( $actions, $order ) {
|
185 |
+
$pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . WCX_Order::get_id( $order ) . '&my-account'), 'generate_wpo_wcpdf' );
|
186 |
+
|
187 |
+
// check my account button settings
|
188 |
+
if (isset($this->general_settings['my_account_buttons'])) {
|
189 |
+
switch ($this->general_settings['my_account_buttons']) {
|
190 |
+
case 'available':
|
191 |
+
$invoice_allowed = WCX_Order::get_meta( $order, '_wcpdf_invoice_exists', true );
|
192 |
+
break;
|
193 |
+
case 'always':
|
194 |
+
$invoice_allowed = true;
|
195 |
+
break;
|
196 |
+
case 'never':
|
197 |
+
$invoice_allowed = false;
|
198 |
+
break;
|
199 |
+
case 'custom':
|
200 |
+
if ( isset( $this->general_settings['my_account_restrict'] ) && in_array( WCX_Order::get_status( $order ), array_keys( $this->general_settings['my_account_restrict'] ) ) ) {
|
201 |
+
$invoice_allowed = true;
|
202 |
+
} else {
|
203 |
+
$invoice_allowed = false;
|
204 |
+
}
|
205 |
+
break;
|
206 |
+
}
|
207 |
+
} else {
|
208 |
+
// backwards compatibility
|
209 |
+
$invoice_allowed = WCX_Order::get_meta( $order, '_wcpdf_invoice_exists', true );
|
210 |
+
}
|
211 |
+
|
212 |
+
// Check if invoice has been created already or if status allows download (filter your own array of allowed statuses)
|
213 |
+
if ( $invoice_allowed || in_array(WCX_Order::get_status( $order ), apply_filters( 'wpo_wcpdf_myaccount_allowed_order_statuses', array() ) ) ) {
|
214 |
+
$actions['invoice'] = array(
|
215 |
+
'url' => $pdf_url,
|
216 |
+
'name' => apply_filters( 'wpo_wcpdf_myaccount_button_text', __( 'Download invoice (PDF)', 'wpo_wcpdf' ) )
|
217 |
+
);
|
218 |
+
}
|
219 |
+
|
220 |
+
return apply_filters( 'wpo_wcpdf_myaccount_actions', $actions, $order );
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Add the meta box on the single order page
|
225 |
+
*/
|
226 |
+
public function add_meta_boxes() {
|
227 |
+
// create PDF buttons
|
228 |
+
add_meta_box(
|
229 |
+
'wpo_wcpdf-box',
|
230 |
+
__( 'Create PDF', 'wpo_wcpdf' ),
|
231 |
+
array( $this, 'sidebar_box_content' ),
|
232 |
+
'shop_order',
|
233 |
+
'side',
|
234 |
+
'default'
|
235 |
+
);
|
236 |
+
|
237 |
+
// Invoice number & date
|
238 |
+
add_meta_box(
|
239 |
+
'wpo_wcpdf-data-input-box',
|
240 |
+
__( 'PDF Invoice data', 'wpo_wcpdf' ),
|
241 |
+
array( $this, 'data_input_box_content' ),
|
242 |
+
'shop_order',
|
243 |
+
'normal',
|
244 |
+
'default'
|
245 |
+
);
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Create the meta box content on the single order page
|
250 |
+
*/
|
251 |
+
public function sidebar_box_content( $post ) {
|
252 |
+
global $post_id;
|
253 |
+
|
254 |
+
$meta_actions = array(
|
255 |
+
'invoice' => array (
|
256 |
+
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $post_id ), 'generate_wpo_wcpdf' ),
|
257 |
+
'alt' => esc_attr__( 'PDF Invoice', 'wpo_wcpdf' ),
|
258 |
+
'title' => __( 'PDF Invoice', 'wpo_wcpdf' ),
|
259 |
+
),
|
260 |
+
'packing-slip' => array (
|
261 |
+
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=packing-slip&order_ids=' . $post_id ), 'generate_wpo_wcpdf' ),
|
262 |
+
'alt' => esc_attr__( 'PDF Packing Slip', 'wpo_wcpdf' ),
|
263 |
+
'title' => __( 'PDF Packing Slip', 'wpo_wcpdf' ),
|
264 |
+
),
|
265 |
+
);
|
266 |
+
|
267 |
+
$meta_actions = apply_filters( 'wpo_wcpdf_meta_box_actions', $meta_actions, $post_id );
|
268 |
+
|
269 |
+
?>
|
270 |
+
<ul class="wpo_wcpdf-actions">
|
271 |
+
<?php
|
272 |
+
foreach ($meta_actions as $action => $data) {
|
273 |
+
printf('<li><a href="%1$s" class="button" target="_blank" alt="%2$s">%3$s</a></li>', $data['url'], $data['alt'],$data['title']);
|
274 |
+
}
|
275 |
+
?>
|
276 |
+
</ul>
|
277 |
+
<?php
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Add metabox for invoice number & date
|
282 |
+
*/
|
283 |
+
public function data_input_box_content ( $post ) {
|
284 |
+
$order = WCX::get_order( $post->ID );
|
285 |
+
$invoice_exists = WCX_Order::get_meta( $order, '_wcpdf_invoice_exists', true );
|
286 |
+
$invoice_number = WCX_Order::get_meta( $order, '_wcpdf_invoice_number', true );
|
287 |
+
$invoice_date = WCX_Order::get_meta( $order, '_wcpdf_invoice_date', true );
|
288 |
+
|
289 |
+
do_action( 'wpo_wcpdf_meta_box_start', $post->ID );
|
290 |
+
|
291 |
+
?>
|
292 |
+
<h4><?php _e( 'Invoice', 'wpo_wcpdf' ) ?></h4>
|
293 |
+
<p class="form-field _wcpdf_invoice_number_field ">
|
294 |
+
<label for="_wcpdf_invoice_number"><?php _e( 'Invoice Number (unformatted!)', 'wpo_wcpdf' ); ?>:</label>
|
295 |
+
<?php if (!empty($invoice_exists)) : ?>
|
296 |
+
<input type="text" class="short" style="" name="_wcpdf_invoice_number" id="_wcpdf_invoice_number" value="<?php echo $invoice_number ?>">
|
297 |
+
<?php else : ?>
|
298 |
+
<input type="text" class="short" style="" name="_wcpdf_invoice_number" id="_wcpdf_invoice_number" value="<?php echo $invoice_number ?>" disabled="disabled" >
|
299 |
+
<?php endif; ?>
|
300 |
+
</p>
|
301 |
+
<p class="form-field form-field-wide">
|
302 |
+
<label for="wcpdf_invoice_date"><?php _e( 'Invoice Date:', 'wpo_wcpdf' ); ?></label>
|
303 |
+
<?php if (!empty($invoice_exists)) : ?>
|
304 |
+
<input type="text" class="date-picker-field" name="wcpdf_invoice_date" id="wcpdf_invoice_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $invoice_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="number" class="hour" placeholder="<?php _e( 'h', 'woocommerce' ) ?>" name="wcpdf_invoice_date_hour" id="wcpdf_invoice_date_hour" min="0" max="23" size="2" value="<?php echo date_i18n( 'H', strtotime( $invoice_date ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:<input type="number" class="minute" placeholder="<?php _e( 'm', 'woocommerce' ) ?>" name="wcpdf_invoice_date_minute" id="wcpdf_invoice_date_minute" min="0" max="59" size="2" value="<?php echo date_i18n( 'i', strtotime( $invoice_date ) ); ?>" pattern="[0-5]{1}[0-9]{1}" />
|
305 |
+
<?php else : ?>
|
306 |
+
<input type="text" class="date-picker-field" name="wcpdf_invoice_date" id="wcpdf_invoice_date" maxlength="10" disabled="disabled" value="" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="number" class="hour" disabled="disabled" placeholder="<?php _e( 'h', 'woocommerce' ) ?>" name="wcpdf_invoice_date_hour" id="wcpdf_invoice_date_hour" min="0" max="23" size="2" value="" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:<input type="number" class="minute" placeholder="<?php _e( 'm', 'woocommerce' ) ?>" name="wcpdf_invoice_date_minute" id="wcpdf_invoice_date_minute" min="0" max="59" size="2" value="" pattern="[0-5]{1}[0-9]{1}" disabled="disabled" />
|
307 |
+
<?php endif; ?>
|
308 |
+
</p>
|
309 |
+
<?php
|
310 |
+
|
311 |
+
do_action( 'wpo_wcpdf_meta_box_end', $post->ID );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Add actions to menu
|
316 |
+
*/
|
317 |
+
public function bulk_actions() {
|
318 |
+
global $post_type;
|
319 |
+
$bulk_actions = apply_filters( 'wpo_wcpdf_bulk_actions', $this->bulk_actions );
|
320 |
+
|
321 |
+
if ( 'shop_order' == $post_type ) {
|
322 |
+
?>
|
323 |
+
<script type="text/javascript">
|
324 |
+
jQuery(document).ready(function() {
|
325 |
+
<?php foreach ($bulk_actions as $action => $title) { ?>
|
326 |
+
jQuery('<option>').val('<?php echo $action; ?>').html('<?php echo esc_attr( $title ); ?>').appendTo("select[name='action'], select[name='action2']");
|
327 |
+
<?php } ?>
|
328 |
+
});
|
329 |
+
</script>
|
330 |
+
<?php
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Save invoice number
|
336 |
+
*/
|
337 |
+
public function save_invoice_number_date($post_id) {
|
338 |
+
global $wpo_wcpdf;
|
339 |
+
$post_type = get_post_type( $post_id );
|
340 |
+
if( $post_type == 'shop_order' ) {
|
341 |
+
// bail if this is not an actual 'Save order' action
|
342 |
+
if (!isset($_POST['action']) || $_POST['action'] != 'editpost') {
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
|
346 |
+
$order = WCX::get_order( $post_id );
|
347 |
+
if ( isset($_POST['_wcpdf_invoice_number']) ) {
|
348 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_number', stripslashes( $_POST['_wcpdf_invoice_number'] ) );
|
349 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_formatted_invoice_number', $wpo_wcpdf->export->get_invoice_number( $post_id ) );
|
350 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_exists', 1 );
|
351 |
+
}
|
352 |
+
|
353 |
+
if ( isset($_POST['wcpdf_invoice_date']) ) {
|
354 |
+
if ( empty($_POST['wcpdf_invoice_date']) ) {
|
355 |
+
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_date' );
|
356 |
+
} else {
|
357 |
+
$invoice_date = strtotime( $_POST['wcpdf_invoice_date'] . ' ' . (int) $_POST['wcpdf_invoice_date_hour'] . ':' . (int) $_POST['wcpdf_invoice_date_minute'] . ':00' );
|
358 |
+
$invoice_date = date_i18n( 'Y-m-d H:i:s', $invoice_date );
|
359 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_date', $invoice_date );
|
360 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_exists', 1 );
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
if (empty($_POST['wcpdf_invoice_date']) && isset($_POST['_wcpdf_invoice_number'])) {
|
365 |
+
$invoice_date = date_i18n( 'Y-m-d H:i:s', time() );
|
366 |
+
WCX_Order::update_meta_data( $order, '_wcpdf_invoice_date', $invoice_date );
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( empty($_POST['wcpdf_invoice_date']) && empty($_POST['_wcpdf_invoice_number'])) {
|
370 |
+
WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Add invoice number to order search scope
|
377 |
+
*/
|
378 |
+
public function search_fields ( $custom_fields ) {
|
379 |
+
$custom_fields[] = '_wcpdf_invoice_number';
|
380 |
+
$custom_fields[] = '_wcpdf_formatted_invoice_number';
|
381 |
+
return $custom_fields;
|
382 |
+
}
|
383 |
+
}
|
384 |
}
|
includes/compatibility/class-wc-product-compatibility.php
CHANGED
@@ -38,7 +38,7 @@ class Product extends Data {
|
|
38 |
*/
|
39 |
public static function get_id( \WC_Product $product ) {
|
40 |
|
41 |
-
if (
|
42 |
|
43 |
return $product->get_id();
|
44 |
|
38 |
*/
|
39 |
public static function get_id( \WC_Product $product ) {
|
40 |
|
41 |
+
if ( method_exists( $product, 'get_id' ) ) {
|
42 |
|
43 |
return $product->get_id();
|
44 |
|
languages/wpo_wcpdf-id_ID.mo
ADDED
Binary file
|
languages/wpo_wcpdf-id_ID.po
ADDED
@@ -0,0 +1,575 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: WooCommerce PDF Invoices & Packing Slips\n"
|
4 |
+
"POT-Creation-Date: 2015-04-29 08:59+0100\n"
|
5 |
+
"PO-Revision-Date: 2017-05-05 11:21+0200\n"
|
6 |
+
"Last-Translator: Jordan Silaen <jordan.silaen@chameleonjohn.com>\n"
|
7 |
+
"Language-Team: ChameleonJohn.com <jordan.silaen@chameleonjohn.com>\n"
|
8 |
+
"Language: id_ID\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.8.12\n"
|
13 |
+
"X-Poedit-Basepath: ..\n"
|
14 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
15 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
+
"X-Poedit-KeywordsList: __;_e;_x;_n:1,2\n"
|
17 |
+
"X-Poedit-SearchPath-0: .\n"
|
18 |
+
|
19 |
+
#: includes/class-wcpdf-export.php:338 includes/class-wcpdf-export.php:348 includes/class-wcpdf-export.php:359 includes/class-wcpdf-export.php:367
|
20 |
+
msgid "You do not have sufficient permissions to access this page."
|
21 |
+
msgstr "Anda tidak memiliki izin yang memadai untuk mengakses halaman ini."
|
22 |
+
|
23 |
+
#: includes/class-wcpdf-export.php:343
|
24 |
+
msgid "Some of the export parameters are missing."
|
25 |
+
msgstr "Beberapa parameter ekspor hilang."
|
26 |
+
|
27 |
+
# This is a filename (prefix). do not use spaces or special characters!
|
28 |
+
#: includes/class-wcpdf-export.php:424
|
29 |
+
msgid "invoice"
|
30 |
+
msgid_plural "invoices"
|
31 |
+
msgstr[0] "faktur"
|
32 |
+
msgstr[1] "faktur"
|
33 |
+
|
34 |
+
# This is a filename (prefix). do not use spaces or special characters!
|
35 |
+
#: includes/class-wcpdf-export.php:428
|
36 |
+
msgid "packing-slip"
|
37 |
+
msgid_plural "packing-slips"
|
38 |
+
msgstr[0] "Packing-slip"
|
39 |
+
msgstr[1] "Packing-slip"
|
40 |
+
|
41 |
+
#: includes/class-wcpdf-settings.php:38 includes/class-wcpdf-settings.php:39 includes/class-wcpdf-writepanels.php:32
|
42 |
+
msgid "PDF Invoices"
|
43 |
+
msgstr "Faktur PDF"
|
44 |
+
|
45 |
+
#: includes/class-wcpdf-settings.php:80
|
46 |
+
msgid "Settings"
|
47 |
+
msgstr "Pengaturan"
|
48 |
+
|
49 |
+
#: includes/class-wcpdf-settings.php:102
|
50 |
+
msgid "General"
|
51 |
+
msgstr "Umum"
|
52 |
+
|
53 |
+
#: includes/class-wcpdf-settings.php:103
|
54 |
+
msgid "Template"
|
55 |
+
msgstr "Template"
|
56 |
+
|
57 |
+
#: includes/class-wcpdf-settings.php:108
|
58 |
+
msgid "Status"
|
59 |
+
msgstr "Status"
|
60 |
+
|
61 |
+
#: includes/class-wcpdf-settings.php:120
|
62 |
+
msgid "WooCommerce PDF Invoices"
|
63 |
+
msgstr "WooCommerce PDF Faktur"
|
64 |
+
|
65 |
+
#: includes/class-wcpdf-settings.php:189
|
66 |
+
msgid "General settings"
|
67 |
+
msgstr "Pengaturan Umum"
|
68 |
+
|
69 |
+
#: includes/class-wcpdf-settings.php:196
|
70 |
+
msgid "How do you want to view the PDF?"
|
71 |
+
msgstr "Bagaimana Anda ingin melihat PDF?"
|
72 |
+
|
73 |
+
#: includes/class-wcpdf-settings.php:204
|
74 |
+
msgid "Download the PDF"
|
75 |
+
msgstr "Download PDF"
|
76 |
+
|
77 |
+
#: includes/class-wcpdf-settings.php:205
|
78 |
+
msgid "Open the PDF in a new browser tab/window"
|
79 |
+
msgstr "Buka PDF di tab / jendela browser baru"
|
80 |
+
|
81 |
+
#: includes/class-wcpdf-settings.php:214
|
82 |
+
msgid "Admin New Order email"
|
83 |
+
msgstr "Email Admin Orde Baru"
|
84 |
+
|
85 |
+
#: includes/class-wcpdf-settings.php:215
|
86 |
+
msgid "Customer Processing Order email"
|
87 |
+
msgstr "Email pesanan pemrosesan pelanggan"
|
88 |
+
|
89 |
+
#: includes/class-wcpdf-settings.php:216
|
90 |
+
msgid "Customer Completed Order email"
|
91 |
+
msgstr "Pelanggan Selesai email Orde"
|
92 |
+
|
93 |
+
#: includes/class-wcpdf-settings.php:217
|
94 |
+
msgid "Customer Invoice email"
|
95 |
+
msgstr "Email faktur pelanggan"
|
96 |
+
|
97 |
+
#: includes/class-wcpdf-settings.php:222
|
98 |
+
msgid "Attach invoice to:"
|
99 |
+
msgstr "Lampirkan faktur ke:"
|
100 |
+
|
101 |
+
#: includes/class-wcpdf-settings.php:230
|
102 |
+
#, php-format
|
103 |
+
msgid "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."
|
104 |
+
msgstr "Sepertinya map temp (<code> %s </ code>) tidak dapat ditulis, periksa izin untuk folder ini! Tanpa memiliki akses tulis ke folder ini, plugin tidak akan bisa mengirim faktur melalui email."
|
105 |
+
|
106 |
+
#: includes/class-wcpdf-settings.php:236
|
107 |
+
msgid "Disable for free products"
|
108 |
+
msgstr "Nonaktifkan untuk produk gratis"
|
109 |
+
|
110 |
+
#: includes/class-wcpdf-settings.php:243
|
111 |
+
msgid "Disable automatic creation/attachment of invoices when only free products are ordered"
|
112 |
+
msgstr "Nonaktifkan pembuatan otomatis / lampiran faktur bila hanya produk gratis yang dipesan"
|
113 |
+
|
114 |
+
#: includes/class-wcpdf-settings.php:250
|
115 |
+
msgid "Interface"
|
116 |
+
msgstr "Interface"
|
117 |
+
|
118 |
+
#: includes/class-wcpdf-settings.php:298
|
119 |
+
msgid "Allow My Account invoice download"
|
120 |
+
msgstr "Izinkan mendownload faktur Akun Saya"
|
121 |
+
|
122 |
+
#: includes/class-wcpdf-settings.php:306
|
123 |
+
msgid "Only when an invoice is already created/emailed"
|
124 |
+
msgstr "Hanya saat faktur sudah dibuat / diemailkan"
|
125 |
+
|
126 |
+
#: includes/class-wcpdf-settings.php:307
|
127 |
+
msgid "Only for specific order statuses (define below)"
|
128 |
+
msgstr "Hanya untuk status pesanan tertentu (tentukan di bawah)"
|
129 |
+
|
130 |
+
#: includes/class-wcpdf-settings.php:308
|
131 |
+
msgid "Always"
|
132 |
+
msgstr "Selalu"
|
133 |
+
|
134 |
+
#: includes/class-wcpdf-settings.php:323
|
135 |
+
msgid "Enable invoice number column in the orders list"
|
136 |
+
msgstr "Aktifkan kolom nomor faktur dalam daftar pesanan"
|
137 |
+
|
138 |
+
#: includes/class-wcpdf-settings.php:361
|
139 |
+
msgid "PDF Template settings"
|
140 |
+
msgstr "Pengaturan template PDF"
|
141 |
+
|
142 |
+
#: includes/class-wcpdf-settings.php:373
|
143 |
+
msgid "Choose a template"
|
144 |
+
msgstr "Pilih template"
|
145 |
+
|
146 |
+
#: includes/class-wcpdf-settings.php:381
|
147 |
+
#, php-format
|
148 |
+
msgid "Want to use your own template? Copy all the files from <code>%s</code> to your (child) theme in <code>%s</code> to customize them"
|
149 |
+
msgstr "Ingin menggunakan template anda sendiri? Salin semua file dari <code> %s </ code> ke tema (anak) Anda di <code> %s </ code> untuk menyesuaikannya"
|
150 |
+
|
151 |
+
#: includes/class-wcpdf-settings.php:387
|
152 |
+
msgid "Paper size"
|
153 |
+
msgstr "Ukuran kertas"
|
154 |
+
|
155 |
+
#: includes/class-wcpdf-settings.php:395
|
156 |
+
msgid "A4"
|
157 |
+
msgstr "A4"
|
158 |
+
|
159 |
+
#: includes/class-wcpdf-settings.php:396
|
160 |
+
msgid "Letter"
|
161 |
+
msgstr "Surat"
|
162 |
+
|
163 |
+
#: includes/class-wcpdf-settings.php:403
|
164 |
+
msgid "Shop header/logo"
|
165 |
+
msgstr "Shop header / logo"
|
166 |
+
|
167 |
+
#: includes/class-wcpdf-settings.php:410
|
168 |
+
msgid "Select or upload your invoice header/logo"
|
169 |
+
msgstr "Pilih atau upload header / logo faktur Anda"
|
170 |
+
|
171 |
+
#: includes/class-wcpdf-settings.php:411
|
172 |
+
msgid "Set image"
|
173 |
+
msgstr "Set gambar"
|
174 |
+
|
175 |
+
#: includes/class-wcpdf-settings.php:412
|
176 |
+
msgid "Remove image"
|
177 |
+
msgstr "Hapus gambar"
|
178 |
+
|
179 |
+
#: includes/class-wcpdf-settings.php:419
|
180 |
+
msgid "Shop Name"
|
181 |
+
msgstr "Nama toko"
|
182 |
+
|
183 |
+
#: includes/class-wcpdf-settings.php:432
|
184 |
+
msgid "Shop Address"
|
185 |
+
msgstr "Alamat toko"
|
186 |
+
|
187 |
+
#: includes/class-wcpdf-settings.php:447
|
188 |
+
msgid "Footer: terms & conditions, policies, etc."
|
189 |
+
msgstr "Footer: syarat & ketentuan, kebijakan, dll."
|
190 |
+
|
191 |
+
#: includes/class-wcpdf-settings.php:463 templates/pdf/Simple/invoice.php:9 templates/pdf/Simple/invoice.php:21 woocommerce-pdf-invoices-packingslips.php:220
|
192 |
+
msgid "Invoice"
|
193 |
+
msgstr "Faktur"
|
194 |
+
|
195 |
+
#: includes/class-wcpdf-settings.php:470
|
196 |
+
msgid "Display shipping address"
|
197 |
+
msgstr "Tampilkan alamat pengiriman"
|
198 |
+
|
199 |
+
#: includes/class-wcpdf-settings.php:477
|
200 |
+
msgid "Display shipping address on invoice (in addition to the default billing address) if different from billing address"
|
201 |
+
msgstr "Tampilkan alamat pengiriman pada faktur (di samping alamat penagihan default) jika berbeda dengan alamat penagihan"
|
202 |
+
|
203 |
+
#: includes/class-wcpdf-settings.php:483 includes/class-wcpdf-settings.php:598
|
204 |
+
msgid "Display email address"
|
205 |
+
msgstr "Tampilkan alamat email"
|
206 |
+
|
207 |
+
#: includes/class-wcpdf-settings.php:495 includes/class-wcpdf-settings.php:610
|
208 |
+
msgid "Display phone number"
|
209 |
+
msgstr "nomor telepon tampilan"
|
210 |
+
|
211 |
+
#: includes/class-wcpdf-settings.php:507
|
212 |
+
msgid "Display invoice date"
|
213 |
+
msgstr "Tampilkan tanggal faktur"
|
214 |
+
|
215 |
+
#: includes/class-wcpdf-settings.php:520
|
216 |
+
msgid "Display built-in sequential invoice number"
|
217 |
+
msgstr "Menampilkan nomor faktur berurutan built-in"
|
218 |
+
|
219 |
+
#: includes/class-wcpdf-settings.php:533
|
220 |
+
msgid "Next invoice number (without prefix/suffix etc.)"
|
221 |
+
msgstr "Nomor faktur berikutnya (tanpa awalan / akhiran dll.)"
|
222 |
+
|
223 |
+
#: includes/class-wcpdf-settings.php:541
|
224 |
+
msgid "This is the number that will be used on the next invoice that is created. By default, numbering starts from the WooCommerce Order Number of the first invoice that is created and increases for every new invoice. Note that if you override this and set it lower than the highest (PDF) invoice number, this could create double invoice numbers!"
|
225 |
+
msgstr "Ini adalah nomor yang akan digunakan pada faktur berikutnya yang dibuat. Secara default, penomoran dimulai dari Nomor Pesanan WooCommerce dari faktur pertama yang dibuat dan meningkat untuk setiap faktur baru. Perhatikan bahwa jika Anda mengganti ini dan menetapkannya lebih rendah dari angka faktur tertinggi (PDF), ini bisa membuat nomor faktur ganda!"
|
226 |
+
|
227 |
+
#: includes/class-wcpdf-settings.php:547
|
228 |
+
msgid "Invoice number format"
|
229 |
+
msgstr "Format nomor faktur"
|
230 |
+
|
231 |
+
#: includes/class-wcpdf-settings.php:556
|
232 |
+
msgid "Prefix"
|
233 |
+
msgstr "Awalan"
|
234 |
+
|
235 |
+
#: includes/class-wcpdf-settings.php:558
|
236 |
+
msgid "to use the order year and/or month, use [order_year] or [order_month] respectively"
|
237 |
+
msgstr "Untuk menggunakan pesanan tahun dan / atau bulan, gunakan [order_year] atau [order_month] masing-masing"
|
238 |
+
|
239 |
+
#: includes/class-wcpdf-settings.php:561
|
240 |
+
msgid "Suffix"
|
241 |
+
msgstr "Akhiran"
|
242 |
+
|
243 |
+
#: includes/class-wcpdf-settings.php:566
|
244 |
+
msgid "Padding"
|
245 |
+
msgstr "Lapisan"
|
246 |
+
|
247 |
+
#: includes/class-wcpdf-settings.php:568
|
248 |
+
msgid "enter the number of digits here - enter \"6\" to display 42 as 000042"
|
249 |
+
msgstr "Masukkan jumlah digit di sini - masukkan \\ \"6 \" untuk menampilkan 42 sebagai 000042"
|
250 |
+
|
251 |
+
#: includes/class-wcpdf-settings.php:571
|
252 |
+
msgid "note: if you have already created a custom invoice number format with a filter, the above settings will be ignored"
|
253 |
+
msgstr "Catatan: jika Anda telah membuat format angka faktur khusus dengan filter, pengaturan di atas akan diabaikan"
|
254 |
+
|
255 |
+
#: includes/class-wcpdf-settings.php:578 templates/pdf/Simple/packing-slip.php:9 templates/pdf/Simple/packing-slip.php:21 woocommerce-pdf-invoices-packingslips.php:223
|
256 |
+
msgid "Packing Slip"
|
257 |
+
msgstr "Slip pengepakan"
|
258 |
+
|
259 |
+
#: includes/class-wcpdf-settings.php:585
|
260 |
+
msgid "Display billing address"
|
261 |
+
msgstr "Tampilkan alamat penagihan"
|
262 |
+
|
263 |
+
#: includes/class-wcpdf-settings.php:592
|
264 |
+
msgid "Display billing address on packing slip (in addition to the default shipping address) if different from shipping address"
|
265 |
+
msgstr "Tampilkan alamat penagihan pada slip pengepakan (selain alamat pengiriman default) jika berbeda dari alamat pengiriman"
|
266 |
+
|
267 |
+
#: includes/class-wcpdf-settings.php:623
|
268 |
+
msgid "Extra template fields"
|
269 |
+
msgstr "Zusätzliche Vorlagenfelder "
|
270 |
+
|
271 |
+
#: includes/class-wcpdf-settings.php:630
|
272 |
+
msgid "Extra field 1"
|
273 |
+
msgstr "Zusatzfeld 1 "
|
274 |
+
|
275 |
+
#: includes/class-wcpdf-settings.php:639
|
276 |
+
msgid "This is footer column 1 in the <i>Modern (Premium)</i> template"
|
277 |
+
msgstr "Ini adalah kolom footer 1 di template <i> Modern (Premium) </ i>"
|
278 |
+
|
279 |
+
#: includes/class-wcpdf-settings.php:645
|
280 |
+
msgid "Extra field 2"
|
281 |
+
msgstr "Bidang tambahan 2"
|
282 |
+
|
283 |
+
#: includes/class-wcpdf-settings.php:654
|
284 |
+
msgid "This is footer column 2 in the <i>Modern (Premium)</i> template"
|
285 |
+
msgstr "Ini adalah kolom footer 2 di template <i> Modern (Premium) </ i>"
|
286 |
+
|
287 |
+
#: includes/class-wcpdf-settings.php:660
|
288 |
+
msgid "Extra field 3"
|
289 |
+
msgstr "Bidang tambahan 3"
|
290 |
+
|
291 |
+
#: includes/class-wcpdf-settings.php:669
|
292 |
+
msgid "This is footer column 3 in the <i>Modern (Premium)</i> template"
|
293 |
+
msgstr "Ini adalah kolom footer 3 di template <i> Modern (Premium) </ i>"
|
294 |
+
|
295 |
+
#: includes/class-wcpdf-settings.php:711
|
296 |
+
msgid "Debug settings"
|
297 |
+
msgstr "Pengaturan Debug"
|
298 |
+
|
299 |
+
#: includes/class-wcpdf-settings.php:718
|
300 |
+
msgid "Enable debug output"
|
301 |
+
msgstr "Aktifkan keluaran debug"
|
302 |
+
|
303 |
+
#: includes/class-wcpdf-settings.php:725
|
304 |
+
msgid "Enable this option to output plugin errors if you're getting a blank page or other PDF generation issues"
|
305 |
+
msgstr "Aktifkan opsi ini untuk menampilkan kesalahan plugin jika Anda mendapatkan halaman kosong atau masalah generasi PDF lainnya"
|
306 |
+
|
307 |
+
#: includes/class-wcpdf-settings.php:731
|
308 |
+
msgid "Output to HTML"
|
309 |
+
msgstr "Keluaran ke HTML"
|
310 |
+
|
311 |
+
#: includes/class-wcpdf-settings.php:738
|
312 |
+
msgid "Send the template output as HTML to the browser instead of creating a PDF."
|
313 |
+
msgstr "Kirimkan output template sebagai HTML ke browser alih-alih membuat PDF."
|
314 |
+
|
315 |
+
#: includes/class-wcpdf-settings.php:744
|
316 |
+
msgid "Use old tmp folder"
|
317 |
+
msgstr "Gunakan folder tmp lama"
|
318 |
+
|
319 |
+
#: includes/class-wcpdf-settings.php:751
|
320 |
+
msgid "Before version 1.5 of PDF Invoices, temporary files were stored in the plugin folder. This setting is only intended for backwards compatibility, not recommended on new installs!"
|
321 |
+
msgstr "Sebelum versi 1.5 dari Faktur PDF, file-file sementara disimpan dalam folder plugin. Pengaturan ini hanya ditujukan untuk kompatibilitas mundur, tidak disarankan pada pemasangan baru!"
|
322 |
+
|
323 |
+
#: includes/class-wcpdf-settings.php:1091
|
324 |
+
msgid "Image resolution"
|
325 |
+
msgstr "Resolusi gambar"
|
326 |
+
|
327 |
+
#: includes/class-wcpdf-settings.php:1207
|
328 |
+
msgid "<b>Warning!</b> The settings below are meant for debugging/development only. Do not use them on a live website!"
|
329 |
+
msgstr "<B> Peringatan! </ B> Pengaturan di bawah dimaksudkan untuk debugging / pengembangan saja. Jangan gunakan mereka di situs web live!"
|
330 |
+
|
331 |
+
#: includes/class-wcpdf-settings.php:1216
|
332 |
+
msgid "These are used for the (optional) footer columns in the <em>Modern (Premium)</em> template, but can also be used for other elements in your custom template"
|
333 |
+
msgstr "Ini digunakan untuk kolom footer (opsional) di template <em> Modern (Premium) </ em>, namun juga dapat digunakan untuk elemen lain dalam template khusus Anda"
|
334 |
+
|
335 |
+
#: includes/class-wcpdf-writepanels.php:33
|
336 |
+
msgid "PDF Packing Slips"
|
337 |
+
msgstr "PDF Packing Slips"
|
338 |
+
|
339 |
+
#: includes/class-wcpdf-writepanels.php:107 includes/class-wcpdf-writepanels.php:216
|
340 |
+
msgid "PDF Invoice"
|
341 |
+
msgstr "Faktur PDF"
|
342 |
+
|
343 |
+
#: includes/class-wcpdf-writepanels.php:112 includes/class-wcpdf-writepanels.php:221
|
344 |
+
msgid "PDF Packing Slip"
|
345 |
+
msgstr "PDF Packing Slip"
|
346 |
+
|
347 |
+
#: includes/class-wcpdf-writepanels.php:139
|
348 |
+
msgid "Invoice Number"
|
349 |
+
msgstr "Nomor faktur"
|
350 |
+
|
351 |
+
#: includes/class-wcpdf-writepanels.php:192
|
352 |
+
msgid "Download invoice (PDF)"
|
353 |
+
msgstr "Download faktur (PDF)"
|
354 |
+
|
355 |
+
#: includes/class-wcpdf-writepanels.php:203
|
356 |
+
msgid "Create PDF"
|
357 |
+
msgstr "Buat PDF"
|
358 |
+
|
359 |
+
#: includes/class-wcpdf-writepanels.php:264
|
360 |
+
msgid "PDF Invoice Number (unformatted!)"
|
361 |
+
msgstr "Nomor Faktur PDF (belum diformat!)"
|
362 |
+
|
363 |
+
#: includes/class-wcpdf-writepanels.php:267 templates/pdf/Simple/invoice.php:55
|
364 |
+
msgid "Invoice Date:"
|
365 |
+
msgstr "Tanggal faktur:"
|
366 |
+
|
367 |
+
#: includes/class-wcpdf-writepanels.php:268
|
368 |
+
msgid "h"
|
369 |
+
msgstr "H"
|
370 |
+
|
371 |
+
#: includes/class-wcpdf-writepanels.php:268
|
372 |
+
msgid "m"
|
373 |
+
msgstr "M"
|
374 |
+
|
375 |
+
#: includes/wcpdf-extensions.php:15
|
376 |
+
msgid "Check out these premium extensions!"
|
377 |
+
msgstr "Lihat ekstensi premium ini!"
|
378 |
+
|
379 |
+
#: includes/wcpdf-extensions.php:16
|
380 |
+
msgid "click items to read more"
|
381 |
+
msgstr "Klik item untuk membaca lebih lanjut"
|
382 |
+
|
383 |
+
#: includes/wcpdf-extensions.php:23
|
384 |
+
msgid "Go Pro: Proforma invoices, credit notes (=refunds) & more!"
|
385 |
+
msgstr "Go Pro: Faktur proforma, catatan kredit (= pengembalian uang) & banyak lagi!"
|
386 |
+
|
387 |
+
#: includes/wcpdf-extensions.php:25
|
388 |
+
msgid "Supercharge WooCommerce PDF Invoices & Packing Slips with the following features:"
|
389 |
+
msgstr "Supercharge WooCommerce PDF Invoices & Packing Slips dengan beberapa fitur berikut:"
|
390 |
+
|
391 |
+
#: includes/wcpdf-extensions.php:27
|
392 |
+
msgid "Email/print/download <b>PDF Credit Notes & Proforma invoices</b>"
|
393 |
+
msgstr "Email / print / download <b> PDF Credit Notes & Proforma invoice </ b>"
|
394 |
+
|
395 |
+
#: includes/wcpdf-extensions.php:28
|
396 |
+
msgid "Send out a separate <b>notification email</b> with (or without) PDF invoices/packing slips, for example to a drop-shipper or a supplier."
|
397 |
+
msgstr "Kirimkan email pemberitahuan <b> terpisah </ b> dengan (atau tanpa) slip faktur / kemasan iPod, misalnya ke pengirim barang atau pemasok."
|
398 |
+
|
399 |
+
#: includes/wcpdf-extensions.php:29
|
400 |
+
msgid "Attach <b>up to 3 static files</b> (for example a terms & conditions document) to the WooCommerce emails of your choice."
|
401 |
+
msgstr "Lampirkan <b> hingga 3 file statis </ b> (misalnya dokumen persyaratan & ketentuan) ke email WooCommerce pilihan Anda."
|
402 |
+
|
403 |
+
#: includes/wcpdf-extensions.php:30
|
404 |
+
msgid "Use <b>separate numbering systems</b> and/or format for proforma invoices and credit notes or utilize the main invoice numbering system"
|
405 |
+
msgstr "Gunakan <b> sistem penomoran yang terpisah </ b> dan / atau format untuk proforma faktur dan nota kredit atau memanfaatkan sistem penomoran faktur utama"
|
406 |
+
|
407 |
+
#: includes/wcpdf-extensions.php:31
|
408 |
+
msgid "<b>Customize</b> the <b>shipping & billing address</b> format to include additional custom fields, font sizes etc. without the need to create a custom template."
|
409 |
+
msgstr "<B> Sesuaikan </ b> <b> alamat pengiriman & penagihan </ b> untuk menyertakan bidang khusus tambahan, ukuran font, dll. Tanpa perlu membuat template khusus."
|
410 |
+
|
411 |
+
#: includes/wcpdf-extensions.php:32
|
412 |
+
msgid "Use the plugin in multilingual <b>WPML</b> setups"
|
413 |
+
msgstr "Gunakan plugin dalam setup bahasa multi bahasa <b> WPML </ b>"
|
414 |
+
|
415 |
+
#: includes/wcpdf-extensions.php:34
|
416 |
+
msgid "Get WooCommerce PDF Invoices & Packing Slips Professional!"
|
417 |
+
msgstr "Dapatkan WooCommerce PDF Invoices & Packing Slips Professional!"
|
418 |
+
|
419 |
+
#: includes/wcpdf-extensions.php:42
|
420 |
+
msgid "Upload all invoices automatically to your dropbox"
|
421 |
+
msgstr "Upload semua faktur secara otomatis ke dropbox Anda"
|
422 |
+
|
423 |
+
#: includes/wcpdf-extensions.php:48
|
424 |
+
msgid "This extension conveniently uploads all the invoices (and other pdf documents from the professional extension) that are emailed to your customers to Dropbox. The best way to keep your invoice administration up to date!"
|
425 |
+
msgstr "Ekstensi ini dengan mudah mengunggah semua faktur (dan dokumen pdf lainnya dari ekstensi profesional) yang dikirim melalui email kepada pelanggan Anda ke Dropbox. Cara terbaik untuk menjaga agar administrasi faktur Anda tetap up to date!"
|
426 |
+
|
427 |
+
#: includes/wcpdf-extensions.php:49
|
428 |
+
msgid "Get WooCommerce PDF Invoices & Packing Slips to dropbox!"
|
429 |
+
msgstr "Dapatkan WooCommerce PDF Invoices & Packing Slips to dropbox!"
|
430 |
+
|
431 |
+
#: includes/wcpdf-extensions.php:61
|
432 |
+
msgid "Automatically send new orders or packing slips to your printer, as soon as the customer orders!"
|
433 |
+
msgstr "Secara otomatis mengirim pesanan baru atau mengepak slip ke printer Anda, segera setelah pesanan pelanggan!"
|
434 |
+
|
435 |
+
#: includes/wcpdf-extensions.php:67
|
436 |
+
msgid "Check out the WooCommerce Automatic Order Printing extension from our partners at Simba Hosting"
|
437 |
+
msgstr "Lihat ekstensi WooCommerce Automatic Order Printing dari mitra kami di Simba Hosting"
|
438 |
+
|
439 |
+
#: includes/wcpdf-extensions.php:68
|
440 |
+
msgid "WooCommerce Automatic Order Printing"
|
441 |
+
msgstr "WooCommerce Automatic Order Printing"
|
442 |
+
|
443 |
+
#: includes/wcpdf-extensions.php:82
|
444 |
+
msgid "More advanced templates"
|
445 |
+
msgstr "Template yang lebih maju"
|
446 |
+
|
447 |
+
#: includes/wcpdf-extensions.php:85
|
448 |
+
msgid "Stylish modern invoices & packing slips with product thumbnails!"
|
449 |
+
msgstr "Bingkisan modern yang trendi & slip kemasan dengan thumbnail produk!"
|
450 |
+
|
451 |
+
#: includes/wcpdf-extensions.php:86
|
452 |
+
msgid "More tax details on the invoices!"
|
453 |
+
msgstr "Detail pajak lebih banyak pada faktur!"
|
454 |
+
|
455 |
+
#: includes/wcpdf-extensions.php:87
|
456 |
+
#, php-format
|
457 |
+
msgid "Check out the Premium PDF Invoice & Packing Slips templates at %s."
|
458 |
+
msgstr "Lihat template Premium Invoice & Packing Slips Premium di %s ."
|
459 |
+
|
460 |
+
#: includes/wcpdf-extensions.php:88
|
461 |
+
#, php-format
|
462 |
+
msgid "For custom templates, contact us at %s."
|
463 |
+
msgstr "Untuk template khusus, hubungi kami di %s ."
|
464 |
+
|
465 |
+
#: templates/pdf/Simple/invoice.php:29 templates/pdf/Simple/packing-slip.php:40
|
466 |
+
msgid "Billing Address:"
|
467 |
+
msgstr "Alamat tagihan:"
|
468 |
+
|
469 |
+
#: templates/pdf/Simple/invoice.php:40
|
470 |
+
msgid "Ship To:"
|
471 |
+
msgstr "Dikirim ke:"
|
472 |
+
|
473 |
+
#: templates/pdf/Simple/invoice.php:49
|
474 |
+
msgid "Invoice Number:"
|
475 |
+
msgstr "Nomor faktur:"
|
476 |
+
|
477 |
+
#: templates/pdf/Simple/invoice.php:60 templates/pdf/Simple/packing-slip.php:48
|
478 |
+
msgid "Order Number:"
|
479 |
+
msgstr "Jumlah order:"
|
480 |
+
|
481 |
+
#: templates/pdf/Simple/invoice.php:64 templates/pdf/Simple/packing-slip.php:52
|
482 |
+
msgid "Order Date:"
|
483 |
+
msgstr "Tanggal pemesanan:"
|
484 |
+
|
485 |
+
#: templates/pdf/Simple/invoice.php:68
|
486 |
+
msgid "Payment Method:"
|
487 |
+
msgstr "Metode pembayaran:"
|
488 |
+
|
489 |
+
#: templates/pdf/Simple/invoice.php:82 templates/pdf/Simple/packing-slip.php:70
|
490 |
+
msgid "Product"
|
491 |
+
msgstr "Produk"
|
492 |
+
|
493 |
+
#: templates/pdf/Simple/invoice.php:83 templates/pdf/Simple/packing-slip.php:71
|
494 |
+
msgid "Quantity"
|
495 |
+
msgstr "Kuantitas"
|
496 |
+
|
497 |
+
#: templates/pdf/Simple/invoice.php:84
|
498 |
+
msgid "Price"
|
499 |
+
msgstr "Harga"
|
500 |
+
|
501 |
+
#: templates/pdf/Simple/invoice.php:91 templates/pdf/Simple/packing-slip.php:78
|
502 |
+
msgid "Description"
|
503 |
+
msgstr "Deskripsi"
|
504 |
+
|
505 |
+
#: templates/pdf/Simple/invoice.php:96 templates/pdf/Simple/packing-slip.php:83
|
506 |
+
msgid "SKU"
|
507 |
+
msgstr "SKU"
|
508 |
+
|
509 |
+
#: templates/pdf/Simple/invoice.php:97 templates/pdf/Simple/packing-slip.php:84
|
510 |
+
msgid "SKU:"
|
511 |
+
msgstr "SKU:"
|
512 |
+
|
513 |
+
#: templates/pdf/Simple/invoice.php:98 templates/pdf/Simple/packing-slip.php:85
|
514 |
+
msgid "Weight:"
|
515 |
+
msgstr "Berat:"
|
516 |
+
|
517 |
+
#: templates/pdf/Simple/invoice.php:112 templates/pdf/Simple/packing-slip.php:99
|
518 |
+
msgid "Customer Notes"
|
519 |
+
msgstr "Catatan Pelanggan"
|
520 |
+
|
521 |
+
#: templates/pdf/Simple/packing-slip.php:29
|
522 |
+
msgid "Shipping Address:"
|
523 |
+
msgstr "Alamat Pengiriman:"
|
524 |
+
|
525 |
+
#: templates/pdf/Simple/packing-slip.php:56
|
526 |
+
msgid "Shipping Method:"
|
527 |
+
msgstr "Metode pengiriman:"
|
528 |
+
|
529 |
+
#: woocommerce-pdf-invoices-packingslips.php:123
|
530 |
+
#, php-format
|
531 |
+
msgid "WooCommerce PDF Invoices & Packing Slips requires %sWooCommerce%s to be installed & activated!"
|
532 |
+
msgstr "WooCommerce PDF Invoices & Packing Slips membutuhkan %s WooCommerce %s untuk diinstal & diaktifkan!"
|
533 |
+
|
534 |
+
#: woocommerce-pdf-invoices-packingslips.php:330 woocommerce-pdf-invoices-packingslips.php:391
|
535 |
+
msgid "N/A"
|
536 |
+
msgstr "N / A"
|
537 |
+
|
538 |
+
#: woocommerce-pdf-invoices-packingslips.php:480
|
539 |
+
msgid "Payment method"
|
540 |
+
msgstr "Metode pembayaran"
|
541 |
+
|
542 |
+
#: woocommerce-pdf-invoices-packingslips.php:491
|
543 |
+
msgid "Shipping method"
|
544 |
+
msgstr "Metode pengiriman"
|
545 |
+
|
546 |
+
#: woocommerce-pdf-invoices-packingslips.php:644
|
547 |
+
msgid "Subtotal"
|
548 |
+
msgstr "Subtotal"
|
549 |
+
|
550 |
+
#: woocommerce-pdf-invoices-packingslips.php:666
|
551 |
+
msgid "Shipping"
|
552 |
+
msgstr "pengiriman"
|
553 |
+
|
554 |
+
#: woocommerce-pdf-invoices-packingslips.php:719
|
555 |
+
msgid "Discount"
|
556 |
+
msgstr "Diskon"
|
557 |
+
|
558 |
+
#: woocommerce-pdf-invoices-packingslips.php:759
|
559 |
+
msgid "VAT"
|
560 |
+
msgstr "TONG"
|
561 |
+
|
562 |
+
#: woocommerce-pdf-invoices-packingslips.php:760
|
563 |
+
msgid "Tax rate"
|
564 |
+
msgstr "Persentase pajak"
|
565 |
+
|
566 |
+
#: woocommerce-pdf-invoices-packingslips.php:797
|
567 |
+
msgid "Total ex. VAT"
|
568 |
+
msgstr "Total mantan TONG"
|
569 |
+
|
570 |
+
#: woocommerce-pdf-invoices-packingslips.php:800
|
571 |
+
msgid "Total"
|
572 |
+
msgstr "Total"
|
573 |
+
|
574 |
+
#~ msgid "Attach a <b>static file</b> (for example a terms & conditions document) to the WooCommerce emails of your choice."
|
575 |
+
#~ msgstr "Hinzufügen einer beliebigen <b>Datei </b> (beispielweise AGB, Widerrufsbelehrung) zum WooCommerce E-Mail"
|
lib/dompdf/lib/fonts/currencies.ttf
ADDED
Binary file
|
lib/dompdf/lib/fonts/currencies.ufm
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
StartFontMetrics 4.1
|
2 |
+
Notice Converted by PHP-font-lib
|
3 |
+
Comment https://github.com/PhenX/php-font-lib
|
4 |
+
EncodingScheme FontSpecific
|
5 |
+
Copyright Typeface © James Kass 1998-2008. Data © James Kass 1998-2008. All Rights Reserved.
|
6 |
+
FontName Currencies
|
7 |
+
FontSubfamily Normal
|
8 |
+
UniqueID FontForge 2.0 : Currencies : 22-5-2017
|
9 |
+
FullName Currencies
|
10 |
+
Version Version 1.171
|
11 |
+
PostScriptName Currencies
|
12 |
+
Trademark Notice: Code2000 is shareware, users are required to register. US$5.00 (James Kass, 2807 Erskine Creek Road Space 93,Lake Isabella, California 93240 U.S.A.)[e-mail: jameskass@code2000.net]<Web site: http://www.code2000.net/index.htm>
|
13 |
+
Manufacturer James Kass
|
14 |
+
Designer James Kass
|
15 |
+
FontVendorURL http://www.code2000.net/index.htm
|
16 |
+
FontDesignerURL http://www.code2000.net/index.htm
|
17 |
+
LicenseURL http://www.code2000.net/code2000_page.htm
|
18 |
+
SampleText Hễ cố là phải được.
|
19 |
+
Weight Bold
|
20 |
+
ItalicAngle 0
|
21 |
+
IsFixedPitch false
|
22 |
+
UnderlineThickness 50
|
23 |
+
UnderlinePosition -299
|
24 |
+
FontHeightOffset 0
|
25 |
+
Ascender 977
|
26 |
+
Descender -293
|
27 |
+
FontBBox -78 -293 1047 977
|
28 |
+
StartCharMetrics 105
|
29 |
+
U 32 ; WX 391 ; N space ; G 3
|
30 |
+
U 36 ; WX 514 ; N uni0024 ; G 4
|
31 |
+
U 65 ; WX 633 ; N A ; G 5
|
32 |
+
U 66 ; WX 648 ; N B ; G 6
|
33 |
+
U 67 ; WX 631 ; N C ; G 7
|
34 |
+
U 68 ; WX 729 ; N D ; G 8
|
35 |
+
U 69 ; WX 556 ; N E ; G 9
|
36 |
+
U 70 ; WX 516 ; N F ; G 10
|
37 |
+
U 71 ; WX 728 ; N G ; G 11
|
38 |
+
U 72 ; WX 738 ; N H ; G 12
|
39 |
+
U 73 ; WX 279 ; N I ; G 13
|
40 |
+
U 74 ; WX 267 ; N J ; G 14
|
41 |
+
U 75 ; WX 614 ; N K ; G 15
|
42 |
+
U 76 ; WX 519 ; N L ; G 16
|
43 |
+
U 77 ; WX 903 ; N M ; G 17
|
44 |
+
U 78 ; WX 754 ; N N ; G 18
|
45 |
+
U 79 ; WX 779 ; N O ; G 19
|
46 |
+
U 80 ; WX 602 ; N P ; G 20
|
47 |
+
U 81 ; WX 779 ; N Q ; G 21
|
48 |
+
U 82 ; WX 618 ; N R ; G 22
|
49 |
+
U 83 ; WX 549 ; N S ; G 23
|
50 |
+
U 84 ; WX 553 ; N T ; G 24
|
51 |
+
U 85 ; WX 728 ; N U ; G 25
|
52 |
+
U 86 ; WX 595 ; N V ; G 26
|
53 |
+
U 87 ; WX 926 ; N W ; G 27
|
54 |
+
U 88 ; WX 577 ; N X ; G 28
|
55 |
+
U 89 ; WX 560 ; N Y ; G 29
|
56 |
+
U 90 ; WX 571 ; N Z ; G 30
|
57 |
+
U 97 ; WX 556 ; N a ; G 31
|
58 |
+
U 98 ; WX 613 ; N b ; G 32
|
59 |
+
U 99 ; WX 476 ; N c ; G 33
|
60 |
+
U 100 ; WX 613 ; N d ; G 34
|
61 |
+
U 101 ; WX 561 ; N e ; G 35
|
62 |
+
U 102 ; WX 339 ; N f ; G 36
|
63 |
+
U 103 ; WX 548 ; N g ; G 37
|
64 |
+
U 104 ; WX 614 ; N h ; G 38
|
65 |
+
U 105 ; WX 253 ; N i ; G 39
|
66 |
+
U 106 ; WX 253 ; N j ; G 40
|
67 |
+
U 107 ; WX 525 ; N k ; G 41
|
68 |
+
U 108 ; WX 253 ; N l ; G 42
|
69 |
+
U 109 ; WX 930 ; N m ; G 43
|
70 |
+
U 110 ; WX 614 ; N n ; G 44
|
71 |
+
U 111 ; WX 604 ; N o ; G 45
|
72 |
+
U 112 ; WX 613 ; N p ; G 46
|
73 |
+
U 113 ; WX 613 ; N q ; G 47
|
74 |
+
U 114 ; WX 408 ; N r ; G 48
|
75 |
+
U 115 ; WX 477 ; N s ; G 49
|
76 |
+
U 116 ; WX 353 ; N t ; G 50
|
77 |
+
U 117 ; WX 614 ; N u ; G 51
|
78 |
+
U 118 ; WX 501 ; N v ; G 52
|
79 |
+
U 119 ; WX 778 ; N w ; G 53
|
80 |
+
U 120 ; WX 524 ; N x ; G 54
|
81 |
+
U 121 ; WX 504 ; N y ; G 55
|
82 |
+
U 122 ; WX 468 ; N z ; G 56
|
83 |
+
U 160 ; WX 391 ; N uni00A0 ; G 57
|
84 |
+
U 162 ; WX 475 ; N uni00A2 ; G 58
|
85 |
+
U 163 ; WX 693 ; N uni00A3 ; G 59
|
86 |
+
U 164 ; WX 703 ; N uni00A4 ; G 60
|
87 |
+
U 165 ; WX 604 ; N uni00A5 ; G 61
|
88 |
+
U 402 ; WX 563 ; N uni0192 ; G 62
|
89 |
+
U 2546 ; WX 537 ; N uni09F2 ; G 63
|
90 |
+
U 2547 ; WX 611 ; N uni09F3 ; G 64
|
91 |
+
U 2801 ; WX 779 ; N uni0AF1 ; G 65
|
92 |
+
U 3065 ; WX 1047 ; N uni0BF9 ; G 66
|
93 |
+
U 3647 ; WX 703 ; N uni0E3F ; G 67
|
94 |
+
U 4314 ; WX 1064 ; N uni10DA ; G 68
|
95 |
+
U 6107 ; WX 377 ; N uni17DB ; G 69
|
96 |
+
U 8199 ; WX 391 ; N uni2007 ; G 70
|
97 |
+
U 8239 ; WX 391 ; N uni202F ; G 71
|
98 |
+
U 8288 ; WX 391 ; N uni2060 ; G 72
|
99 |
+
U 8352 ; WX 703 ; N uni20A0 ; G 73
|
100 |
+
U 8353 ; WX 650 ; N uni20A1 ; G 74
|
101 |
+
U 8354 ; WX 670 ; N uni20A2 ; G 75
|
102 |
+
U 8355 ; WX 586 ; N uni20A3 ; G 76
|
103 |
+
U 8356 ; WX 693 ; N uni20A4 ; G 77
|
104 |
+
U 8357 ; WX 967 ; N uni20A5 ; G 78
|
105 |
+
U 8358 ; WX 895 ; N uni20A6 ; G 79
|
106 |
+
U 8359 ; WX 764 ; N uni20A7 ; G 80
|
107 |
+
U 8360 ; WX 961 ; N uni20A8 ; G 81
|
108 |
+
U 8361 ; WX 1025 ; N uni20A9 ; G 82
|
109 |
+
U 8362 ; WX 736 ; N uni20AA ; G 83
|
110 |
+
U 8363 ; WX 676 ; N uni20AB ; G 84
|
111 |
+
U 8364 ; WX 746 ; N uni20AC ; G 85
|
112 |
+
U 8365 ; WX 965 ; N uni20AD ; G 86
|
113 |
+
U 8366 ; WX 633 ; N uni20AE ; G 87
|
114 |
+
U 8367 ; WX 1049 ; N uni20AF ; G 88
|
115 |
+
U 8368 ; WX 709 ; N uni20B0 ; G 89
|
116 |
+
U 8369 ; WX 881 ; N uni20B1 ; G 90
|
117 |
+
U 8370 ; WX 650 ; N uni20B2 ; G 91
|
118 |
+
U 8371 ; WX 760 ; N uni20B3 ; G 92
|
119 |
+
U 8372 ; WX 643 ; N uni20B4 ; G 93
|
120 |
+
U 8373 ; WX 650 ; N uni20B5 ; G 94
|
121 |
+
U 8377 ; WX 636 ; N uni20B9 ; G 95
|
122 |
+
U 8378 ; WX 636 ; N uni20BA ; G 96
|
123 |
+
U 8381 ; WX 636 ; N uni20BD ; G 97
|
124 |
+
U 8382 ; WX 572 ; N uni20BE ; G 98
|
125 |
+
U 8499 ; WX 824 ; N uni2133 ; G 99
|
126 |
+
U 20803 ; WX 1000 ; N uni5143 ; G 100
|
127 |
+
U 20870 ; WX 1000 ; N uni5186 ; G 101
|
128 |
+
U 22278 ; WX 1000 ; N uni5706 ; G 102
|
129 |
+
U 22291 ; WX 1000 ; N uni5713 ; G 103
|
130 |
+
U 65020 ; WX 1086 ; N uniFDFC ; G 104
|
131 |
+
EndCharMetrics
|
132 |
+
EndFontMetrics
|
lib/dompdf/lib/fonts/dompdf_font_family_cache.php
CHANGED
@@ -87,9 +87,9 @@
|
|
87 |
),
|
88 |
'currencies' =>
|
89 |
array (
|
90 |
-
'normal' => DOMPDF_FONT_DIR . '
|
91 |
-
'bold' => DOMPDF_FONT_DIR . '
|
92 |
-
'italic' => DOMPDF_FONT_DIR . '
|
93 |
-
'bold_italic' => DOMPDF_FONT_DIR . '
|
94 |
),
|
95 |
) ?>
|
87 |
),
|
88 |
'currencies' =>
|
89 |
array (
|
90 |
+
'normal' => DOMPDF_FONT_DIR . 'currencies',
|
91 |
+
'bold' => DOMPDF_FONT_DIR . 'currencies',
|
92 |
+
'italic' => DOMPDF_FONT_DIR . 'currencies',
|
93 |
+
'bold_italic' => DOMPDF_FONT_DIR . 'currencies',
|
94 |
),
|
95 |
) ?>
|
readme.txt
CHANGED
@@ -1,543 +1,550 @@
|
|
1 |
-
===
|
2 |
-
Contributors: pomegranate
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
License
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*
|
19 |
-
*
|
20 |
-
*
|
21 |
-
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
*
|
46 |
-
|
47 |
-
|
48 |
-
Automatic installation
|
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 |
-
= 1.6.
|
110 |
-
* Fix:
|
111 |
-
* Fix:
|
112 |
-
|
113 |
-
= 1.6.
|
114 |
-
* Fix:
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
* Fix:
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
* Fix:
|
123 |
-
|
124 |
-
= 1.6.
|
125 |
-
*
|
126 |
-
*
|
127 |
-
|
128 |
-
|
129 |
-
* Fix:
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
*
|
134 |
-
*
|
135 |
-
* Fix:
|
136 |
-
*
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
*
|
141 |
-
*
|
142 |
-
*
|
143 |
-
*
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
*
|
148 |
-
*
|
149 |
-
*
|
150 |
-
*
|
151 |
-
*
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
*
|
156 |
-
|
157 |
-
|
158 |
-
*
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
* Translations:
|
166 |
-
|
167 |
-
= 1.5.
|
168 |
-
* Fix:
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
*
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
*
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
*
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
*
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
*
|
193 |
-
* Fix:
|
194 |
-
*
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
* Feature:
|
199 |
-
* Feature:
|
200 |
-
*
|
201 |
-
*
|
202 |
-
*
|
203 |
-
|
204 |
-
|
205 |
-
*
|
206 |
-
*
|
207 |
-
|
208 |
-
|
209 |
-
*
|
210 |
-
|
211 |
-
|
212 |
-
*
|
213 |
-
*
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
*
|
220 |
-
|
221 |
-
|
222 |
-
* Translations:
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
*
|
227 |
-
|
228 |
-
|
229 |
-
*
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
* Fix:
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
*
|
240 |
-
|
241 |
-
= 1.5.
|
242 |
-
*
|
243 |
-
|
244 |
-
|
245 |
-
*
|
246 |
-
*
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
*
|
252 |
-
* Tweak:
|
253 |
-
*
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
*
|
261 |
-
|
262 |
-
|
263 |
-
*
|
264 |
-
* Translations:
|
265 |
-
|
266 |
-
= 1.5.
|
267 |
-
*
|
268 |
-
|
269 |
-
|
270 |
-
*
|
271 |
-
*
|
272 |
-
|
273 |
-
= 1.5.
|
274 |
-
*
|
275 |
-
|
276 |
-
= 1.5.
|
277 |
-
*
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
*
|
282 |
-
|
283 |
-
|
284 |
-
*
|
285 |
-
|
286 |
-
= 1.5.
|
287 |
-
* Feature:
|
288 |
-
|
289 |
-
|
290 |
-
*
|
291 |
-
*
|
292 |
-
|
293 |
-
|
294 |
-
*
|
295 |
-
|
296 |
-
|
297 |
-
*
|
298 |
-
*
|
299 |
-
*
|
300 |
-
*
|
301 |
-
|
302 |
-
|
303 |
-
* Fix:
|
304 |
-
* Fix:
|
305 |
-
* Fix:
|
306 |
-
*
|
307 |
-
* Translations: Updated
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
*
|
312 |
-
*
|
313 |
-
* Fix:
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
*
|
319 |
-
* Tweak:
|
320 |
-
* Fix:
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
*
|
325 |
-
*
|
326 |
-
|
327 |
-
|
328 |
-
*
|
329 |
-
|
330 |
-
= 1.5.
|
331 |
-
*
|
332 |
-
*
|
333 |
-
|
334 |
-
|
335 |
-
*
|
336 |
-
|
337 |
-
|
338 |
-
*
|
339 |
-
|
340 |
-
|
341 |
-
*
|
342 |
-
* Translations: Updated
|
343 |
-
* Translations:
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
*
|
349 |
-
* Translations:
|
350 |
-
*
|
351 |
-
|
352 |
-
= 1.4.
|
353 |
-
*
|
354 |
-
|
355 |
-
|
356 |
-
*
|
357 |
-
*
|
358 |
-
|
359 |
-
= 1.4.
|
360 |
-
* Fix:
|
361 |
-
|
362 |
-
|
363 |
-
*
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
*
|
368 |
-
* Translations:
|
369 |
-
*
|
370 |
-
*
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
*
|
375 |
-
|
376 |
-
|
377 |
-
*
|
378 |
-
*
|
379 |
-
|
380 |
-
|
381 |
-
*
|
382 |
-
|
383 |
-
|
384 |
-
*
|
385 |
-
*
|
386 |
-
|
387 |
-
|
388 |
-
*
|
389 |
-
*
|
390 |
-
|
391 |
-
|
392 |
-
*
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
*
|
400 |
-
* Fix:
|
401 |
-
*
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
* Feature:
|
406 |
-
*
|
407 |
-
*
|
408 |
-
* Tweak:
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
*
|
413 |
-
|
414 |
-
|
415 |
-
*
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
*
|
420 |
-
|
421 |
-
|
422 |
-
*
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
*
|
429 |
-
*
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
*
|
436 |
-
* Translations:
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
*
|
441 |
-
|
442 |
-
|
443 |
-
*
|
444 |
-
|
445 |
-
= 1.2.
|
446 |
-
*
|
447 |
-
*
|
448 |
-
|
449 |
-
= 1.2.
|
450 |
-
*
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
*
|
455 |
-
|
456 |
-
|
457 |
-
*
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
* Fix:
|
462 |
-
|
463 |
-
|
464 |
-
*
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
*
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
*
|
473 |
-
|
474 |
-
|
475 |
-
* Translations:
|
476 |
-
*
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
* Feature:
|
481 |
-
|
482 |
-
|
483 |
-
*
|
484 |
-
*
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
* Feature:
|
491 |
-
*
|
492 |
-
*
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
*
|
499 |
-
*
|
500 |
-
|
501 |
-
= 1.1
|
502 |
-
*
|
503 |
-
|
504 |
-
|
505 |
-
*
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
*
|
510 |
-
|
511 |
-
|
512 |
-
* Fix:
|
513 |
-
|
514 |
-
= 1.1.
|
515 |
-
* Feature:
|
516 |
-
*
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
*
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
* Feature:
|
529 |
-
*
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
*
|
536 |
-
|
537 |
-
|
538 |
-
*
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WooCommerce PDF Invoices & Packing Slips ===
|
2 |
+
Contributors: pomegranate
|
3 |
+
Donate link: https://wpovernight.com/
|
4 |
+
Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
|
5 |
+
Requires at least: 3.5
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 1.6.6
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Create, print & automatically email PDF invoices & packing slips for WooCommerce orders.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
This WooCommerce extension automatically adds a PDF invoice to the order confirmation emails sent out to your customers. Includes a basic template (additional templates are available from [WP Overnight](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/)) as well as the possibility to modify/create your own templates. In addition, you can choose to download or print invoices and packing slips from the WooCommerce order admin.
|
16 |
+
|
17 |
+
= Main features =
|
18 |
+
* Automatically attach invoice PDF to WooCommerce emails of your choice
|
19 |
+
* Download the PDF invoice / packing slip from the order admin page
|
20 |
+
* Generate PDF invoices / packings slips in bulk
|
21 |
+
* **Fully customizable** HTML/CSS invoice templates
|
22 |
+
* Download invoices from the My Account page
|
23 |
+
* Sequential invoice numbers - with custom formatting
|
24 |
+
* **Available in: Czech, Dutch, English, Finnish, French, German, Hungarian, Italian, Japanese (see FAQ for adding custom fonts!), Norwegian, Polish, Romanian, Russian, Slovak, Slovenian, Spanish, Swedish & Ukrainian**
|
25 |
+
|
26 |
+
In addition to this, we offer several premium extensions:
|
27 |
+
|
28 |
+
* Create/email PDF Proforma Invoices, Credit Notes (for Refunds), email Packing Slips & more with [WooCommerce PDF Invoices & Packing Slips Professional](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-professional/)
|
29 |
+
* Upload all invoices automatically to Dropbox with [WooCommerce PDF Invoices & Packing Slips to Dropbox](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-dropbox/)
|
30 |
+
* Automatically send new orders or packing slips to your printer, as soon as the customer orders! [WooCommerce Automatic Order Printing](https://www.simbahosting.co.uk/s3/product/woocommerce-automatic-order-printing/?affiliates=2) (from our partners at Simba Hosting)
|
31 |
+
* More advanced & stylish templates with [WooCommerce PDF Invoices & Packing Slips Premium Templates](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/)
|
32 |
+
|
33 |
+
= Fully customizable =
|
34 |
+
In addition to a number of default settings (including a custom header/logo) and several layout fields that you can use out of the box, the plugin contains HTML/CSS based templates that allow for customization & full control over the PDF output. Copy the templates to your theme folder and you don't have to worry that your customizations will be overwritten when you update the plugin.
|
35 |
+
|
36 |
+
* Insert customer header image/logo
|
37 |
+
* Modify shop data / footer / disclaimer etc. on the invoices & packing slips
|
38 |
+
* Select paper size (Letter or A4)
|
39 |
+
* Translation ready
|
40 |
+
|
41 |
+
== Installation ==
|
42 |
+
|
43 |
+
= Minimum Requirements =
|
44 |
+
|
45 |
+
* WooCommerce 2.0 or later
|
46 |
+
* WordPress 3.5 or later
|
47 |
+
|
48 |
+
= Automatic installation =
|
49 |
+
Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't even need to leave your web browser. To do an automatic install of WooCommerce PDF Invoices & Packing Slips, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
|
50 |
+
|
51 |
+
In the search field type "WooCommerce PDF Invoices & Packing Slips" and click Search Plugins. You can install it by simply clicking Install Now. After clicking that link you will be asked if you're sure you want to install the plugin. Click yes and WordPress will automatically complete the installation. After installation has finished, click the 'activate plugin' link.
|
52 |
+
|
53 |
+
= Manual installation via the WordPress interface =
|
54 |
+
1. Download the plugin zip file to your computer
|
55 |
+
2. Go to the WordPress admin panel menu Plugins > Add New
|
56 |
+
3. Choose upload
|
57 |
+
4. Upload the plugin zip file, the plugin will now be installed
|
58 |
+
5. After installation has finished, click the 'activate plugin' link
|
59 |
+
|
60 |
+
= Manual installation via FTP =
|
61 |
+
1. Download the plugin file to your computer and unzip it
|
62 |
+
2. Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your WordPress installation's wp-content/plugins/ directory.
|
63 |
+
3. Activate the plugin from the Plugins menu within the WordPress admin.
|
64 |
+
|
65 |
+
== Frequently Asked Questions ==
|
66 |
+
|
67 |
+
= Where can I find the documentation? =
|
68 |
+
|
69 |
+
[WooCommerce PDF Invoices & Packing Slips documentation](http://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/)
|
70 |
+
|
71 |
+
= It's not working! =
|
72 |
+
|
73 |
+
Check out our step by step diagnostic instructions here: https://wordpress.org/support/topic/read-this-first-9/
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
= Where can I find more templates? =
|
80 |
+
|
81 |
+
Go to [wpovernight.com](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/) to checkout more templates! These include templates with more tax details and product thumbnails. Need a custom templates? Contact us at support@wpovernight.com for more information.
|
82 |
+
|
83 |
+
= Can I create/send a proforma invoice or a credit note? =
|
84 |
+
This is a feature of our Professional extension, which can be found at [wpovernight.com](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-professional/)
|
85 |
+
|
86 |
+
= Can I contribute to the code? =
|
87 |
+
You're more than welcome! This plugin is hosted on github, where you can post issues or make pull requests.
|
88 |
+
https://github.com/wpovernight/woocommerce-pdf-invoices-packing-slips
|
89 |
+
|
90 |
+
= How can I display the HTML/CSS source for debugging/developing templates? =
|
91 |
+
There's a setting on the Status tab of the settings page that allows you to toggle HTML output. Don't forget to turn if off after you're done testing!
|
92 |
+
|
93 |
+
|
94 |
+
== Screenshots ==
|
95 |
+
|
96 |
+
1. General settings page
|
97 |
+
2. Template settings page
|
98 |
+
3. Simple invoice PDF
|
99 |
+
4. Simple packing slip PDF
|
100 |
+
|
101 |
+
== Changelog ==
|
102 |
+
|
103 |
+
= 1.6.6 =
|
104 |
+
* **This is the last release before our [upcoming 2.0 update](https://wpovernight.com/2017/06/woocomerce-pdf-invoice-2-0-beta-testers-wanted/)**
|
105 |
+
* Feature: Facilitate downgrading from 2.0 (re-installing fonts & resetting version)
|
106 |
+
* Fix: Update currencies font (added Georgian Lari)
|
107 |
+
* Translations: Added Indonesian
|
108 |
+
|
109 |
+
= 1.6.5 =
|
110 |
+
* Fix: Duplicate invoice numbers when bulk completing orders (WC3.0)
|
111 |
+
* Fix: Hidden Invoice date when order refunded
|
112 |
+
|
113 |
+
= 1.6.4 =
|
114 |
+
* Fix: My account invoice button visibility
|
115 |
+
|
116 |
+
= 1.6.3 =
|
117 |
+
* Fix: Empty date handling
|
118 |
+
* Fix: Shipping notes on refunds (reason for refund)
|
119 |
+
|
120 |
+
= 1.6.2 =
|
121 |
+
* Fix: TM Extra Product Options compatibility (in WC3.0)
|
122 |
+
* Fix: Tax display in WC3.0
|
123 |
+
|
124 |
+
= 1.6.1 =
|
125 |
+
* Fix: Error with totals in credit notes
|
126 |
+
* Fix: Always set invoice date when invoice is create (even display is disabled in the settings)
|
127 |
+
|
128 |
+
= 1.6.0.2 =
|
129 |
+
* Fix: Don't crash with PHP 5.2 or older (5.3 or higher required, 5.6 or higher recommended)
|
130 |
+
|
131 |
+
= 1.6.0 =
|
132 |
+
* WooCommerce 3.0 Compatible
|
133 |
+
* **Requires PHP version 5.3 or higher**
|
134 |
+
* Fix: Invoice number display in mobile view
|
135 |
+
* Fix: Update formatted invoice number in order meta when number is altered
|
136 |
+
* Fix: global plugin object loading in wrapped cron methods
|
137 |
+
* Tweak: Avoid PHP7 scan false positives in DomPDF
|
138 |
+
|
139 |
+
= 1.5.39 =
|
140 |
+
* Feature: new template action hooks `wpo_wcpdf_before_document` & `wpo_wcpdf_after_document`
|
141 |
+
* Tweak: In totals, emphasize order total rather than last item
|
142 |
+
* Fix: User deprecation notices
|
143 |
+
* Translations: Updated Slovenian
|
144 |
+
|
145 |
+
= 1.5.38 =
|
146 |
+
* Fix: Thumbnail path fallback
|
147 |
+
* Fix: Edge/IE hour & minute pattern
|
148 |
+
* Fix: Skip over non-order objects
|
149 |
+
* Tweak: Let shop manager view My Account links
|
150 |
+
* Dev: added `wpo_wcpdf_before_attachment_creation` action
|
151 |
+
* Translations: Updated POT, Swedish, Dutch & Norwegian
|
152 |
+
|
153 |
+
= 1.5.37 =
|
154 |
+
* Feature: Added support for third party invoice numbers
|
155 |
+
* Feature: Enable pre-invoice number click-to-edit
|
156 |
+
* Fix: Review link for custom admins
|
157 |
+
* Fix: PHP7 compatibility
|
158 |
+
* Fix: Invoice date hour/minute pattern
|
159 |
+
* Tweak: Multisite WooCommerce check optimization
|
160 |
+
|
161 |
+
= 1.5.36 =
|
162 |
+
* Translations: Fixed Romanian (incorrect "Factură Proforma" translation for "Invoice")
|
163 |
+
|
164 |
+
= 1.5.35 =
|
165 |
+
* Translations: Fixed "Includes %s" string for WC2.6+
|
166 |
+
|
167 |
+
= 1.5.34 =
|
168 |
+
* Fix: Document check that was introduced in 1.5.33 for disable free setting
|
169 |
+
|
170 |
+
= 1.5.33 =
|
171 |
+
* Tweak: Don't apply 'disable free' setting to packing slip attachment
|
172 |
+
* Translations: Updated Romanian
|
173 |
+
|
174 |
+
= 1.5.32 =
|
175 |
+
* Fix: Updated currency font with Indian Rupee symbol
|
176 |
+
* Translations: added Formal German (currently a copy of informal German)
|
177 |
+
|
178 |
+
= 1.5.31 =
|
179 |
+
* Feature: [invoice_day] or [order_day] in invoice number format
|
180 |
+
* Fix: Link to hide all ads when premium extensions active
|
181 |
+
|
182 |
+
= 1.5.30 =
|
183 |
+
* Feature: Enable currency font for extended currency support
|
184 |
+
* Fix: Font sync on plugin update
|
185 |
+
|
186 |
+
= 1.5.29 =
|
187 |
+
* Translations: Added Croation (Thanks Neven/Spine ICT!), updated French (Thanks Sabra!)
|
188 |
+
* Tweak: filter shop address before checking if it's empty
|
189 |
+
* Dev: added $order to `wpo_wcpdf_template_file` filter
|
190 |
+
|
191 |
+
= 1.5.28 =
|
192 |
+
* Tweak: the 'Next invoice number' is now stored separately in the database for faster and more reliable retrieval. Circumventing any caching, this should prevent duplicate invoice numbers.
|
193 |
+
* Fix: Bulk actions plugin conflicts
|
194 |
+
* Experimental: page numbers (use {{PAGE_NUM}} / {{PAGE_COUNT}} in your template)
|
195 |
+
|
196 |
+
= 1.5.27 =
|
197 |
+
* Feature: Use [invoice_year] and [invoice_month] placeholders in invoice number prefix/suffix
|
198 |
+
* Feature: WooCommerce Order Status & Actions Manager emails compatibility
|
199 |
+
* Feature: Add invoice number to WC REST API
|
200 |
+
* Fix: Allow positive 'discounts' (price corrections)
|
201 |
+
* Fix: Discounts rounding
|
202 |
+
* Translations: Updated Finnish & Portugese & POT
|
203 |
+
|
204 |
+
= 1.5.26 =
|
205 |
+
* Feature: Automatically list all emails registered in WooCommerce
|
206 |
+
* Feature: Reset invoice number yearly
|
207 |
+
* Feature: WooCommerce Chained Products compatibility
|
208 |
+
* Feature: WooCommerce Product Bundles visibility settings taken into account in invoice
|
209 |
+
* Fix: Disable PDF creation from trashed order_ids
|
210 |
+
* Tweak: Alert when no orders selected for bulk export (Props to Dartui!)
|
211 |
+
* Tweak: PDF invoice settings always under WooCommerce menu (also for premium users)
|
212 |
+
* Tweak: extra $item_id passed in row class filter
|
213 |
+
* Translations: Updated Slovenian, Spanish, Dutch & POT file
|
214 |
+
|
215 |
+
= 1.5.24 =
|
216 |
+
* Hotfix: Subscriptions renewal filter arguments
|
217 |
+
|
218 |
+
= 1.5.23 =
|
219 |
+
* Fix: WooCommerce Subscriptons 2.0 deprecation notice.
|
220 |
+
* Tweak: better qTranslate-X support
|
221 |
+
* Tweak: filter for user privileges check (wpo_wcpdf_check_privs)
|
222 |
+
* Translations: French translations fix
|
223 |
+
|
224 |
+
= 1.5.22 =
|
225 |
+
* Fix: Workaround for bug in WPML (which cleared all settings)
|
226 |
+
* Translation: fixed Polish translation for invoice
|
227 |
+
|
228 |
+
= 1.5.21 =
|
229 |
+
* Translations: Added Estionan (thanks Tanel!)
|
230 |
+
* Tweak: WC2.4 compatibility
|
231 |
+
|
232 |
+
= 1.5.20 =
|
233 |
+
* Feature: Option to 'never' display My Account invoice link
|
234 |
+
* Fix: Order total for refunds in WC2.4
|
235 |
+
* Fix: notice when no custom statuses selected for My Account display
|
236 |
+
* Tweak: Product bundles styles
|
237 |
+
|
238 |
+
= 1.5.19 =
|
239 |
+
* Fix: Invoice number search (broke other custom searches)
|
240 |
+
|
241 |
+
= 1.5.18 =
|
242 |
+
* Fix: wpo_wcpdf_item_row_class packing slip filter arguments
|
243 |
+
|
244 |
+
= 1.5.17 =
|
245 |
+
* Feature: WooCommerce Product Bundles compatibility styles
|
246 |
+
* Tweak: wpo_wcpdf_item_row_class as filter instead of action
|
247 |
+
|
248 |
+
= 1.5.16 =
|
249 |
+
* Feature: Search orders by invoice number (note: search on formatted invoice number only works for new orders)
|
250 |
+
* Feature: Formatted invoice number stored in order
|
251 |
+
* Tweak: Function parameters added to some of the filters
|
252 |
+
* Tweak: WooCommerce 2.4 compatibility
|
253 |
+
* Dev feature: action to add class to items table row (wpo_wcpdf_item_row_class)
|
254 |
+
* Translations: Swedish updated (thanks Conney!)
|
255 |
+
* Translations: Norwegian updated
|
256 |
+
|
257 |
+
= 1.5.15 =
|
258 |
+
* Fix: invoice number padding didn't work for values lower than 3
|
259 |
+
* Tweak: WPML compatibility filter
|
260 |
+
* Translations: Updated French (Thanks Nicolas!)
|
261 |
+
|
262 |
+
= 1.5.14 =
|
263 |
+
* Tweak: Invoice number & date edit fields moved to separate box on order edit page
|
264 |
+
* Translations: Updated POT & Dutch
|
265 |
+
|
266 |
+
= 1.5.13 =
|
267 |
+
* Fix: Better address comparison to determine when to display alternate address
|
268 |
+
* Tweak: Filter N/A addresses
|
269 |
+
* Tweak: Use WooCommerce function for 2.3 discounts
|
270 |
+
* Translations: Czech Updated (Thanks Ivo!)
|
271 |
+
* Translations: French (minor fixes)
|
272 |
+
|
273 |
+
= 1.5.12 =
|
274 |
+
* Translations: added Danish, Updated POT & Italian
|
275 |
+
|
276 |
+
= 1.5.11 =
|
277 |
+
* Fix: Product text attributes (now checks key too)
|
278 |
+
* Fix: Status page upload explanation typos
|
279 |
+
|
280 |
+
= 1.5.10 =
|
281 |
+
* Fix: Double check to make sure plugin doesn't attach to user emails
|
282 |
+
|
283 |
+
= 1.5.9 =
|
284 |
+
* Feature: Shorthand function to display product attributes: `$wpo_wcpdf->get_product_attribute( $attribute_name, $product )`
|
285 |
+
|
286 |
+
= 1.5.8 =
|
287 |
+
* Feature: disable invoice for free orders
|
288 |
+
* Feature: action to insert data before & after item meta
|
289 |
+
* Tweak: Added classes to sku & weight
|
290 |
+
* Tweak: Hide payment method from totals (already shown in template)
|
291 |
+
* Translations: Updated POT & Dutch
|
292 |
+
|
293 |
+
= 1.5.7 =
|
294 |
+
* Feature: Setting to show email address & phone number on invoice or packing slip (does not work on custom templates based on previous versions!)
|
295 |
+
|
296 |
+
= 1.5.6 =
|
297 |
+
* Feature: Setting to show shipping address on invoice (does not work on custom templates based on previous versions!)
|
298 |
+
* Feature: My Account invoice download setting
|
299 |
+
* Feature: several new template actions
|
300 |
+
* Tweak: WooCommerce Bookings compatibility
|
301 |
+
* Tweak: Gerenal stylesheet cleanup
|
302 |
+
* Fix: temp path check/error on settings page
|
303 |
+
* Fix: Document titles for credit notes and proforma (Pro)
|
304 |
+
* Fix: Discount including tax
|
305 |
+
* Fix: Special characters on item meta (requires WooCommerce 2.3.6)
|
306 |
+
* Translations: Missing text domain on several strings
|
307 |
+
* Translations: Updated POT & Dutch
|
308 |
+
|
309 |
+
= 1.5.5 =
|
310 |
+
* Fix: Check for incomplete line tax data (Subscriptions compatibility)
|
311 |
+
* Fix: More precise template path instructions
|
312 |
+
* Fix: duplicate stylesheet filter
|
313 |
+
* Fix: Always prefer original order's billing address for refunds (WooCommerce EU VAT Number compatibility)
|
314 |
+
* Translations: Updated German (MwSt. instead of formal Ust.)
|
315 |
+
* Translations: Updated Dutch
|
316 |
+
|
317 |
+
= 1.5.4 =
|
318 |
+
* Tweak: include plugin version in style/script includes
|
319 |
+
* Tweak: upload code cleanup
|
320 |
+
* Fix: Parent invoice number (for Credit Notes in professional extension)
|
321 |
+
|
322 |
+
= 1.5.3 =
|
323 |
+
* Feature: add original order date value to order date filter
|
324 |
+
* Feature: Work with line_tax_data when available
|
325 |
+
* Feature: pass item_id to items
|
326 |
+
* Tweak: later check for woocommerce active
|
327 |
+
* Fix: do not try to validate empty settings (Status page settings)
|
328 |
+
* Translations: Fixed Dutch typo
|
329 |
+
|
330 |
+
= 1.5.2 =
|
331 |
+
* Fix: fatal error when trying to activate with WooCommerce not installed yet.
|
332 |
+
* Tweak: indentation fix on the Simple template
|
333 |
+
|
334 |
+
= 1.5.1 =
|
335 |
+
* Fix: prevent errors when upgrading
|
336 |
+
|
337 |
+
= 1.5.0 =
|
338 |
+
* Feature: All temporary files are now stored centrally in the WP uploads folder.
|
339 |
+
* Feature: Debug settings in status panel (output errors & output to HTML)
|
340 |
+
* Feature: Compatibility filter for WooCommerce Subscriptions (prevents duplicate invoice numbers)
|
341 |
+
* Tweak: Pass order to totals filters
|
342 |
+
* Translations: Updated POT
|
343 |
+
* Translations: Updated Italian (Thanks Astrid!)
|
344 |
+
* Translations: Updated Dutch
|
345 |
+
* FAQ: instructions for placing a link on the thank you page
|
346 |
+
|
347 |
+
= 1.4.14 =
|
348 |
+
* Fix: fatal error when user registers at checkout (applies to credit notes only)
|
349 |
+
* Translations: Updated German (Thanks Dietmar!)
|
350 |
+
* Translations: Place your custom translations in wp-content/languages/woocommerce-pdf-invoices-packing-slips/wpo_wcpdf-LOCALE.mo to protect them from being overwritten by plugin updates.
|
351 |
+
|
352 |
+
= 1.4.13 =
|
353 |
+
* Feature: use separate file for all your template specific functions (template-functions.php)
|
354 |
+
* Translations: Added Slovenian (thanks gregy1403!)
|
355 |
+
* Translations: Updated Norwegian & Dutch.
|
356 |
+
* Translations: Added Japanese - needs custom font!
|
357 |
+
* FAQ: instructions on how to use custom fonts
|
358 |
+
|
359 |
+
= 1.4.12 =
|
360 |
+
* Fix: issues with post parent objects (WC2.1 and older)
|
361 |
+
|
362 |
+
= 1.4.11 =
|
363 |
+
* Small fix: bulk actions for specific i18n configurations
|
364 |
+
* Tweak: total row key used as class in Simple template
|
365 |
+
|
366 |
+
= 1.4.10 =
|
367 |
+
* Fix: Invoice not attaching
|
368 |
+
* Translations: Updated POT file
|
369 |
+
* Translations: Updated Dutch, Norwegian, Polish, Brazilian Portugese, Romanian, Russian, Slovak, Spanish & Ukrainian (Many thanks to all the translators!)
|
370 |
+
* Templates: added action hooks for easier customizations (`wpo_wcpdf_before_order_details`, `wpo_wcpdf_after_order_details`, `wpo_wcpdf_invoice_title` & `wpo_wcpdf_packing_slip_title`)
|
371 |
+
|
372 |
+
= 1.4.9 =
|
373 |
+
* Feature: Order number and date are now displayed by default in the Simple template (invoice number and date still optional)
|
374 |
+
* Feature: Display Customer/Order notes with a simple shorthand (see FAQ)
|
375 |
+
* Translations: Added Brazilian Portugese (thanks Victor Debone!)
|
376 |
+
* Tweak: Fail more gracefully when there are errors during PDF generation
|
377 |
+
* Tweak: added template type class to template output body
|
378 |
+
* Tweak: cleaned up Simple template style.css
|
379 |
+
|
380 |
+
= 1.4.8 =
|
381 |
+
* Translations: Added Finnish (Thanks Sami Mäkelä/Contrast.fi!)
|
382 |
+
|
383 |
+
= 1.4.7 =
|
384 |
+
* Fix: check if image file exists locally, fallback to url if not (CDN compatibility)
|
385 |
+
* Fix: make deleting invoice date possible
|
386 |
+
* Fix: correct tmp folder check on status page
|
387 |
+
* Translations: updated po/mo files
|
388 |
+
* Tweak: changed settings capability requirement to `manage_woocommerce` (was: `manage_options`)
|
389 |
+
* Tweak: better email attachment function
|
390 |
+
* Tweak: prevent footer overlap (Simple template)
|
391 |
+
* Tweak: fallback if `glob()` is not allowed on the server
|
392 |
+
* Tweak: better custom template instructions (reflects path to actual (child-)theme)
|
393 |
+
|
394 |
+
= 1.4.6 =
|
395 |
+
* HOTFIX: WooCommerce 2.2 compatibility fix
|
396 |
+
* Filter for PDF temp folder (wpo_wcpdf_tmp_path)
|
397 |
+
|
398 |
+
= 1.4.5 =
|
399 |
+
* Fix: Double date conversion for order date on invoice number filter (to avoid i18n date issues)
|
400 |
+
* Fix: Template selector reset after update
|
401 |
+
* Translations: added Norwegian (Thanks Aleksander!)
|
402 |
+
|
403 |
+
= 1.4.4 =
|
404 |
+
* Feature: Editable invoice date per order/invoice.
|
405 |
+
* Feature: HTML is now allowed in footer and other settings fields.
|
406 |
+
* Translations: Updated German (Thanks Nadine!)
|
407 |
+
* Fix: template paths are now saved relative to the site base path (ABSPATH) to prevent errors when moving to another server
|
408 |
+
* Tweak: Changed bulk action hook for better theme compatibility
|
409 |
+
* Tweak: Newlines in custom checkout fields
|
410 |
+
|
411 |
+
= 1.4.3 =
|
412 |
+
* Feature: Added function to call custom fields more easily (see FAQ)
|
413 |
+
* Feature: Change the my account button text via a filter (wpo_wcpdf_myaccount_button_text)
|
414 |
+
* Translations: Added Danish (Thanks Mads!)
|
415 |
+
* Tweak: only load PDF engine if it's not already loaded by another plugin
|
416 |
+
|
417 |
+
= 1.4.2 =
|
418 |
+
* Fix: Don't create invoice number when exporting packing slips
|
419 |
+
* Fix: Division by zero for 0 quantity items
|
420 |
+
|
421 |
+
= 1.4.1 =
|
422 |
+
* Translations: Added Polish (Thanks Mike!)
|
423 |
+
* Fix: Invoice number formatting notices in debug mode
|
424 |
+
|
425 |
+
= 1.4.0 =
|
426 |
+
* Feature: Invoice numbers can now be given a prefix, suffix or padding on the settings page!
|
427 |
+
* Filter: `wpo_wcpdf_email_allowed_statuses` to attach pdf to custom order status emails
|
428 |
+
* Tweak: Sequential Order Numbers Pro compatibility
|
429 |
+
* Tweak: Filenames are now automatically sanitized to prevent issues with illegal characters
|
430 |
+
|
431 |
+
= 1.3.2 =
|
432 |
+
* Fix: error on wpo_wcpdf_email_attachment filter when $pdf_path not set
|
433 |
+
|
434 |
+
= 1.3.1 =
|
435 |
+
* Fix: invoice number was cleared when Order Actions were being used when an invoice number was not set
|
436 |
+
* Translations: Updated Slovak (Thanks Jozef!)
|
437 |
+
* Translations: Added Czech (Thanks CubiQ!)
|
438 |
+
|
439 |
+
= 1.3.0 =
|
440 |
+
* Feature: Added 'status' panel for better problem diagnosis
|
441 |
+
* Tweak: split create & get invoice number calls to prevent slow database calls from causing number skipping
|
442 |
+
* Translations: Added Romanian (Thanks Leonardo!)
|
443 |
+
* Translations: Added Slovak (Thanks Oleg!)
|
444 |
+
|
445 |
+
= 1.2.13 =
|
446 |
+
* Feature: added filter for custom email attachment condition (wpo_wcpdf_custom_email_condition)
|
447 |
+
* Fix: warning for tax implode
|
448 |
+
|
449 |
+
= 1.2.12 =
|
450 |
+
* Fix: hyperlink underline (was more like a strikethrough)
|
451 |
+
|
452 |
+
= 1.2.11 =
|
453 |
+
* Translations: Fixed German spelling error
|
454 |
+
* Translations: Updated Swedish (Thanks Fredrik!)
|
455 |
+
|
456 |
+
= 1.2.10 =
|
457 |
+
* Translations: Added Swedish (Thanks Jonathan!)
|
458 |
+
* Fix: Line-height issue (on some systems, the space between lines was very high)
|
459 |
+
|
460 |
+
= 1.2.9 =
|
461 |
+
* Fix: bug where 'standard' tax class would not display in some cases
|
462 |
+
* Fix: bug that caused the totals to jump for some font sizes
|
463 |
+
* Fix: WC2.1 deprecated totals function
|
464 |
+
* Fix: If multiple taxes were set up with the same name, only one would display (Simple template was not affected)
|
465 |
+
|
466 |
+
= 1.2.8 =
|
467 |
+
* Template: Body line-height defined to prevent character jumping with italic texts
|
468 |
+
* Fix: Open Sans now included in plugin package (fixes font issues for servers with allow_url_fopen disabled)
|
469 |
+
|
470 |
+
= 1.2.7 =
|
471 |
+
* Translations: POT, DE & NL updated
|
472 |
+
* Fix: Removed stray span tag in totals table
|
473 |
+
|
474 |
+
= 1.2.6 =
|
475 |
+
* Translations: Spanish update (thanks prepu!)
|
476 |
+
* Fix: More advanced checks to determine if a customer can download the invoice (including a status filter)
|
477 |
+
|
478 |
+
= 1.2.5 =
|
479 |
+
* Feature: Optional Invoice Number column for the orders listing
|
480 |
+
* Feature: Better support for international characters
|
481 |
+
* Translations: Added Russian & Ukrainian translation (thanks Oleg!)
|
482 |
+
* Translations: Updated Spanish (Thanks Manuel!) and Dutch translations & POT file
|
483 |
+
* Tweak: Memory limit notice
|
484 |
+
* Tweak: Filename name now includes invoice number (when configured in the settings)
|
485 |
+
|
486 |
+
= 1.2.4 =
|
487 |
+
* Feature: Set which type of emails you want to attach the invoice to
|
488 |
+
|
489 |
+
= 1.2.3 =
|
490 |
+
* Feature: Manually edit invoice number on the edit order screen
|
491 |
+
* Feature: Set the first (/next) invoice number on the settings screen
|
492 |
+
* Fix: Bug where invoice number would be generated twice due to slow database calls
|
493 |
+
* Fix: php strict warnings
|
494 |
+
|
495 |
+
= 1.2.2 =
|
496 |
+
* Feature: Simple template now uses Open Sans to include more international special characters
|
497 |
+
* Feature: Implemented filters for paper size & orientation ([read here](http://wordpress.org/support/topic/select-a5-paper-size-for-packing-slips?replies=5#post-5211129))
|
498 |
+
* Tweak: PDF engine updated (dompdf 0.6.0)
|
499 |
+
* Tweak: Download PDF link on the my account page is now only shown when an invoice is already created by the admin or automatically, to prevent unwanted invoice created (creating problems with european laws).
|
500 |
+
|
501 |
+
= 1.2.1 =
|
502 |
+
* Fix: shipping & fees functions didn't output correctly with the tax set to 'incl'
|
503 |
+
|
504 |
+
= 1.2.0 =
|
505 |
+
* Feature: Sequential invoice numbers (set upon invoice creation).
|
506 |
+
* Feature: Invoice date (set upon invoice creation).
|
507 |
+
|
508 |
+
= 1.1.6 =
|
509 |
+
* Feature: Hungarian translations added - thanks Joseph!
|
510 |
+
* Tweak: Better debug code.
|
511 |
+
* Tweak: Error reporting when templates not found.
|
512 |
+
* Fix: tax rate calculation for free items.
|
513 |
+
|
514 |
+
= 1.1.5 =
|
515 |
+
* Feature: German translations added - thanks Christian!
|
516 |
+
* Fix: dompdf 0.6.0 proved to be less stable, so switching back to beta3 for now.
|
517 |
+
|
518 |
+
= 1.1.4 =
|
519 |
+
* Fix: Template paths on windows servers were not properly saved (stripslashes), resulting in an empty output.
|
520 |
+
|
521 |
+
= 1.1.3 =
|
522 |
+
* Feature: PDF engine (dompdf) updated to 0.6.0 for better stability and utf-8 support.
|
523 |
+
* Tweak: Local server path is used for header image for better compatibility with server settings.
|
524 |
+
* Fix: several small bugs.
|
525 |
+
|
526 |
+
= 1.1.2 =
|
527 |
+
* Feature: Totals can now be called with simpler template functions
|
528 |
+
* Feature: Italian translations - thanks max66max!
|
529 |
+
* Tweak: improved memory performance
|
530 |
+
|
531 |
+
= 1.1.1 =
|
532 |
+
* Feature: French translations - thanks Guillaume!
|
533 |
+
|
534 |
+
= 1.1.0 =
|
535 |
+
* Feature: Fees can now also be called ex. VAT
|
536 |
+
* Feature: Invoices can now be downloaded from the My Account page
|
537 |
+
* Feature: Spanish translation & POT file included
|
538 |
+
* Fix: ternary statements that caused an error
|
539 |
+
|
540 |
+
= 1.0.1 =
|
541 |
+
* Tweak: Packing slip now displays shipping address instead of billing address
|
542 |
+
* Tweak: Variation data is now displayed by default
|
543 |
+
|
544 |
+
= 1.0.0 =
|
545 |
+
* First release
|
546 |
+
|
547 |
+
== Upgrade Notice ==
|
548 |
+
|
549 |
+
= 1.6.6 =
|
550 |
+
Important: Version 1.6 requires PHP 5.3 or higher to run!
|
woocommerce-pdf-invoices-packingslips.php
CHANGED
@@ -1,590 +1,666 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
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.6.
|
7 |
-
* Author: Ewout Fernhout
|
8 |
-
* Author URI: http://www.wpovernight.com
|
9 |
-
* License: GPLv2 or later
|
10 |
-
* License URI: http://www.opensource.org/licenses/gpl-license.php
|
11 |
-
* Text Domain: wpo_wcpdf
|
12 |
-
*/
|
13 |
-
defined( 'ABSPATH' ) or exit;
|
14 |
-
|
15 |
-
if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
|
16 |
-
|
17 |
-
class WooCommerce_PDF_Invoices {
|
18 |
-
|
19 |
-
public static $plugin_prefix;
|
20 |
-
public static $plugin_url;
|
21 |
-
public static $plugin_path;
|
22 |
-
public static $plugin_basename;
|
23 |
-
public static $version;
|
24 |
-
|
25 |
-
public $writepanels;
|
26 |
-
public $settings;
|
27 |
-
public $export;
|
28 |
-
|
29 |
-
protected static $_instance = null;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Main Plugin Instance
|
33 |
-
*
|
34 |
-
* Ensures only one instance of plugin is loaded or can be loaded.
|
35 |
-
*/
|
36 |
-
public static function instance() {
|
37 |
-
if ( is_null( self::$_instance ) ) {
|
38 |
-
self::$_instance = new self();
|
39 |
-
}
|
40 |
-
return self::$_instance;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Constructor
|
45 |
-
*/
|
46 |
-
public function __construct() {
|
47 |
-
self::$plugin_prefix = 'wpo_wcpdf_';
|
48 |
-
self::$plugin_basename = plugin_basename(__FILE__);
|
49 |
-
self::$plugin_url = plugin_dir_url(self::$plugin_basename);
|
50 |
-
self::$plugin_path = trailingslashit(dirname(__FILE__));
|
51 |
-
self::$version = '1.6.
|
52 |
-
|
53 |
-
// load the localisation & classes
|
54 |
-
add_action( 'plugins_loaded', array( $this, 'translations' ) ); // or use init?
|
55 |
-
add_action( 'init', array( $this, 'load_classes' ) );
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
if
|
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 |
-
load_textdomain( 'wpo_wcpdf', $dir . '
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
include_once( 'includes/class-wcpdf-
|
97 |
-
include_once( 'includes/class-wcpdf-
|
98 |
-
include_once( 'includes/class-wcpdf-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
include_once( 'includes/compatibility/
|
103 |
-
include_once( 'includes/compatibility/class-wc-
|
104 |
-
include_once( 'includes/compatibility/class-wc-
|
105 |
-
include_once( 'includes/compatibility/class-wc-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
$this->
|
126 |
-
$this->
|
127 |
-
$this->
|
128 |
-
$this->
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
*
|
148 |
-
*
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
$
|
166 |
-
$
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
*
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
$
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
$
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
$
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
return $
|
331 |
-
}
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
public function
|
519 |
-
|
520 |
-
}
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
public function
|
533 |
-
$this->functions->
|
534 |
-
}
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
public function
|
544 |
-
$this->functions->
|
545 |
-
}
|
546 |
-
|
547 |
-
/**
|
548 |
-
* Return/
|
549 |
-
*/
|
550 |
-
public function
|
551 |
-
return $this->functions->
|
552 |
-
}
|
553 |
-
public function
|
554 |
-
$this->functions->
|
555 |
-
}
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Return/
|
559 |
-
*/
|
560 |
-
public function
|
561 |
-
return $this->functions->
|
562 |
-
}
|
563 |
-
public function
|
564 |
-
$this->functions->
|
565 |
-
}
|
566 |
-
|
567 |
-
/**
|
568 |
-
* Return/
|
569 |
-
*/
|
570 |
-
public function
|
571 |
-
return $this->functions->
|
572 |
-
}
|
573 |
-
public function
|
574 |
-
$this->functions->
|
575 |
-
}
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
$GLOBALS['wpo_wcpdf'] = WPO_WCPDF();
|
1 |
+
<?php
|
2 |
+
/**
|
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.6.6
|
7 |
+
* Author: Ewout Fernhout
|
8 |
+
* Author URI: http://www.wpovernight.com
|
9 |
+
* License: GPLv2 or later
|
10 |
+
* License URI: http://www.opensource.org/licenses/gpl-license.php
|
11 |
+
* Text Domain: wpo_wcpdf
|
12 |
+
*/
|
13 |
+
defined( 'ABSPATH' ) or exit;
|
14 |
+
|
15 |
+
if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
|
16 |
+
|
17 |
+
class WooCommerce_PDF_Invoices {
|
18 |
+
|
19 |
+
public static $plugin_prefix;
|
20 |
+
public static $plugin_url;
|
21 |
+
public static $plugin_path;
|
22 |
+
public static $plugin_basename;
|
23 |
+
public static $version;
|
24 |
+
|
25 |
+
public $writepanels;
|
26 |
+
public $settings;
|
27 |
+
public $export;
|
28 |
+
|
29 |
+
protected static $_instance = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Main Plugin Instance
|
33 |
+
*
|
34 |
+
* Ensures only one instance of plugin is loaded or can be loaded.
|
35 |
+
*/
|
36 |
+
public static function instance() {
|
37 |
+
if ( is_null( self::$_instance ) ) {
|
38 |
+
self::$_instance = new self();
|
39 |
+
}
|
40 |
+
return self::$_instance;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Constructor
|
45 |
+
*/
|
46 |
+
public function __construct() {
|
47 |
+
self::$plugin_prefix = 'wpo_wcpdf_';
|
48 |
+
self::$plugin_basename = plugin_basename(__FILE__);
|
49 |
+
self::$plugin_url = plugin_dir_url(self::$plugin_basename);
|
50 |
+
self::$plugin_path = trailingslashit(dirname(__FILE__));
|
51 |
+
self::$version = '1.6.6';
|
52 |
+
|
53 |
+
// load the localisation & classes
|
54 |
+
add_action( 'plugins_loaded', array( $this, 'translations' ) ); // or use init?
|
55 |
+
add_action( 'init', array( $this, 'load_classes' ) );
|
56 |
+
add_action( 'in_plugin_update_message-'.self::$plugin_basename, array( $this, 'in_plugin_update_message' ) );
|
57 |
+
|
58 |
+
// run lifecycle methods
|
59 |
+
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
60 |
+
// check if upgrading from versionless (1.4.14 and older)
|
61 |
+
if ( get_option('wpo_wcpdf_general_settings') && get_option('wpo_wcpdf_version') === false ) {
|
62 |
+
// tag 'versionless', so that we can apply necessary upgrade settings
|
63 |
+
add_option( 'wpo_wcpdf_version', 'versionless' );
|
64 |
+
}
|
65 |
+
|
66 |
+
add_action( 'wp_loaded', array( $this, 'do_install' ) );
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Load the translation / textdomain files
|
72 |
+
*
|
73 |
+
* Note: the first-loaded translation file overrides any following ones if the same translation is present
|
74 |
+
*/
|
75 |
+
public function translations() {
|
76 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), 'wpo_wcpdf' );
|
77 |
+
$dir = trailingslashit( WP_LANG_DIR );
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Frontend/global Locale. Looks in:
|
81 |
+
*
|
82 |
+
* - WP_LANG_DIR/woocommerce-pdf-invoices-packing-slips/wpo_wcpdf-LOCALE.mo
|
83 |
+
* - WP_LANG_DIR/plugins/wpo_wcpdf-LOCALE.mo
|
84 |
+
* - woocommerce-pdf-invoices-packing-slips/languages/wpo_wcpdf-LOCALE.mo (which if not found falls back to:)
|
85 |
+
* - WP_LANG_DIR/plugins/wpo_wcpdf-LOCALE.mo
|
86 |
+
*/
|
87 |
+
load_textdomain( 'wpo_wcpdf', $dir . 'woocommerce-pdf-invoices-packing-slips/wpo_wcpdf-' . $locale . '.mo' );
|
88 |
+
load_textdomain( 'wpo_wcpdf', $dir . 'plugins/wpo_wcpdf-' . $locale . '.mo' );
|
89 |
+
load_plugin_textdomain( 'wpo_wcpdf', false, dirname( self::$plugin_basename ) . '/languages' );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Load the main plugin classes and functions
|
94 |
+
*/
|
95 |
+
public function includes() {
|
96 |
+
include_once( 'includes/class-wcpdf-settings.php' );
|
97 |
+
include_once( 'includes/class-wcpdf-writepanels.php' );
|
98 |
+
include_once( 'includes/class-wcpdf-export.php' );
|
99 |
+
include_once( 'includes/class-wcpdf-functions.php' );
|
100 |
+
|
101 |
+
// compatibility classes
|
102 |
+
include_once( 'includes/compatibility/abstract-wc-data-compatibility.php' );
|
103 |
+
include_once( 'includes/compatibility/class-wc-date-compatibility.php' );
|
104 |
+
include_once( 'includes/compatibility/class-wc-core-compatibility.php' );
|
105 |
+
include_once( 'includes/compatibility/class-wc-order-compatibility.php' );
|
106 |
+
include_once( 'includes/compatibility/class-wc-product-compatibility.php' );
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Instantiate classes when woocommerce is activated
|
112 |
+
*/
|
113 |
+
public function load_classes() {
|
114 |
+
if ( $this->is_woocommerce_activated() === false ) {
|
115 |
+
add_action( 'admin_notices', array ( $this, 'need_woocommerce' ) );
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
|
119 |
+
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
120 |
+
add_action( 'admin_notices', array ( $this, 'required_php_version' ) );
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
// all systems ready - GO!
|
125 |
+
$this->includes();
|
126 |
+
$this->settings = new WooCommerce_PDF_Invoices_Settings();
|
127 |
+
$this->writepanels = new WooCommerce_PDF_Invoices_Writepanels();
|
128 |
+
$this->export = new WooCommerce_PDF_Invoices_Export();
|
129 |
+
$this->functions = new WooCommerce_PDF_Invoices_Functions();
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Check if woocommerce is activated
|
134 |
+
*/
|
135 |
+
public function is_woocommerce_activated() {
|
136 |
+
$blog_plugins = get_option( 'active_plugins', array() );
|
137 |
+
$site_plugins = is_multisite() ? (array) maybe_unserialize( get_site_option('active_sitewide_plugins' ) ) : array();
|
138 |
+
|
139 |
+
if ( in_array( 'woocommerce/woocommerce.php', $blog_plugins ) || isset( $site_plugins['woocommerce/woocommerce.php'] ) ) {
|
140 |
+
return true;
|
141 |
+
} else {
|
142 |
+
return false;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* WooCommerce not active notice.
|
148 |
+
*
|
149 |
+
* @return string Fallack notice.
|
150 |
+
*/
|
151 |
+
|
152 |
+
public function need_woocommerce() {
|
153 |
+
$error = sprintf( __( 'WooCommerce PDF Invoices & Packing Slips requires %sWooCommerce%s to be installed & activated!' , 'wpo_wcpdf' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">', '</a>' );
|
154 |
+
|
155 |
+
$message = '<div class="error"><p>' . $error . '</p></div>';
|
156 |
+
|
157 |
+
echo $message;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* PHP version requirement notice
|
162 |
+
*/
|
163 |
+
|
164 |
+
public function required_php_version() {
|
165 |
+
$error = __( 'WooCommerce PDF Invoices & Packing Slips requires PHP 5.3 or higher (5.6 or higher recommended).', 'wpo_wcpdf' );
|
166 |
+
$how_to_update = __( 'How to update your PHP version', 'wpo_wcpdf' );
|
167 |
+
$message = sprintf('<div class="error"><p>%s</p><p><a href="%s">%s</a></p></div>', $error, 'http://docs.wpovernight.com/general/how-to-update-your-php-version/', $how_to_update);
|
168 |
+
|
169 |
+
echo $message;
|
170 |
+
}
|
171 |
+
|
172 |
+
/** Lifecycle methods *******************************************************
|
173 |
+
* Because register_activation_hook only runs when the plugin is manually
|
174 |
+
* activated by the user, we're checking the current version against the
|
175 |
+
* version stored in the database
|
176 |
+
****************************************************************************/
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Handles version checking
|
180 |
+
*/
|
181 |
+
public function do_install() {
|
182 |
+
// only install when woocommerce is active and PHP version 5.3 or higher
|
183 |
+
if ( !$this->is_woocommerce_activated() || version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
|
187 |
+
$version_setting = 'wpo_wcpdf_version';
|
188 |
+
$installed_version = get_option( $version_setting );
|
189 |
+
|
190 |
+
// installed version lower than plugin version?
|
191 |
+
if ( version_compare( $installed_version, self::$version, '<' ) ) {
|
192 |
+
|
193 |
+
if ( ! $installed_version ) {
|
194 |
+
$this->install();
|
195 |
+
} else {
|
196 |
+
$this->upgrade( $installed_version );
|
197 |
+
}
|
198 |
+
|
199 |
+
// new version number
|
200 |
+
update_option( $version_setting, self::$version );
|
201 |
+
} elseif ( $installed_version && version_compare( $installed_version, self::$version, '>' ) ) {
|
202 |
+
$this->downgrade( $installed_version );
|
203 |
+
// downgrade version number
|
204 |
+
update_option( $version_setting, self::$version );
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Plugin install method. Perform any installation tasks here
|
211 |
+
*/
|
212 |
+
protected function install() {
|
213 |
+
// Create temp folders
|
214 |
+
$tmp_base = $this->export->get_tmp_base();
|
215 |
+
|
216 |
+
// check if tmp folder exists => if not, initialize
|
217 |
+
if ( !@is_dir( $tmp_base ) ) {
|
218 |
+
$this->export->init_tmp( $tmp_base );
|
219 |
+
}
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Plugin upgrade method. Perform any required upgrades here
|
226 |
+
*
|
227 |
+
* @param string $installed_version the currently installed version
|
228 |
+
*/
|
229 |
+
protected function upgrade( $installed_version ) {
|
230 |
+
if ( $installed_version == 'versionless') { // versionless = 1.4.14 and older
|
231 |
+
// We're upgrading from an old version, so we're enabling the option to use the plugin tmp folder.
|
232 |
+
// This is not per se the 'best' solution, but the good thing is that nothing is changed
|
233 |
+
// and nothing will be broken (that wasn't broken before)
|
234 |
+
$default = array( 'old_tmp' => 1 );
|
235 |
+
update_option( 'wpo_wcpdf_debug_settings', $default );
|
236 |
+
}
|
237 |
+
|
238 |
+
// sync fonts on every upgrade!
|
239 |
+
$debug_settings = get_option( 'wpo_wcpdf_debug_settings' ); // get temp setting
|
240 |
+
|
241 |
+
// do not copy if old_tmp function active! (double check for slow databases)
|
242 |
+
if ( !( isset($debug_settings['old_tmp']) || $installed_version == 'versionless' ) ) {
|
243 |
+
$tmp_base = $this->export->get_tmp_base();
|
244 |
+
|
245 |
+
// check if tmp folder exists => if not, initialize
|
246 |
+
if ( !@is_dir( $tmp_base ) ) {
|
247 |
+
$this->export->init_tmp( $tmp_base );
|
248 |
+
}
|
249 |
+
|
250 |
+
$font_path = $tmp_base . 'fonts/';
|
251 |
+
$this->export->copy_fonts( $font_path );
|
252 |
+
}
|
253 |
+
|
254 |
+
// 1.5.28 update: copy next invoice number to separate setting
|
255 |
+
if ( $installed_version == 'versionless' || version_compare( $installed_version, '1.5.28', '<' ) ) {
|
256 |
+
$template_settings = get_option( 'wpo_wcpdf_template_settings' );
|
257 |
+
$next_invoice_number = isset($template_settings['next_invoice_number'])?$template_settings['next_invoice_number']:'';
|
258 |
+
update_option( 'wpo_wcpdf_next_invoice_number', $next_invoice_number );
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Plugin downgrade method. Perform any required downgrades here
|
264 |
+
*
|
265 |
+
* @param string $installed_version the currently installed ('old') version (actually higher since this is a downgrade)
|
266 |
+
*/
|
267 |
+
protected function downgrade( $installed_version ) {
|
268 |
+
// sync fonts on downgrade, fixing incompatibility with 2.0
|
269 |
+
$debug_settings = get_option( 'wpo_wcpdf_debug_settings' ); // get temp setting
|
270 |
+
|
271 |
+
// do not copy if old_tmp function active! (double check for slow databases)
|
272 |
+
if ( !isset($debug_settings['old_tmp']) ) {
|
273 |
+
$tmp_base = $this->export->get_tmp_base();
|
274 |
+
|
275 |
+
// check if tmp folder exists => if not, initialize
|
276 |
+
if ( !@is_dir( $tmp_base ) ) {
|
277 |
+
$this->export->init_tmp( $tmp_base );
|
278 |
+
}
|
279 |
+
|
280 |
+
$font_path = $tmp_base . 'fonts/';
|
281 |
+
$this->export->copy_fonts( $font_path );
|
282 |
+
}
|
283 |
+
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Show plugin changes. Code adapted from W3 Total Cache.
|
288 |
+
*/
|
289 |
+
public function in_plugin_update_message( $args ) {
|
290 |
+
$transient_name = 'wpo_wcpdf_upgrade_notice_' . $args['Version'];
|
291 |
+
if ( false === ( $upgrade_notice = get_transient( $transient_name ) ) ) {
|
292 |
+
$response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/woocommerce-pdf-invoices-packing-slips/trunk/readme.txt' );
|
293 |
+
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
|
294 |
+
$upgrade_notice = self::parse_update_notice( $response['body'], $args['new_version'] );
|
295 |
+
set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
|
296 |
+
}
|
297 |
+
}
|
298 |
+
echo wp_kses_post( $upgrade_notice );
|
299 |
+
}
|
300 |
+
/**
|
301 |
+
* Parse update notice from readme file.
|
302 |
+
*
|
303 |
+
* @param string $content
|
304 |
+
* @param string $new_version
|
305 |
+
* @return string
|
306 |
+
*/
|
307 |
+
private function parse_update_notice( $content, $new_version ) {
|
308 |
+
// Output Upgrade Notice.
|
309 |
+
$matches = null;
|
310 |
+
$regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
|
311 |
+
$upgrade_notice = '';
|
312 |
+
if ( preg_match( $regexp, $content, $matches ) ) {
|
313 |
+
$notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
|
314 |
+
// Convert the full version strings to minor versions.
|
315 |
+
$notice_version_parts = explode( '.', trim( $matches[1] ) );
|
316 |
+
$current_version_parts = explode( '.', self::$version );
|
317 |
+
if ( 3 !== sizeof( $notice_version_parts ) ) {
|
318 |
+
return;
|
319 |
+
}
|
320 |
+
$notice_version = $notice_version_parts[0] . '.' . $notice_version_parts[1];
|
321 |
+
$current_version = $current_version_parts[0] . '.' . $current_version_parts[1];
|
322 |
+
// Check the latest stable version and ignore trunk.
|
323 |
+
if ( version_compare( $current_version, $notice_version, '<' ) ) {
|
324 |
+
$upgrade_notice .= '</p><p class="wpo_wcpdf_upgrade_notice">';
|
325 |
+
foreach ( $notices as $index => $line ) {
|
326 |
+
$upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
|
327 |
+
}
|
328 |
+
}
|
329 |
+
}
|
330 |
+
return wp_kses_post( $upgrade_notice );
|
331 |
+
}
|
332 |
+
|
333 |
+
/***********************************************************************/
|
334 |
+
/********************** GENERAL TEMPLATE FUNCTIONS *********************/
|
335 |
+
/***********************************************************************/
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Get template name from slug
|
339 |
+
*/
|
340 |
+
public function get_template_name ( $template_type ) {
|
341 |
+
return $this->functions->get_template_name( $template_type );
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Output template styles
|
346 |
+
*/
|
347 |
+
public function template_styles() {
|
348 |
+
$this->functions->template_styles();
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Return logo id
|
353 |
+
*/
|
354 |
+
public function get_header_logo_id() {
|
355 |
+
return $this->functions->get_header_logo_id();
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Show logo html
|
360 |
+
*/
|
361 |
+
public function header_logo() {
|
362 |
+
$this->functions->header_logo();
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Return/Show custom company name or default to blog name
|
367 |
+
*/
|
368 |
+
public function get_shop_name() {
|
369 |
+
return $this->functions->get_shop_name();
|
370 |
+
}
|
371 |
+
public function shop_name() {
|
372 |
+
$this->functions->shop_name();
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Return/Show shop/company address if provided
|
377 |
+
*/
|
378 |
+
public function get_shop_address() {
|
379 |
+
return $this->functions->get_shop_address();
|
380 |
+
}
|
381 |
+
public function shop_address() {
|
382 |
+
$this->functions->shop_address();
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Check if billing address and shipping address are equal
|
387 |
+
*/
|
388 |
+
public function ships_to_different_address() {
|
389 |
+
return $this->functions->ships_to_different_address();
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Return/Show billing address
|
394 |
+
*/
|
395 |
+
public function get_billing_address() {
|
396 |
+
return $this->functions->get_billing_address();
|
397 |
+
}
|
398 |
+
public function billing_address() {
|
399 |
+
$this->functions->billing_address();
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Return/Show billing email
|
404 |
+
*/
|
405 |
+
public function get_billing_email() {
|
406 |
+
return $this->functions->get_billing_email();
|
407 |
+
}
|
408 |
+
public function billing_email() {
|
409 |
+
$this->functions->billing_email();
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Return/Show billing phone
|
414 |
+
*/
|
415 |
+
public function get_billing_phone() {
|
416 |
+
return $this->functions->get_billing_phone();
|
417 |
+
}
|
418 |
+
public function billing_phone() {
|
419 |
+
$this->functions->billing_phone();
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Return/Show shipping address
|
424 |
+
*/
|
425 |
+
public function get_shipping_address() {
|
426 |
+
return $this->functions->get_shipping_address();
|
427 |
+
}
|
428 |
+
public function shipping_address() {
|
429 |
+
$this->functions->shipping_address();
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Return/Show a custom field
|
434 |
+
*/
|
435 |
+
public function get_custom_field( $field_name ) {
|
436 |
+
return $this->functions->get_custom_field( $field_name );
|
437 |
+
}
|
438 |
+
public function custom_field( $field_name, $field_label = '', $display_empty = false ) {
|
439 |
+
$this->functions->custom_field( $field_name, $field_label, $display_empty );
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Return/Show order notes
|
444 |
+
*/
|
445 |
+
public function get_order_notes( $filter = 'customer' ) {
|
446 |
+
return $this->functions->get_order_notes( $filter );
|
447 |
+
}
|
448 |
+
public function order_notes( $filter = 'customer' ) {
|
449 |
+
$this->functions->order_notes( $filter );
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Return/Show the current date
|
454 |
+
*/
|
455 |
+
public function get_current_date() {
|
456 |
+
return $this->functions->get_current_date();
|
457 |
+
}
|
458 |
+
public function current_date() {
|
459 |
+
$this->functions->current_date();
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Return/Show payment method
|
464 |
+
*/
|
465 |
+
public function get_payment_method() {
|
466 |
+
return $this->functions->get_payment_method();
|
467 |
+
}
|
468 |
+
public function payment_method() {
|
469 |
+
$this->functions->payment_method();
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Return/Show shipping method
|
474 |
+
*/
|
475 |
+
public function get_shipping_method() {
|
476 |
+
return $this->functions->get_shipping_method();
|
477 |
+
}
|
478 |
+
public function shipping_method() {
|
479 |
+
$this->functions->shipping_method();
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Return/Show order number
|
484 |
+
*/
|
485 |
+
public function get_order_number() {
|
486 |
+
return $this->functions->get_order_number();
|
487 |
+
}
|
488 |
+
public function order_number() {
|
489 |
+
$this->functions->order_number();
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* Return/Show invoice number
|
494 |
+
*/
|
495 |
+
public function get_invoice_number() {
|
496 |
+
return $this->functions->get_invoice_number();
|
497 |
+
}
|
498 |
+
public function invoice_number() {
|
499 |
+
$this->functions->invoice_number();
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Return/Show the order date
|
504 |
+
*/
|
505 |
+
public function get_order_date() {
|
506 |
+
return $this->functions->get_order_date();
|
507 |
+
}
|
508 |
+
public function order_date() {
|
509 |
+
$this->functions->order_date();
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Return/Show the invoice date
|
514 |
+
*/
|
515 |
+
public function get_invoice_date() {
|
516 |
+
return $this->functions->get_invoice_date();
|
517 |
+
}
|
518 |
+
public function invoice_date() {
|
519 |
+
$this->functions->invoice_date();
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Return the order items
|
524 |
+
*/
|
525 |
+
public function get_order_items() {
|
526 |
+
return $this->functions->get_order_items();
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Return/show product attribute
|
531 |
+
*/
|
532 |
+
public function get_product_attribute( $attribute_name, $product ) {
|
533 |
+
return $this->functions->get_product_attribute( $attribute_name, $product );
|
534 |
+
}
|
535 |
+
public function product_attribute( $attribute_name, $product ) {
|
536 |
+
$this->functions->product_attribute( $attribute_name, $product );
|
537 |
+
}
|
538 |
+
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Return the order totals listing
|
542 |
+
*/
|
543 |
+
public function get_woocommerce_totals() {
|
544 |
+
return $this->functions->get_woocommerce_totals();
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Return/show the order subtotal
|
549 |
+
*/
|
550 |
+
public function get_order_subtotal( $tax = 'excl', $discount = 'incl' ) { // set $tax to 'incl' to include tax, same for $discount
|
551 |
+
return $this->functions->get_order_subtotal( $tax, $discount );
|
552 |
+
}
|
553 |
+
public function order_subtotal( $tax = 'excl', $discount = 'incl' ) {
|
554 |
+
$this->functions->order_subtotal( $tax, $discount );
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Return/show the order shipping costs
|
559 |
+
*/
|
560 |
+
public function get_order_shipping( $tax = 'excl' ) { // set $tax to 'incl' to include tax
|
561 |
+
return $this->functions->get_order_shipping( $tax );
|
562 |
+
}
|
563 |
+
public function order_shipping( $tax = 'excl' ) {
|
564 |
+
$this->functions->order_shipping( $tax );
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Return/show the total discount
|
569 |
+
*/
|
570 |
+
public function get_order_discount( $type = 'total', $tax = 'incl' ) {
|
571 |
+
return $this->functions->get_order_discount( $type, $tax );
|
572 |
+
}
|
573 |
+
public function order_discount( $type = 'total', $tax = 'incl' ) {
|
574 |
+
$this->functions->order_discount( $type, $tax );
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Return the order fees
|
579 |
+
*/
|
580 |
+
public function get_order_fees( $tax = 'excl' ) {
|
581 |
+
return $this->functions->get_order_fees( $tax );
|
582 |
+
}
|
583 |
+
|
584 |
+
/**
|
585 |
+
* Return the order taxes
|
586 |
+
*/
|
587 |
+
public function get_order_taxes() {
|
588 |
+
return $this->functions->get_order_taxes();
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Return/show the order grand total
|
593 |
+
*/
|
594 |
+
public function get_order_grand_total( $tax = 'incl' ) {
|
595 |
+
return $this->functions->get_order_grand_total( $tax );
|
596 |
+
}
|
597 |
+
public function order_grand_total( $tax = 'incl' ) {
|
598 |
+
$this->functions->order_grand_total( $tax );
|
599 |
+
}
|
600 |
+
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Return/Show shipping notes
|
604 |
+
*/
|
605 |
+
public function get_shipping_notes() {
|
606 |
+
return $this->functions->get_shipping_notes();
|
607 |
+
}
|
608 |
+
public function shipping_notes() {
|
609 |
+
$this->functions->shipping_notes();
|
610 |
+
}
|
611 |
+
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Return/Show shop/company footer imprint, copyright etc.
|
615 |
+
*/
|
616 |
+
public function get_footer() {
|
617 |
+
return $this->functions->get_footer();
|
618 |
+
}
|
619 |
+
public function footer() {
|
620 |
+
$this->functions->footer();
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Return/Show Extra field 1
|
625 |
+
*/
|
626 |
+
public function get_extra_1() {
|
627 |
+
return $this->functions->get_extra_1();
|
628 |
+
}
|
629 |
+
public function extra_1() {
|
630 |
+
$this->functions->extra_1();
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Return/Show Extra field 2
|
635 |
+
*/
|
636 |
+
public function get_extra_2() {
|
637 |
+
return $this->functions->get_extra_2();
|
638 |
+
}
|
639 |
+
public function extra_2() {
|
640 |
+
$this->functions->extra_2();
|
641 |
+
}
|
642 |
+
|
643 |
+
/**
|
644 |
+
* Return/Show Extra field 3
|
645 |
+
*/
|
646 |
+
public function get_extra_3() {
|
647 |
+
return $this->functions->get_extra_3();
|
648 |
+
}
|
649 |
+
public function extra_3() {
|
650 |
+
$this->functions->extra_3();
|
651 |
+
}
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Returns the main instance of WooCommerce PDF Invoices & Packing Slips to prevent the need to use globals.
|
657 |
+
*
|
658 |
+
* @since 1.6
|
659 |
+
* @return WPO_WCPDF
|
660 |
+
*/
|
661 |
+
function WPO_WCPDF() {
|
662 |
+
return WooCommerce_PDF_Invoices::instance();
|
663 |
+
}
|
664 |
+
|
665 |
+
// Global for backwards compatibility.
|
666 |
$GLOBALS['wpo_wcpdf'] = WPO_WCPDF();
|