Booster for WooCommerce - Version 1.3.0

Version Description

  • 25/08/2014 =
  • Feature Upgraded - PDF Invoices - Major upgrade: single item price, item and line taxes, payment and shipping methods, additional footer, font size, custom css added.
Download this release

Release Info

Developer algoritmika
Plugin Icon 128x128 Booster for WooCommerce
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.0 to 1.3.0

includes/class-wcj-pdf-invoices.php CHANGED
@@ -4,42 +4,53 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices class.
6
  *
7
- * @class WCJ_PDF_Invoices
 
 
 
8
  */
 
9
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
-
11
  if ( ! class_exists( 'WCJ_PDF_Invoices' ) ) :
12
-
13
  class WCJ_PDF_Invoices {
14
-
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * Constructor.
17
  */
18
  public function __construct() {
19
-
20
  // Main hooks
21
  if ( get_option( 'wcj_pdf_invoices_enabled' ) == 'yes' ) {
22
-
23
  add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_link_to_order_list' ), 100, 2 );
24
-
25
  add_action( 'init', array( $this, 'generate_pdf' ), 10 );
26
- //wp_ajax_
27
-
28
- add_action( 'admin_head', array( $this, 'add_custom_css' ) );
29
-
30
- if ( get_option( 'wcj_pdf_invoices_enabled_for_customers' ) == 'yes' )
31
  add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'add_pdf_invoices_link_to_my_account' ), 100, 2 );
32
  //add_filter( apply_filters( 'wcj_get_option_filter', 'wcj_empty_filter', 'woocommerce_my_account_my_orders_actions' ), array( $this, 'add_pdf_invoices_link_to_my_account' ), 100, 2 );
33
  }
34
-
35
- //$this->generate_pdf();
36
-
37
  // Settings hooks
38
  add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
39
  add_filter( 'wcj_settings_pdf_invoices', array( $this, 'get_settings' ), 100 );
40
  add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
41
  }
42
-
43
  /**
44
  * Unlocks - PDF Invoices - add_pdf_invoices_link_to_my_account.
45
  */
@@ -51,33 +62,31 @@ class WCJ_PDF_Invoices {
51
  );
52
 
53
  return $actions;
54
- }
55
-
56
  /**
57
- * add_custom_css.
58
  */
59
- function add_custom_css() {
60
-
61
  echo '<style> a.button.tips.view.pdf_invoice:after { content: "\e028" !important; } </style>';
62
  //echo '<style> a.button.tips.view.save_pdf_invoice:after { content: "\e028" !important; } </style>';
63
  }
64
-
65
  /**
66
  * generate_pdf.
67
  */
68
  public function generate_pdf() {
69
-
70
  if ( ! isset( $_GET['pdf_invoice'] ) ) return;
71
 
72
  if ( ! is_user_logged_in() ) return;
73
-
74
  $order_id = $_GET['pdf_invoice'];
75
- $the_order = new WC_Order( $order_id );
76
- $the_items = $the_order->get_items();
77
 
78
  if ( ( ! current_user_can( 'administrator' ) ) && ( get_current_user_id() != intval( get_post_meta( $order_id, '_customer_user', true ) ) ) ) return;
79
-
80
- // Include the main TCPDF library (search for installation path).
81
  //require_once('tcpdf_include.php');
82
  require_once( 'tcpdf_min/tcpdf.php' );
83
 
@@ -133,7 +142,7 @@ class WCJ_PDF_Invoices {
133
  // dejavusans is a UTF-8 Unicode font, if you only need to
134
  // print standard ASCII chars, you can use core fonts like
135
  // helvetica or times to reduce file size.
136
- $pdf->SetFont('dejavusans', '', 12, '', true);
137
 
138
  // Add a page
139
  // This method has several options, check the source code documentation for more information.
@@ -142,166 +151,263 @@ class WCJ_PDF_Invoices {
142
  // set text shadow effect
143
  $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
144
 
145
- $html = '<style>
146
- .custom_table { font-size: smaller; padding: 10px; width: 100%; }
147
- .custom_table td { border: 1px solid #F0F0F0; }
148
- .custom_table th { border: 1px solid #F0F0F0; font-weight: bold; font-size: small; }
149
- </style>';
150
-
151
- //$html .= print_r( $the_order , true );
152
-
153
- // HEADER TEXT (AND IF SET - LOGO) //
154
- if ( get_option( 'wcj_pdf_invoices_seller_logo_url' ) !== '' )
155
- //$html .= get_option( 'wcj_pdf_invoices_seller_logo_url' );
156
- $html .= '<p><img src="' . get_option( 'wcj_pdf_invoices_seller_logo_url' ) . '"><div style="text-align:right;color:gray;font-weight:bold;">' . get_option( 'wcj_pdf_invoices_header_text' ) . '</div></p>';
157
  else
158
- $html .= '<div style="text-align:right;color:gray;font-weight:bold;">' . get_option( 'wcj_pdf_invoices_header_text' ) . '</div>';
159
-
 
 
 
 
 
 
 
 
 
 
160
  $order_number = $the_order->get_order_number();
161
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  // NUMBER AND DATE //
163
- $html .= '<table><tbody>';
164
  $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_number_text' ) . '</td><td>' . $order_number . '</td></tr>';
165
  $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_date_text' ) . '</td><td>' . date( get_option('date_format') , strtotime( $the_order->order_date ) ) . '</td></tr>';
166
- $html .= '</tbody></table>';
167
-
 
 
 
 
 
168
  // SELLER AND BUYER INFO //
169
- $html .= '<p><table><tbody>';
 
170
  $html .= '<tr><td>';
171
  $html .= '<h2>' . get_option( 'wcj_pdf_invoices_seller_text' ) . '</h2>';
172
  $html .= str_replace( PHP_EOL, '<br>', get_option( 'wcj_pdf_invoices_seller_info' ) );
173
  $html .= '</td><td>';
174
  $html .= '<h2>' . get_option( 'wcj_pdf_invoices_buyer_text' ) . '</h2>';
175
- $html .= $the_order->get_formatted_billing_address();
176
- $html .= '</td></tr></tbody></table></p>';
177
-
178
- // ITEMS //
 
179
  $html .= '<h2>' . get_option( 'wcj_pdf_invoices_items_text' ) . '</h2>';
180
- $html .= '<table class="custom_table"><tbody>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  $html .= '<tr>';
182
- $html .= '<th style="width:10%;">' . get_option( 'wcj_pdf_invoices_column_nr_text' ) . '</th>';
183
- //if ( 0 != $the_order->get_line_tax( $item ) )
184
- if ( $the_order->get_total_tax() != 0 )
185
- $html .= '<th style="width:50%;">' . get_option( 'wcj_pdf_invoices_column_item_name_text' ) . '</th>';
186
- else
187
- $html .= '<th style="width:65%;">' . get_option( 'wcj_pdf_invoices_column_item_name_text' ) . '</th>';
188
- $html .= '<th style="width:10%;">' . get_option( 'wcj_pdf_invoices_column_qty_text' ) . '</th>';
189
- //if ( 0 !== $the_order->get_line_tax( $item ) )
190
- //if ( $the_order->get_line_tax( $item ) != 0 )
191
- if ( $the_order->get_total_tax() != 0 )
192
- $html .= '<th style="width:15%;">' . get_option( 'wcj_pdf_invoices_column_price_tax_excl_text' ) . '</th>';
193
- $html .= '<th style="width:15%;">' . get_option( 'wcj_pdf_invoices_column_price_text' ) . '</th>';
194
  $html .= '</tr>';
 
 
195
  $item_counter = 0;
196
  foreach ( $the_items as $item ) {
197
-
198
-
199
-
200
- $item_counter++;
201
-
202
- //$html .= '<li>';
203
- $html .= '<tr>';
204
-
205
- //$html .= '<td>' . $the_order->get_line_tax( $item ) . '</td>';
206
-
207
- $html .= '<td>' . $item_counter . '</td>';
208
-
209
- $html .= '<td>' . $item['name'];
210
-
211
- $product = $the_order->get_product_from_item( $item );
212
-
213
- //$html .= print_r($product , true );
214
-
215
- if ( isset ( $product->variation_data ) ) {
216
-
 
 
 
217
  foreach ( $product->variation_data as $key => $value ) {
218
-
219
  $taxonomy_name = str_replace( 'attribute_', '', $key );
220
  $taxonomy = get_taxonomy( $taxonomy_name );
221
  $term = get_term_by( 'slug', $value, $taxonomy_name );
222
- if ( isset( $term->name ) ) $html .= '<div style="font-size:x-small;">' . $taxonomy->label . ': ' . $term->name . '</div>';
 
 
 
 
 
 
 
 
 
 
223
  }
224
- }
225
- $html .= '</td>';
226
-
227
- $html .= '<td>' . $item['qty'] . '</td>';
228
- //if ( '' !== $the_order->get_formatted_line_subtotal( $item, 'excl' ) ) $html .= '<td>' . $the_order->get_formatted_line_subtotal( $item, 'excl' ) . '</td>';
229
- if ( $the_order->get_line_tax( $item ) != 0 )
230
- $html .= '<td style="text-align:right;">' . wc_price( $the_order->get_line_subtotal( $item ), array( 'currency' => $the_order->get_order_currency() ) ) . '</td>';
231
- $html .= '<td style="text-align:right;">' . $the_order->get_formatted_line_subtotal( $item, 'incl' ) . '</td>';
232
- //$html .= '</li>';
233
  $html .= '</tr>';
234
  }
235
- //$html .= '</ol>';
236
  $html .= '</tbody></table>';
237
-
238
-
239
- // ORDER TOTALS //
240
- //$html .= '<h3>Order total: ' . $the_order->get_formatted_order_total() . '</h3>';
241
- $html .= '<p><table style="font-size: smaller; padding: 10px; width: 100%;"><tbody>';
242
-
243
- // SUBTOTAL
244
- //$html .= '<tr><td colspan="3"></td><td style="border: 1px solid #F0F0F0;">' . get_option( 'wcj_pdf_invoices_order_subtotal_text' ) . '</td><td style="border: 1px solid #F0F0F0;">' . $the_order->get_subtotal_to_display( false, 'excl' ) . '</td></tr>';
245
- $subtotal = wc_price( ( $the_order->get_total() - $the_order->get_total_tax() - $the_order->get_total_shipping() - $the_order->get_total_discount() ), array( 'currency' => $the_order->get_order_currency() ) ); //$the_order->get_total_discount() $the_order->get_total_shipping()
246
- $html .= '<tr><td colspan="3"></td><td style="border: 1px solid #F0F0F0;">' . get_option( 'wcj_pdf_invoices_order_subtotal_text' ) . '</td><td style="border: 1px solid #F0F0F0; text-align:right;">' . $subtotal . '</td></tr>';
247
-
248
- // SHIPPING
249
- if ( $the_order->get_total_shipping() != 0 )
250
- $html .= '<tr><td colspan="3"></td><td style="border: 1px solid #F0F0F0;">' . get_option( 'wcj_pdf_invoices_order_shipping_text' ) . '</td><td style="border: 1px solid #F0F0F0; text-align:right;">' . wc_price( $the_order->get_total_shipping(), array( 'currency' => $the_order->get_order_currency() ) ) . '</td></tr>';
251
-
252
- // DISCOUNT
253
- if ( $the_order->get_total_discount() != 0 )
254
- $html .= '<tr><td colspan="3"></td><td style="border: 1px solid #F0F0F0;">' . get_option( 'wcj_pdf_invoices_order_discount_text' ) . '</td><td style="border: 1px solid #F0F0F0; text-align:right;">' . wc_price( $the_order->get_total_discount(), array( 'currency' => $the_order->get_order_currency() ) ) . '</td></tr>';
255
- //
256
-
257
- // TAXES
258
- foreach ( $the_order->get_tax_totals() as $tax_object )
259
- $html .= '<tr><td colspan="3"></td><td style="border: 1px solid #F0F0F0;">' . $tax_object->label . '</td><td style="border: 1px solid #F0F0F0; text-align:right;">' . $tax_object->formatted_amount . '</td></tr>';
260
-
261
- // TOTAL
262
- $html .= '<tr><td colspan="3"></td><td style="border: 1px solid #F0F0F0;">' . get_option( 'wcj_pdf_invoices_order_total_text' ) . '</td><td style="border: 1px solid #F0F0F0; text-align:right;">' . $the_order->get_formatted_order_total() . '</td></tr>';
263
-
264
- $html .= '</tbody></table></p>';
265
-
266
- // $html .= '<p>' . get_option( 'wcj_pdf_invoices_order_shipping_text' ) . ': ' . $the_order->get_shipping_to_display( 'incl' ) . '</p>';
267
-
268
- // $html .= '<p>' . wc_price( $the_order->get_total_shipping(), array( 'currency' => $the_order->get_order_currency() ) ) . '</p>';
269
-
270
- //$html .= print_r($the_order , true );
271
-
272
- //$html .= '</pre>';
273
 
274
 
275
- // Print text using writeHTMLCell()
276
- $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
- // ---------------------------------------------------------
 
 
 
 
 
 
 
279
 
280
- // Close and output PDF document
281
- // This method has several options, check the source code documentation for more information.
282
- if ( isset( $_GET['save_pdf_invoice'] ) && ( $_GET['save_pdf_invoice'] == '1' ) )
283
- $pdf->Output('invoice-' . $order_number . '.pdf', 'D');
284
- else
285
- $pdf->Output('invoice-' . $order_number . '.pdf', 'I');
286
- }
287
 
288
  /**
289
  * add_pdf_invoices_link_to_order_list.
290
  */
291
  public function add_pdf_invoices_link_to_order_list( $actions, $the_order ) {
292
-
293
  $actions['pdf_invoice'] = array(
294
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
295
  'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
296
  'action' => "view pdf_invoice"
297
  );
298
-
299
  /*$actions['save_pdf_invoice'] = array(
300
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
301
  'name' => __( 'Save PDF', 'woocommerce-jetpack' ),
302
  'action' => "view save_pdf_invoice"
303
  );*/
304
-
305
  return $actions;
306
  }
307
 
@@ -309,22 +415,22 @@ class WCJ_PDF_Invoices {
309
  * add_enabled_option.
310
  */
311
  public function add_enabled_option( $settings ) {
312
-
313
  $all_settings = $this->get_settings();
314
  $settings[] = $all_settings[1];
315
-
316
  return $settings;
317
  }
318
-
319
  /**
320
  * get_settings.
321
- */
322
  function get_settings() {
323
-
324
  $settings = array(
325
-
326
- array( 'title' => __( 'PDF Invoices Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'PDF Invoices.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_options' ),
327
-
328
  array(
329
  'title' => __( 'PDF Invoices', 'woocommerce-jetpack' ),
330
  'desc' => __( 'Enable the PDF Invoices feature', 'woocommerce-jetpack' ),
@@ -333,29 +439,34 @@ class WCJ_PDF_Invoices {
333
  'default' => 'yes',
334
  'type' => 'checkbox',
335
  ),
336
-
 
 
 
 
337
  array(
338
  'title' => __( 'Your Logo URL', 'woocommerce-jetpack' ),
339
  'desc' => __( 'Enter a URL to an image you want to show in the invoice\'s header. Upload your image using the <a href="/wp-admin/media-new.php">media uploader</a>.', 'woocommerce-jetpack' ),
340
- 'desc_tip' => __( 'Header image', 'woocommerce-jetpack' ),
341
  'id' => 'wcj_pdf_invoices_seller_logo_url',
342
  'default' => '',
343
  'type' => 'text',
344
  'css' => 'width:33%;min-width:300px;',
345
  ),
346
-
347
  array(
348
  'title' => __( 'Header Text', 'woocommerce-jetpack' ),
349
- 'desc_tip' => __( 'Header text', 'woocommerce-jetpack' ),
 
350
  'id' => 'wcj_pdf_invoices_header_text',
351
  'default' => __( 'INVOICE', 'woocommerce-jetpack' ),
352
  'type' => 'text',
353
  'css' => 'width:33%;min-width:300px;',
354
  ),
355
-
356
  array(
357
- 'title' => __( 'Invoice Number Text', 'woocommerce-jetpack' ),
358
- 'desc_tip' => __( 'Invoice number text', 'woocommerce-jetpack' ),
359
  'id' => 'wcj_pdf_invoices_invoice_number_text',
360
  'default' => __( 'Invoice number', 'woocommerce-jetpack' ),
361
  'type' => 'text',
@@ -363,53 +474,124 @@ class WCJ_PDF_Invoices {
363
  ),
364
 
365
  array(
366
- 'title' => __( 'Invoice Date Text', 'woocommerce-jetpack' ),
367
- 'desc_tip' => __( 'Invoice date text', 'woocommerce-jetpack' ),
368
  'id' => 'wcj_pdf_invoices_invoice_date_text',
369
  'default' => __( 'Invoice date', 'woocommerce-jetpack' ),
370
  'type' => 'text',
371
  'css' => 'width:33%;min-width:300px;',
372
- ),
373
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  array(
375
- 'title' => __( 'Seller Text', 'woocommerce-jetpack' ),
376
- 'desc_tip' => __( 'Seller text', 'woocommerce-jetpack' ),
377
  'id' => 'wcj_pdf_invoices_seller_text',
378
  'default' => __( 'Seller', 'woocommerce-jetpack' ),
379
  'type' => 'text',
380
  'css' => 'width:33%;min-width:300px;',
381
- ),
382
-
383
  array(
384
  'title' => __( 'Your business information', 'woocommerce-jetpack' ),
385
- 'desc_tip' => __( 'Seller information', 'woocommerce-jetpack' ),
 
386
  'id' => 'wcj_pdf_invoices_seller_info',
387
  'default' => __( '<strong>Company Name</strong>', 'woocommerce-jetpack' ),
388
  'type' => 'textarea',
389
  'css' => 'width:33%;min-width:300px;min-height:300px;',
390
- ),
391
-
392
  array(
393
- 'title' => __( 'Buyer Text', 'woocommerce-jetpack' ),
394
- 'desc_tip' => __( 'Buyer text', 'woocommerce-jetpack' ),
395
  'id' => 'wcj_pdf_invoices_buyer_text',
396
  'default' => __( 'Buyer', 'woocommerce-jetpack' ),
397
  'type' => 'text',
398
  'css' => 'width:33%;min-width:300px;',
399
  ),
400
-
 
 
 
 
401
  array(
402
- 'title' => __( 'Items Text', 'woocommerce-jetpack' ),
403
- 'desc_tip' => __( 'Items text', 'woocommerce-jetpack' ),
404
  'id' => 'wcj_pdf_invoices_items_text',
405
  'default' => __( 'Items', 'woocommerce-jetpack' ),
406
  'type' => 'text',
407
  'css' => 'width:33%;min-width:300px;',
408
- ),
 
 
 
 
409
 
410
  array(
411
- 'title' => __( 'Column - Nr. Text', 'woocommerce-jetpack' ),
412
- 'desc_tip' => __( 'Nr. text', 'woocommerce-jetpack' ),
413
  'id' => 'wcj_pdf_invoices_column_nr_text',
414
  'default' => __( 'Nr.', 'woocommerce-jetpack' ),
415
  'type' => 'text',
@@ -417,77 +599,194 @@ class WCJ_PDF_Invoices {
417
  ),
418
 
419
  array(
420
- 'title' => __( 'Column - Item Name Text', 'woocommerce-jetpack' ),
421
- 'desc_tip' => __( 'Item name text', 'woocommerce-jetpack' ),
422
  'id' => 'wcj_pdf_invoices_column_item_name_text',
423
  'default' => __( 'Item Name', 'woocommerce-jetpack' ),
424
  'type' => 'text',
425
  'css' => 'width:33%;min-width:300px;',
426
  ),
427
-
428
  array(
429
- 'title' => __( 'Column - Qty Text', 'woocommerce-jetpack' ),
430
- 'desc_tip' => __( 'Qty text', 'woocommerce-jetpack' ),
431
  'id' => 'wcj_pdf_invoices_column_qty_text',
432
  'default' => __( 'Qty', 'woocommerce-jetpack' ),
433
  'type' => 'text',
434
  'css' => 'width:33%;min-width:300px;',
435
  ),
436
-
437
  array(
438
- 'title' => __( 'Column - Sum (TAX excl.) Text', 'woocommerce-jetpack' ),
439
- 'desc_tip' => __( 'Price text', 'woocommerce-jetpack' ),
440
- 'id' => 'wcj_pdf_invoices_column_price_tax_excl_text',
441
  'default' => __( 'Price (TAX excl.)', 'woocommerce-jetpack' ),
442
  'type' => 'text',
443
  'css' => 'width:33%;min-width:300px;',
444
- ),
445
-
446
  array(
447
- 'title' => __( 'Column - Sum (TAX incl.) Text', 'woocommerce-jetpack' ),
448
- 'desc_tip' => __( 'Price text', 'woocommerce-jetpack' ),
449
- 'id' => 'wcj_pdf_invoices_column_price_text',
 
 
 
 
 
 
 
 
 
450
  'default' => __( 'Price (TAX incl.)', 'woocommerce-jetpack' ),
451
  'type' => 'text',
452
  'css' => 'width:33%;min-width:300px;',
453
- ),
454
 
455
  array(
456
- 'title' => __( 'Order Subtotal Text', 'woocommerce-jetpack' ),
457
- 'desc_tip' => __( 'Order Subtotal = Total - Taxes - Shipping - Discounts', 'woocommerce-jetpack' ),
458
- 'id' => 'wcj_pdf_invoices_order_subtotal_text',
459
- 'default' => __( 'Order Subtotal', 'woocommerce-jetpack' ),
460
  'type' => 'text',
461
  'css' => 'width:33%;min-width:300px;',
462
  ),
463
-
464
  array(
465
- 'title' => __( 'Order Shipping Text', 'woocommerce-jetpack' ),
466
- 'desc_tip' => __( 'Order Shipping text', 'woocommerce-jetpack' ),
467
- 'id' => 'wcj_pdf_invoices_order_shipping_text',
468
- 'default' => __( 'Shipping', 'woocommerce-jetpack' ),
469
  'type' => 'text',
470
  'css' => 'width:33%;min-width:300px;',
471
- ),
472
-
473
  array(
474
- 'title' => __( 'Total Discount Text', 'woocommerce-jetpack' ),
475
- 'desc_tip' => __( 'Total Discount text', 'woocommerce-jetpack' ),
476
- 'id' => 'wcj_pdf_invoices_order_discount_text',
477
- 'default' => __( 'Discount', 'woocommerce-jetpack' ),
478
  'type' => 'text',
479
  'css' => 'width:33%;min-width:300px;',
480
- ),
481
-
482
  array(
483
- 'title' => __( 'Order Total Text', 'woocommerce-jetpack' ),
484
- 'desc_tip' => __( 'Order Total text', 'woocommerce-jetpack' ),
485
- 'id' => 'wcj_pdf_invoices_order_total_text',
486
- 'default' => __( 'Order Total', 'woocommerce-jetpack' ),
487
  'type' => 'text',
488
  'css' => 'width:33%;min-width:300px;',
489
  ),
490
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  array(
492
  'title' => __( 'PDF Invoices for Customers', 'woocommerce-jetpack' ),
493
  'desc' => __( 'Enable the PDF Invoices in customers account', 'woocommerce-jetpack' ),
@@ -498,23 +797,24 @@ class WCJ_PDF_Invoices {
498
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
499
  ),
500
 
501
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_options' ),
 
502
  );
503
-
504
  return $settings;
505
  }
506
-
507
  /**
508
  * settings_section.
509
  */
510
  function settings_section( $sections ) {
511
-
512
  $sections['pdf_invoices'] = __( 'PDF Invoices', 'woocommerce-jetpack' );
513
-
514
  return $sections;
515
- }
516
  }
517
-
518
  endif;
519
-
520
  return new WCJ_PDF_Invoices();
4
  *
5
  * The WooCommerce Jetpack PDF Invoices class.
6
  *
7
+ * @class WCJ_PDF_Invoices
8
+ * @version 1.1.0
9
+ * @category Class
10
+ * @author Algoritmika Ltd.
11
  */
12
+
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
  if ( ! class_exists( 'WCJ_PDF_Invoices' ) ) :
16
+
17
  class WCJ_PDF_Invoices {
18
+
19
+ public $default_css =
20
+ '.pdf_invoice_header_text_wcj { text-align: right; color: gray; font-weight: bold; }
21
+ .pdf_invoice_number_and_date_table_wcj { width: 50%; }
22
+ .pdf_invoice_items_table_wcj { padding: 5px; width: 100%; }
23
+ .pdf_invoice_items_table_wcj th { border: 1px solid #F0F0F0; font-weight: bold; text-align: center; }
24
+ .pdf_invoice_items_table_wcj td { border: 1px solid #F0F0F0; }
25
+ .pdf_invoice_totals_table_wcj { padding: 5px; width: 100%; }
26
+ .pdf_invoice_totals_table_wcj th { width: 80%; text-align: right; }
27
+ .pdf_invoice_totals_table_wcj td { width: 20%; text-align: right; border: 1px solid #F0F0F0; }';
28
+
29
  /**
30
  * Constructor.
31
  */
32
  public function __construct() {
33
+
34
  // Main hooks
35
  if ( get_option( 'wcj_pdf_invoices_enabled' ) == 'yes' ) {
36
+
37
  add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_link_to_order_list' ), 100, 2 );
38
+
39
  add_action( 'init', array( $this, 'generate_pdf' ), 10 );
40
+
41
+ add_action( 'admin_head', array( $this, 'add_pdf_invoice_icon_css' ) );
42
+
43
+ if ( 'yes' === get_option( 'wcj_pdf_invoices_enabled_for_customers' ) )
 
44
  add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'add_pdf_invoices_link_to_my_account' ), 100, 2 );
45
  //add_filter( apply_filters( 'wcj_get_option_filter', 'wcj_empty_filter', 'woocommerce_my_account_my_orders_actions' ), array( $this, 'add_pdf_invoices_link_to_my_account' ), 100, 2 );
46
  }
47
+
 
 
48
  // Settings hooks
49
  add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
50
  add_filter( 'wcj_settings_pdf_invoices', array( $this, 'get_settings' ), 100 );
51
  add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
52
  }
53
+
54
  /**
55
  * Unlocks - PDF Invoices - add_pdf_invoices_link_to_my_account.
56
  */
62
  );
63
 
64
  return $actions;
65
+ }
66
+
67
  /**
68
+ * add_pdf_invoice_icon_css.
69
  */
70
+ function add_pdf_invoice_icon_css() {
71
+
72
  echo '<style> a.button.tips.view.pdf_invoice:after { content: "\e028" !important; } </style>';
73
  //echo '<style> a.button.tips.view.save_pdf_invoice:after { content: "\e028" !important; } </style>';
74
  }
75
+
76
  /**
77
  * generate_pdf.
78
  */
79
  public function generate_pdf() {
80
+
81
  if ( ! isset( $_GET['pdf_invoice'] ) ) return;
82
 
83
  if ( ! is_user_logged_in() ) return;
84
+
85
  $order_id = $_GET['pdf_invoice'];
 
 
86
 
87
  if ( ( ! current_user_can( 'administrator' ) ) && ( get_current_user_id() != intval( get_post_meta( $order_id, '_customer_user', true ) ) ) ) return;
88
+
89
+ // Include the main TCPDF library (search for installation path).
90
  //require_once('tcpdf_include.php');
91
  require_once( 'tcpdf_min/tcpdf.php' );
92
 
142
  // dejavusans is a UTF-8 Unicode font, if you only need to
143
  // print standard ASCII chars, you can use core fonts like
144
  // helvetica or times to reduce file size.
145
+ $pdf->SetFont('dejavusans', '', apply_filters( 'wcj_get_option_filter', 8, get_option( 'wcj_pdf_invoices_general_font_size' ) ), '', true);
146
 
147
  // Add a page
148
  // This method has several options, check the source code documentation for more information.
151
  // set text shadow effect
152
  $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
153
 
154
+ $html = $this->get_invoice_html( $order_id );
155
+
156
+ // Print text using writeHTMLCell()
157
+ $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
158
+
159
+ // ---------------------------------------------------------
160
+
161
+ // Close and output PDF document
162
+ // This method has several options, check the source code documentation for more information.
163
+ if ( isset( $_GET['save_pdf_invoice'] ) && ( $_GET['save_pdf_invoice'] == '1' ) )
164
+ $pdf->Output('invoice-' . $order_number . '.pdf', 'D');
 
165
  else
166
+ $pdf->Output('invoice-' . $order_number . '.pdf', 'I');
167
+ }
168
+
169
+ /**
170
+ * get_invoice_html.
171
+ */
172
+ public function get_invoice_html( $order_id ) {
173
+
174
+ // PREPARING DATA //
175
+ // General
176
+ $the_order = new WC_Order( $order_id );
177
+ $the_items = $the_order->get_items();
178
  $order_number = $the_order->get_order_number();
179
+ $order_currency_array = array( 'currency' => $the_order->get_order_currency() );
180
+ // Getting Totals
181
+ $order_total = $the_order->get_total();
182
+ $order_total_tax = $the_order->get_total_tax();
183
+ $order_total_shipping = $the_order->get_total_shipping();
184
+ $order_total_discount = $the_order->get_total_discount();
185
+ $order_subtotal = $order_total - $order_total_tax - $order_total_shipping + $order_total_discount;
186
+
187
+ $billing_address_formatted = $the_order->get_formatted_billing_address();
188
+
189
+ // Count optional columns number for column width calculation
190
+ $total_optional_columns = 0;
191
+ if ( '' != get_option( 'wcj_pdf_invoices_column_single_price_tax_excl_text' ) ) $total_optional_columns++;
192
+ if ( '' != get_option( 'wcj_pdf_invoices_column_single_price_tax_text' ) ) $total_optional_columns++;
193
+ if ( '' != get_option( 'wcj_pdf_invoices_column_single_price_tax_incl_text' ) ) $total_optional_columns++;
194
+ if ( '' != get_option( 'wcj_pdf_invoices_column_price_tax_excl_text' ) ) $total_optional_columns++;
195
+ if ( '' != get_option( 'wcj_pdf_invoices_column_price_tax_percent' ) ) $total_optional_columns++;
196
+ if ( '' != get_option( 'wcj_pdf_invoices_column_price_tax_text' ) ) $total_optional_columns++;
197
+ $price_column_width = 50 / ( 1 + $total_optional_columns );
198
+
199
+
200
+ // Starting output
201
+ // Css
202
+ $html = '<style>' . apply_filters( 'wcj_get_option_filter', $this->default_css, get_option( 'wcj_pdf_invoices_general_css' ) ) . '</style>';
203
+
204
+ // HEADER //
205
+ // TEXT AND LOGO //
206
+ $html .= '<p>';
207
+ if ( '' != get_option( 'wcj_pdf_invoices_seller_logo_url' ) )
208
+ $html .= '<img src="' . get_option( 'wcj_pdf_invoices_seller_logo_url' ) . '">';
209
+ $html .= '<div class="pdf_invoice_header_text_wcj">' . get_option( 'wcj_pdf_invoices_header_text' ) . '</div>';
210
  // NUMBER AND DATE //
211
+ $html .= '<table class="pdf_invoice_number_and_date_table_wcj"><tbody>';
212
  $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_number_text' ) . '</td><td>' . $order_number . '</td></tr>';
213
  $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_date_text' ) . '</td><td>' . date( get_option('date_format') , strtotime( $the_order->order_date ) ) . '</td></tr>';
214
+ if ( '' != get_option( 'wcj_pdf_invoices_invoice_due_date_text' ) )
215
+ $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_due_date_text' ) . '</td><td>' . date( get_option('date_format') , ( strtotime( $the_order->order_date ) + get_option( 'wcj_pdf_invoices_invoice_due_date_days' ) * 24 * 60 *60 ) ) . '</td></tr>';
216
+ if ( '' != get_option( 'wcj_pdf_invoices_invoice_fulfillment_date_text' ) )
217
+ $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_fulfillment_date_text' ) . '</td><td>' . date( get_option('date_format') , ( strtotime( $the_order->order_date ) + get_option( 'wcj_pdf_invoices_invoice_fulfillment_date_days' ) * 24 * 60 *60 ) ) . '</td></tr>';
218
+ $html .= '</tbody></table>';
219
+ $html .= '</p>';
220
+
221
  // SELLER AND BUYER INFO //
222
+ $html .= '<p>';
223
+ $html .= '<table class="pdf_invoice_seller_and_buyer_table_wcj"><tbody>';
224
  $html .= '<tr><td>';
225
  $html .= '<h2>' . get_option( 'wcj_pdf_invoices_seller_text' ) . '</h2>';
226
  $html .= str_replace( PHP_EOL, '<br>', get_option( 'wcj_pdf_invoices_seller_info' ) );
227
  $html .= '</td><td>';
228
  $html .= '<h2>' . get_option( 'wcj_pdf_invoices_buyer_text' ) . '</h2>';
229
+ $html .= $billing_address_formatted;
230
+ $html .= '</td></tr></tbody></table>';
231
+ $html .= '</p>';
232
+
233
+ // ITEMS HEADER //
234
  $html .= '<h2>' . get_option( 'wcj_pdf_invoices_items_text' ) . '</h2>';
235
+ $html .= '<table class="pdf_invoice_items_table_wcj"><tbody>';
236
+
237
+ // Columns array //
238
+ // - if required == false (i.e. optional), then title != '' will be checked
239
+ $columns = array(
240
+ array(
241
+ //'name' => 'item-counter',
242
+ 'title' => get_option( 'wcj_pdf_invoices_column_nr_text' ),
243
+ 'css' => 'width:7%;',
244
+ 'required' => true,
245
+ 'value_var' => 'item_counter',
246
+ 'td_css' => 'text-align:center;',
247
+ ),
248
+ array(
249
+ 'title' => get_option( 'wcj_pdf_invoices_column_item_name_text' ),
250
+ 'css' => 'width:36%;',
251
+ 'required' => true,
252
+ 'value_var' => 'item_name',
253
+ ),
254
+ array(
255
+ 'title' => get_option( 'wcj_pdf_invoices_column_qty_text' ),
256
+ 'css' => 'width:7%;',
257
+ 'required' => true,
258
+ 'value_var' => 'item_quantity',
259
+ 'td_css' => 'text-align:center;',
260
+ ),
261
+ array(
262
+ 'title' => get_option( 'wcj_pdf_invoices_column_single_price_tax_excl_text' ),
263
+ 'css' => 'width:' . $price_column_width . '%;',
264
+ 'required' => false,
265
+ 'value_var' => 'item_total_excl_tax_formatted',
266
+ 'td_css' => 'text-align:right;',
267
+ ),
268
+ array(
269
+ 'title' => get_option( 'wcj_pdf_invoices_column_single_price_tax_text' ),
270
+ 'css' => 'width:' . $price_column_width . '%;',
271
+ 'required' => false,
272
+ 'value_var' => 'item_total_tax_formatted',
273
+ 'td_css' => 'text-align:right;',
274
+ ),
275
+ array(
276
+ 'title' => get_option( 'wcj_pdf_invoices_column_single_price_tax_incl_text' ),
277
+ 'css' => 'width:' . $price_column_width . '%;',
278
+ 'required' => false,
279
+ 'value_var' => 'item_total_incl_tax_formatted',
280
+ 'td_css' => 'text-align:right;',
281
+ ),
282
+ array(
283
+ 'title' => get_option( 'wcj_pdf_invoices_column_price_tax_excl_text' ),
284
+ 'css' => 'width:' . $price_column_width . '%;',
285
+ 'required' => false,
286
+ 'value_var' => 'line_total_excl_tax_formatted',
287
+ 'td_css' => 'text-align:right;',
288
+ ),
289
+ array(
290
+ 'title' => get_option( 'wcj_pdf_invoices_column_price_tax_percent' ),
291
+ 'css' => 'width:' . $price_column_width . '%;',
292
+ 'required' => false,
293
+ 'value_var' => 'line_total_tax_percent',
294
+ 'td_css' => 'text-align:right;',
295
+ ),
296
+ array(
297
+ 'title' => get_option( 'wcj_pdf_invoices_column_price_tax_text' ),
298
+ 'css' => 'width:' . $price_column_width . '%;',
299
+ 'required' => false,
300
+ 'value_var' => 'line_total_tax',
301
+ 'td_css' => 'text-align:right;',
302
+ ),
303
+ array(
304
+ 'title' => get_option( 'wcj_pdf_invoices_column_price_text' ),
305
+ 'css' => 'width:' . $price_column_width . '%;',
306
+ 'required' => true,
307
+ 'value_var' => 'line_total_incl_tax_formatted',
308
+ 'td_css' => 'text-align:right;',
309
+ ),
310
+ );
311
+ // Adding to output //
312
  $html .= '<tr>';
313
+ foreach ( $columns as $column )
314
+ if ( ( true === $column['required'] ) || ( '' != $column['title'] ) )
315
+ $html .= '<th style="' . $column['css'] . '">' . $column['title'] . '</th>';
 
 
 
 
 
 
 
 
 
316
  $html .= '</tr>';
317
+
318
+ // ITEMS LOOP //
319
  $item_counter = 0;
320
  foreach ( $the_items as $item ) {
321
+
322
+ // Preparing data //
323
+ // Item Prices
324
+ $item_total_excl_tax = $the_order->get_item_total( $item, false, true );
325
+ $item_tax = $the_order->get_item_tax( $item, true );
326
+ $item_total_incl_tax = $the_order->get_item_total( $item, true, true );
327
+ $item_total_excl_tax_formatted = wc_price( $item_total_excl_tax, $order_currency_array );
328
+ $item_tax_formatted = wc_price( $item_tax, $order_currency_array );
329
+ $item_total_incl_tax_formatted = wc_price( $item_total_incl_tax, $order_currency_array );
330
+ // Line Prices
331
+ $line_total_excl_tax = $the_order->get_line_total( $item, false );//$the_order->get_line_subtotal( $item, false, true );//$item['line_subtotal'];//$item['line_total'];
332
+ $line_tax = $the_order->get_line_tax( $item );//$item['line_tax'];
333
+ $line_tax_percent = round( ( $item['line_tax'] / $item['line_subtotal'] * 100 ), 2 );
334
+ $line_total_incl_tax = $the_order->get_line_total( $item, true );//$line_total_excl_tax + $line_tax;
335
+ $line_total_excl_tax_formatted = wc_price( $line_total_excl_tax, $order_currency_array );
336
+ $line_tax_formatted = wc_price( $line_tax, $order_currency_array );
337
+ $line_total_incl_tax_formatted = wc_price( $line_total_incl_tax, $order_currency_array );
338
+ // Item Quantity
339
+ $item_quantity = $item['qty'];
340
+ // Item Name
341
+ $item_name = $item['name'];
342
+ $product = $the_order->get_product_from_item( $item ); // variation (if needed)
343
+ if ( isset ( $product->variation_data ) ) {
344
  foreach ( $product->variation_data as $key => $value ) {
 
345
  $taxonomy_name = str_replace( 'attribute_', '', $key );
346
  $taxonomy = get_taxonomy( $taxonomy_name );
347
  $term = get_term_by( 'slug', $value, $taxonomy_name );
348
+ if ( isset( $term->name ) ) $item_name .= '<div style="font-size:x-small;">' . $taxonomy->label . ': ' . $term->name . '</div>';
349
+ }
350
+ }
351
+ // Item Counter
352
+ $item_counter++;
353
+
354
+ // Adding to output //
355
+ $html .= '<tr>';
356
+ foreach ( $columns as $column )
357
+ if ( ( true === $column['required'] ) || ( '' != $column['title'] ) ) {
358
+ $html .= '<td style="' . $column['td_css'] . '">' . $$column['value_var'] . '</td>';
359
  }
 
 
 
 
 
 
 
 
 
360
  $html .= '</tr>';
361
  }
 
362
  $html .= '</tbody></table>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
 
364
 
365
+ // ORDER TOTALS //
366
+ $html .= '<p><table class="pdf_invoice_totals_table_wcj"><tbody>';
367
+ // SUBTOTAL
368
+ $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_subtotal_text' ) . '</th><td>' . wc_price( $order_subtotal, $order_currency_array ) . '</td></tr>';
369
+ // TAXES
370
+ if ( $order_total_tax != 0 )
371
+ $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_total_tax_text' ) . '</th><td>' . wc_price( $order_total_tax, $order_currency_array ) . '</td></tr>';
372
+ // SHIPPING
373
+ if ( $order_total_shipping != 0 )
374
+ $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_shipping_text' ) . '</th><td>' . wc_price( $order_total_shipping, $order_currency_array ) . '</td></tr>';
375
+ // DISCOUNT
376
+ if ( $order_total_discount != 0 )
377
+ $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_discount_text' ) . '</th><td>-' . wc_price( $order_total_discount, $order_currency_array ) . '</td></tr>';
378
+ // TOTAL
379
+ $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_total_text' ) . '</th><td>' . $the_order->get_formatted_order_total() . '</td></tr>';
380
+ $html .= '</tbody></table></p>';
381
 
382
+ // PAYMENT METHOD
383
+ if ( '' != get_option( 'wcj_pdf_invoices_order_payment_method_text' ) )
384
+ $html .= '<p>' . get_option( 'wcj_pdf_invoices_order_payment_method_text' ). ': ' . $the_order->payment_method_title . '</p>';
385
+ // SHIPPING METHOD
386
+ if ( '' != get_option( 'wcj_pdf_invoices_order_shipping_method_text' ) )
387
+ $html .= '<p>' . get_option( 'wcj_pdf_invoices_order_shipping_method_text' ). ': ' . $the_order->get_shipping_method() . '</p>';
388
+ // ADDITIONAL FOOTER
389
+ $html .= '<p>' . str_replace( PHP_EOL, '<br>', get_option( 'wcj_pdf_invoices_footer_text' ) ) . '</p>';
390
 
391
+ return $html;
392
+ }
 
 
 
 
 
393
 
394
  /**
395
  * add_pdf_invoices_link_to_order_list.
396
  */
397
  public function add_pdf_invoices_link_to_order_list( $actions, $the_order ) {
398
+
399
  $actions['pdf_invoice'] = array(
400
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
401
  'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
402
  'action' => "view pdf_invoice"
403
  );
404
+
405
  /*$actions['save_pdf_invoice'] = array(
406
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
407
  'name' => __( 'Save PDF', 'woocommerce-jetpack' ),
408
  'action' => "view save_pdf_invoice"
409
  );*/
410
+
411
  return $actions;
412
  }
413
 
415
  * add_enabled_option.
416
  */
417
  public function add_enabled_option( $settings ) {
418
+
419
  $all_settings = $this->get_settings();
420
  $settings[] = $all_settings[1];
421
+
422
  return $settings;
423
  }
424
+
425
  /**
426
  * get_settings.
427
+ */
428
  function get_settings() {
429
+
430
  $settings = array(
431
+
432
+ array( 'title' => __( 'PDF Invoices Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_options' ),
433
+
434
  array(
435
  'title' => __( 'PDF Invoices', 'woocommerce-jetpack' ),
436
  'desc' => __( 'Enable the PDF Invoices feature', 'woocommerce-jetpack' ),
439
  'default' => 'yes',
440
  'type' => 'checkbox',
441
  ),
442
+
443
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_options' ),
444
+
445
+ array( 'title' => __( 'Invoice Header', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set texts for required invoice number and date, and optional logo, header text, invoice due and fulfillment dates.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_header_options' ),
446
+
447
  array(
448
  'title' => __( 'Your Logo URL', 'woocommerce-jetpack' ),
449
  'desc' => __( 'Enter a URL to an image you want to show in the invoice\'s header. Upload your image using the <a href="/wp-admin/media-new.php">media uploader</a>.', 'woocommerce-jetpack' ),
450
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
451
  'id' => 'wcj_pdf_invoices_seller_logo_url',
452
  'default' => '',
453
  'type' => 'text',
454
  'css' => 'width:33%;min-width:300px;',
455
  ),
456
+
457
  array(
458
  'title' => __( 'Header Text', 'woocommerce-jetpack' ),
459
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
460
+ 'desc' => __( 'Default: INVOICE', 'woocommerce-jetpack' ),
461
  'id' => 'wcj_pdf_invoices_header_text',
462
  'default' => __( 'INVOICE', 'woocommerce-jetpack' ),
463
  'type' => 'text',
464
  'css' => 'width:33%;min-width:300px;',
465
  ),
466
+
467
  array(
468
+ 'title' => __( 'Invoice Number', 'woocommerce-jetpack' ),
469
+ 'desc' => __( 'Default: Invoice number', 'woocommerce-jetpack' ),
470
  'id' => 'wcj_pdf_invoices_invoice_number_text',
471
  'default' => __( 'Invoice number', 'woocommerce-jetpack' ),
472
  'type' => 'text',
474
  ),
475
 
476
  array(
477
+ 'title' => __( 'Invoice Date', 'woocommerce-jetpack' ),
478
+ 'desc' => __( 'Default: Invoice date', 'woocommerce-jetpack' ),
479
  'id' => 'wcj_pdf_invoices_invoice_date_text',
480
  'default' => __( 'Invoice date', 'woocommerce-jetpack' ),
481
  'type' => 'text',
482
  'css' => 'width:33%;min-width:300px;',
483
+ ),
484
+
485
+ /*array(
486
+ 'title' => __( 'Invoice Due Date', 'woocommerce-jetpack' ),
487
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
488
+ //'desc_tip' => __( 'Set to 0 to disable', 'woocommerce-jetpack' ),
489
+ 'id' => 'wcj_pdf_invoices_invoice_due_date_enabled',
490
+ 'default' => 'no',
491
+ 'type' => 'checkbox',
492
+ ),*/
493
+
494
+ array(
495
+ 'title' => 'Invoice Due Date',
496
+ 'desc' => __( 'Default: Invoice due date', 'woocommerce-jetpack' ),
497
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
498
+ 'id' => 'wcj_pdf_invoices_invoice_due_date_text',
499
+ 'default' => __( 'Invoice due date', 'woocommerce-jetpack' ),
500
+ 'type' => 'text',
501
+ 'css' => 'width:33%;min-width:300px;',
502
+ ),
503
+
504
+ array(
505
+ 'title' => '',
506
+ 'desc' => __( 'days', 'woocommerce-jetpack' ),
507
+ //'desc_tip' => __( 'Set to 0 to disable', 'woocommerce-jetpack' ),
508
+ 'id' => 'wcj_pdf_invoices_invoice_due_date_days',
509
+ 'default' => 0,
510
+ 'type' => 'number',
511
+ 'css' => 'width:33%;min-width:300px;',
512
+ ),
513
+
514
+ /*array(
515
+ 'title' => __( 'Invoice Fulfillment Date', 'woocommerce-jetpack' ),
516
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
517
+ //'desc_tip' => __( 'Set to 0 to disable', 'woocommerce-jetpack' ),
518
+ 'id' => 'wcj_pdf_invoices_invoice_fulfillment_date_enabled',
519
+ 'default' => 'no',
520
+ 'type' => 'checkbox',
521
+ ),*/
522
+
523
+ array(
524
+ 'title' => 'Invoice Fulfillment Date',
525
+ 'desc' => __( 'Default: Invoice fulfillment date', 'woocommerce-jetpack' ),
526
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
527
+ 'id' => 'wcj_pdf_invoices_invoice_fulfillment_date_text',
528
+ 'default' => __( 'Invoice fulfillment date', 'woocommerce-jetpack' ),
529
+ 'type' => 'text',
530
+ 'css' => 'width:33%;min-width:300px;',
531
+ ),
532
+
533
+ array(
534
+ 'title' => '',
535
+ 'desc' => __( 'days', 'woocommerce-jetpack' ),
536
+ //'desc_tip' => __( 'Set to 0 to disable', 'woocommerce-jetpack' ),
537
+ 'id' => 'wcj_pdf_invoices_invoice_fulfillment_date_days',
538
+ 'default' => 0,
539
+ 'type' => 'number',
540
+ 'css' => 'width:33%;min-width:300px;',
541
+ ),
542
+
543
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_header_options' ),
544
+
545
+ array( 'title' => __( 'Seller and Buyer Info', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_seller_and_buyer_options' ),
546
+
547
  array(
548
+ 'title' => __( 'Seller', 'woocommerce-jetpack' ),
549
+ //'desc_tip' => __( 'Seller text', 'woocommerce-jetpack' ),
550
  'id' => 'wcj_pdf_invoices_seller_text',
551
  'default' => __( 'Seller', 'woocommerce-jetpack' ),
552
  'type' => 'text',
553
  'css' => 'width:33%;min-width:300px;',
554
+ ),
555
+
556
  array(
557
  'title' => __( 'Your business information', 'woocommerce-jetpack' ),
558
+ //'desc_tip' => __( 'Seller information', 'woocommerce-jetpack' ),
559
+ 'desc' => __( 'New lines are added automatically.', 'woocommerce-jetpack' ),
560
  'id' => 'wcj_pdf_invoices_seller_info',
561
  'default' => __( '<strong>Company Name</strong>', 'woocommerce-jetpack' ),
562
  'type' => 'textarea',
563
  'css' => 'width:33%;min-width:300px;min-height:300px;',
564
+ ),
565
+
566
  array(
567
+ 'title' => __( 'Buyer', 'woocommerce-jetpack' ),
568
+ //'desc_tip' => __( 'Buyer text', 'woocommerce-jetpack' ),
569
  'id' => 'wcj_pdf_invoices_buyer_text',
570
  'default' => __( 'Buyer', 'woocommerce-jetpack' ),
571
  'type' => 'text',
572
  'css' => 'width:33%;min-width:300px;',
573
  ),
574
+
575
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_seller_and_buyer_options' ),
576
+
577
+ array( 'title' => __( 'Items', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_items_options' ),
578
+
579
  array(
580
+ 'title' => __( 'Items', 'woocommerce-jetpack' ),
581
+ //'desc_tip' => __( 'Items text', 'woocommerce-jetpack' ),
582
  'id' => 'wcj_pdf_invoices_items_text',
583
  'default' => __( 'Items', 'woocommerce-jetpack' ),
584
  'type' => 'text',
585
  'css' => 'width:33%;min-width:300px;',
586
+ ),
587
+
588
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_items_options' ),
589
+
590
+ array( 'title' => __( 'Items Columns', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set column names in invoice items table. You can disable some columns by leaving blank column name.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_items_columns_options' ),
591
 
592
  array(
593
+ 'title' => __( 'Nr.', 'woocommerce-jetpack' ),
594
+ //'desc_tip' => __( 'Nr. text', 'woocommerce-jetpack' ),
595
  'id' => 'wcj_pdf_invoices_column_nr_text',
596
  'default' => __( 'Nr.', 'woocommerce-jetpack' ),
597
  'type' => 'text',
599
  ),
600
 
601
  array(
602
+ 'title' => __( 'Item Name', 'woocommerce-jetpack' ),
603
+ //'desc_tip' => __( 'Item name text', 'woocommerce-jetpack' ),
604
  'id' => 'wcj_pdf_invoices_column_item_name_text',
605
  'default' => __( 'Item Name', 'woocommerce-jetpack' ),
606
  'type' => 'text',
607
  'css' => 'width:33%;min-width:300px;',
608
  ),
609
+
610
  array(
611
+ 'title' => __( 'Qty', 'woocommerce-jetpack' ),
612
+ //'desc_tip' => __( 'Qty text', 'woocommerce-jetpack' ),
613
  'id' => 'wcj_pdf_invoices_column_qty_text',
614
  'default' => __( 'Qty', 'woocommerce-jetpack' ),
615
  'type' => 'text',
616
  'css' => 'width:33%;min-width:300px;',
617
  ),
618
+
619
  array(
620
+ 'title' => __( 'Single Item Price (TAX excl.)', 'woocommerce-jetpack' ),
621
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
622
+ 'id' => 'wcj_pdf_invoices_column_single_price_tax_excl_text',
623
  'default' => __( 'Price (TAX excl.)', 'woocommerce-jetpack' ),
624
  'type' => 'text',
625
  'css' => 'width:33%;min-width:300px;',
626
+ ),
627
+
628
  array(
629
+ 'title' => __( 'Single Item TAX', 'woocommerce-jetpack' ),
630
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
631
+ 'id' => 'wcj_pdf_invoices_column_single_price_tax_text',
632
+ 'default' => __( 'TAX', 'woocommerce-jetpack' ),
633
+ 'type' => 'text',
634
+ 'css' => 'width:33%;min-width:300px;',
635
+ ),
636
+
637
+ array(
638
+ 'title' => __( 'Single Item Price (TAX incl.)', 'woocommerce-jetpack' ),
639
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
640
+ 'id' => 'wcj_pdf_invoices_column_single_price_tax_incl_text',
641
  'default' => __( 'Price (TAX incl.)', 'woocommerce-jetpack' ),
642
  'type' => 'text',
643
  'css' => 'width:33%;min-width:300px;',
644
+ ),
645
 
646
  array(
647
+ 'title' => __( 'Sum (TAX excl.)', 'woocommerce-jetpack' ),
648
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
649
+ 'id' => 'wcj_pdf_invoices_column_price_tax_excl_text',
650
+ 'default' => __( 'Sum (TAX excl.)', 'woocommerce-jetpack' ),
651
  'type' => 'text',
652
  'css' => 'width:33%;min-width:300px;',
653
  ),
654
+
655
  array(
656
+ 'title' => __( 'Tax Percent', 'woocommerce-jetpack' ),
657
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
658
+ 'id' => 'wcj_pdf_invoices_column_price_tax_percent',
659
+ 'default' => __( 'Taxes %', 'woocommerce-jetpack' ),
660
  'type' => 'text',
661
  'css' => 'width:33%;min-width:300px;',
662
+ ),
663
+
664
  array(
665
+ 'title' => __( 'Taxes', 'woocommerce-jetpack' ),
666
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
667
+ 'id' => 'wcj_pdf_invoices_column_price_tax_text',
668
+ 'default' => __( 'Taxes', 'woocommerce-jetpack' ),
669
  'type' => 'text',
670
  'css' => 'width:33%;min-width:300px;',
671
+ ),
672
+
673
  array(
674
+ 'title' => __( 'Sum (TAX incl.)', 'woocommerce-jetpack' ),
675
+ //'desc_tip' => __( 'Price text', 'woocommerce-jetpack' ),
676
+ 'id' => 'wcj_pdf_invoices_column_price_text',
677
+ 'default' => __( 'Sum (TAX incl.)', 'woocommerce-jetpack' ),
678
  'type' => 'text',
679
  'css' => 'width:33%;min-width:300px;',
680
  ),
681
+
682
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_items_columns_options' ),
683
+
684
+ array( 'title' => __( 'Totals', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set texts for totals table.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_totals_options' ),
685
+
686
+ array(
687
+ 'title' => __( 'Order Subtotal', 'woocommerce-jetpack' ),
688
+ 'desc_tip' => __( 'Order Subtotal = Total - Taxes - Shipping - Discounts', 'woocommerce-jetpack' ),
689
+ 'id' => 'wcj_pdf_invoices_order_subtotal_text',
690
+ 'default' => __( 'Order Subtotal', 'woocommerce-jetpack' ),
691
+ 'type' => 'text',
692
+ 'css' => 'width:33%;min-width:300px;',
693
+ ),
694
+
695
+ array(
696
+ 'title' => __( 'Order Total Taxes', 'woocommerce-jetpack' ),
697
+ //'desc_tip' => __( 'Order Subtotal = Total - Taxes - Shipping - Discounts', 'woocommerce-jetpack' ),
698
+ 'id' => 'wcj_pdf_invoices_order_total_tax_text',
699
+ 'default' => __( 'Taxes', 'woocommerce-jetpack' ),
700
+ 'type' => 'text',
701
+ 'css' => 'width:33%;min-width:300px;',
702
+ ),
703
+
704
+ array(
705
+ 'title' => __( 'Order Shipping Price', 'woocommerce-jetpack' ),
706
+ //'desc_tip' => __( 'Order Shipping text', 'woocommerce-jetpack' ),
707
+ 'id' => 'wcj_pdf_invoices_order_shipping_text',
708
+ 'default' => __( 'Shipping', 'woocommerce-jetpack' ),
709
+ 'type' => 'text',
710
+ 'css' => 'width:33%;min-width:300px;',
711
+ ),
712
+
713
+ array(
714
+ 'title' => __( 'Total Discount', 'woocommerce-jetpack' ),
715
+ //'desc_tip' => __( 'Total Discount text', 'woocommerce-jetpack' ),
716
+ 'id' => 'wcj_pdf_invoices_order_discount_text',
717
+ 'default' => __( 'Discount', 'woocommerce-jetpack' ),
718
+ 'type' => 'text',
719
+ 'css' => 'width:33%;min-width:300px;',
720
+ ),
721
+
722
+ array(
723
+ 'title' => __( 'Order Total', 'woocommerce-jetpack' ),
724
+ //'desc_tip' => __( 'Order Total text', 'woocommerce-jetpack' ),
725
+ 'id' => 'wcj_pdf_invoices_order_total_text',
726
+ 'default' => __( 'Order Total', 'woocommerce-jetpack' ),
727
+ 'type' => 'text',
728
+ 'css' => 'width:33%;min-width:300px;',
729
+ ),
730
+
731
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_totals_options' ),
732
+
733
+ array( 'title' => __( 'Footer', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_footer_options' ),
734
+
735
+ array(
736
+ 'title' => __( 'Payment Method', 'woocommerce-jetpack' ),
737
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
738
+ 'id' => 'wcj_pdf_invoices_order_payment_method_text',
739
+ 'default' => __( 'Payment Method', 'woocommerce-jetpack' ),
740
+ 'type' => 'text',
741
+ 'css' => 'width:33%;min-width:300px;',
742
+ ),
743
+
744
+ array(
745
+ 'title' => __( 'Shipping Method', 'woocommerce-jetpack' ),
746
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
747
+ 'id' => 'wcj_pdf_invoices_order_shipping_method_text',
748
+ 'default' => __( 'Shipping Method', 'woocommerce-jetpack' ),
749
+ 'type' => 'text',
750
+ 'css' => 'width:33%;min-width:300px;',
751
+ ),
752
+
753
+ array(
754
+ 'title' => __( 'Additional Footer', 'woocommerce-jetpack' ),
755
+ //'desc_tip' => __( 'Additional Footer text', 'woocommerce-jetpack' ),
756
+ 'id' => 'wcj_pdf_invoices_footer_text',
757
+ 'default' => '',
758
+ 'type' => 'textarea',
759
+ 'css' => 'width:33%;min-width:300px;min-height:300px;',
760
+ ),
761
+
762
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_footer_options' ),
763
+
764
+ array( 'title' => __( 'General Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_general_options' ),
765
+
766
+ array(
767
+ 'title' => __( 'Font size', 'woocommerce-jetpack' ),
768
+ 'desc' => __( 'Default: 8', 'woocommerce-jetpack' ),
769
+ //'desc_tip' => __( 'Add PDF invoices for the store owners and for the customers.', 'woocommerce-jetpack' ),
770
+ 'id' => 'wcj_pdf_invoices_general_font_size',
771
+ 'default' => 8,
772
+ 'type' => 'number',
773
+ ),
774
+
775
+ array(
776
+ 'title' => __( 'Css', 'woocommerce-jetpack' ),
777
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
778
+ //'desc_tip' => __( 'Add PDF invoices for the store owners and for the customers.', 'woocommerce-jetpack' ),
779
+ 'id' => 'wcj_pdf_invoices_general_css',
780
+ 'default' => $this->default_css,
781
+ 'type' => 'textarea',
782
+ 'css' => 'width:66%;min-width:300px;min-height:300px;',
783
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
784
+ ),
785
+
786
+ //array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_general_options' ),
787
+
788
+ //array( 'title' => __( 'More Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_more_options' ),
789
+
790
  array(
791
  'title' => __( 'PDF Invoices for Customers', 'woocommerce-jetpack' ),
792
  'desc' => __( 'Enable the PDF Invoices in customers account', 'woocommerce-jetpack' ),
797
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
798
  ),
799
 
800
+ //array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_more_options' ),
801
+ array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_general_options' ),
802
  );
803
+
804
  return $settings;
805
  }
806
+
807
  /**
808
  * settings_section.
809
  */
810
  function settings_section( $sections ) {
811
+
812
  $sections['pdf_invoices'] = __( 'PDF Invoices', 'woocommerce-jetpack' );
813
+
814
  return $sections;
815
+ }
816
  }
817
+
818
  endif;
819
+
820
  return new WCJ_PDF_Invoices();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: algoritmika
3
  Donate link: http://algoritmika.com/donate/
4
  Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price
5
  Requires at least: 3.9.1
6
- Tested up to: 3.9.2
7
- Stable tag: 1.2.0
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -66,7 +66,7 @@ If you wish that some task would go up the queue to make it faster, please conta
66
  1. Upgrade Feature - Custom Price Labels - Add "global labels".
67
  1. Upgrade Feature - Shipping - Add "Custom Shipping Method".
68
  1. Upgrade Feature - Product Info - Add "total sales" and "time since last sale" info.
69
- 1. Upgrade Feature - Orders - Custom Order Statuses - Add options for selecting icons and colour.
70
  1. New Feature - Products per Page - Add "products per page" option for customers (i.e. front end).
71
  1. Upgrade Feature - Custom Price Labels - Add "local remove".
72
  1. Upgrade Feature - Orders - Bulk orders (start from global discount for all products; later - discounts for individual products).
@@ -76,6 +76,9 @@ If you wish that some task would go up the queue to make it faster, please conta
76
 
77
  == Changelog ==
78
 
 
 
 
79
  = 1.2.0 - 17/08/2014 =
80
  * Feature Upgraded - Orders - Auto-complete all orders option added.
81
  * Feature Upgraded - Orders - Custom Order Statuses added.
3
  Donate link: http://algoritmika.com/donate/
4
  Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price
5
  Requires at least: 3.9.1
6
+ Tested up to: 4.0
7
+ Stable tag: 1.3.0
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
66
  1. Upgrade Feature - Custom Price Labels - Add "global labels".
67
  1. Upgrade Feature - Shipping - Add "Custom Shipping Method".
68
  1. Upgrade Feature - Product Info - Add "total sales" and "time since last sale" info.
69
+ 1. Upgrade Feature - Orders - Custom Order Statuses - Add options for selecting icons and color.
70
  1. New Feature - Products per Page - Add "products per page" option for customers (i.e. front end).
71
  1. Upgrade Feature - Custom Price Labels - Add "local remove".
72
  1. Upgrade Feature - Orders - Bulk orders (start from global discount for all products; later - discounts for individual products).
76
 
77
  == Changelog ==
78
 
79
+ = 1.3.0 - 25/08/2014 =
80
+ * Feature Upgraded - PDF Invoices - Major upgrade: single item price, item and line taxes, payment and shipping methods, additional footer, font size, custom css added.
81
+
82
  = 1.2.0 - 17/08/2014 =
83
  * Feature Upgraded - Orders - Auto-complete all orders option added.
84
  * Feature Upgraded - Orders - Custom Order Statuses added.
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 1.2.0
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 1.3.0
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.