Enabled product bundles

This commit is contained in:
Nedim Uka
2018-06-29 14:40:28 +02:00
parent e0514f7f57
commit b5475ff2f1
12004 changed files with 1694047 additions and 1610 deletions

View File

@@ -0,0 +1,87 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Advanced
*
* @version 3.3.0
* @since 3.3.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Advanced' ) ) :
class WCJ_PDF_Invoicing_Advanced extends WCJ_Module {
/**
* Constructor.
*
* @version 3.3.0
* @since 3.3.0
*/
function __construct() {
$this->id = 'pdf_invoicing_advanced';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Advanced', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
}
/**
* get_report_default_columns.
*
* @version 3.3.0
* @since 3.3.0
*/
function get_report_default_columns() {
return array_keys( array(
'document_number' => __( 'Document Number', 'woocommerce-jetpack' ),
'document_date' => __( 'Document Date', 'woocommerce-jetpack' ),
'order_id' => __( 'Order ID', 'woocommerce-jetpack' ),
'customer_country' => __( 'Customer Country', 'woocommerce-jetpack' ),
'customer_vat_id' => __( 'Customer VAT ID', 'woocommerce-jetpack' ),
'tax_percent' => __( 'Tax %', 'woocommerce-jetpack' ),
'order_total_tax_excluding' => __( 'Order Total Excl. Tax', 'woocommerce-jetpack' ),
'order_taxes' => __( 'Order Taxes', 'woocommerce-jetpack' ),
'order_total' => __( 'Order Total', 'woocommerce-jetpack' ),
'order_currency' => __( 'Order Currency', 'woocommerce-jetpack' ),
'payment_gateway' => __( 'Payment Gateway', 'woocommerce-jetpack' ),
'refunds' => __( 'Refunds', 'woocommerce-jetpack' ),
) );
}
/**
* get_report_columns.
*
* @version 3.3.0
* @since 3.3.0
* @todo (maybe) `order_discount_tax`
*/
function get_report_columns() {
return array(
'document_number' => __( 'Document Number', 'woocommerce-jetpack' ),
'document_date' => __( 'Document Date', 'woocommerce-jetpack' ),
'order_id' => __( 'Order ID', 'woocommerce-jetpack' ),
'customer_country' => __( 'Customer Country', 'woocommerce-jetpack' ),
'customer_vat_id' => __( 'Customer VAT ID', 'woocommerce-jetpack' ),
'tax_percent' => __( 'Tax %', 'woocommerce-jetpack' ),
'order_total_tax_excluding' => __( 'Order Total Excl. Tax', 'woocommerce-jetpack' ),
'order_taxes' => __( 'Order Taxes', 'woocommerce-jetpack' ),
'order_cart_total_excl_tax' => __( 'Cart Total Excl. Tax', 'woocommerce-jetpack' ),
'order_cart_tax' => __( 'Cart Tax', 'woocommerce-jetpack' ),
'order_cart_tax_percent' => __( 'Cart Tax %', 'woocommerce-jetpack' ),
'order_shipping_total_excl_tax' => __( 'Shipping Total Excl. Tax', 'woocommerce-jetpack' ),
'order_shipping_tax' => __( 'Shipping Tax', 'woocommerce-jetpack' ),
'order_shipping_tax_percent' => __( 'Shipping Tax %', 'woocommerce-jetpack' ),
'order_total' => __( 'Order Total', 'woocommerce-jetpack' ),
'order_currency' => __( 'Order Currency', 'woocommerce-jetpack' ),
'payment_gateway' => __( 'Payment Gateway', 'woocommerce-jetpack' ),
'refunds' => __( 'Refunds', 'woocommerce-jetpack' ),
);
}
}
endif;
return new WCJ_PDF_Invoicing_Advanced();

View File

@@ -0,0 +1,350 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Display
*
* @version 3.6.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Display' ) ) :
class WCJ_PDF_Invoicing_Display extends WCJ_Module {
/**
* Constructor.
*
* @version 3.6.0
*/
function __construct() {
$this->id = 'pdf_invoicing_display';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Display & Misc.', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
if ( $this->is_enabled() ) {
// Columns on Admin's Orders page
add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_order_column' ), PHP_INT_MAX - 3 );
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'render_order_columns' ), 2 );
// Action Links on Customer's My Account page
add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'add_pdf_invoices_action_links' ), PHP_INT_MAX, 2 );
// Action Links on Customer's Thank You page
add_action( 'woocommerce_thankyou', array( $this, 'add_pdf_invoices_links_to_thankyou_page' ), 10, 1 );
// Action Buttons to Admin's Orders list
add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_admin_actions' ), PHP_INT_MAX, 2 );
add_filter( 'admin_head', array( $this, 'add_pdf_invoices_admin_actions_buttons_css' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
// Make Sortable Columns
add_filter( 'manage_edit-shop_order_sortable_columns', array( $this, 'shop_order_sortable_columns' ) );
add_action( 'pre_get_posts', array( $this, 'shop_order_pre_get_posts_order_by_column' ) );
// Meta box on admin order page
add_action( 'add_meta_boxes', array( $this, 'add_invoices_meta_box' ) );
}
}
/**
* shop_order_pre_get_posts_order_by_column.
*
* @version 2.9.0
* @since 2.5.8
*/
function shop_order_pre_get_posts_order_by_column( $query ) {
if (
$query->is_main_query() &&
( $orderby = $query->get( 'orderby' ) ) &&
isset( $query->query['post_type'] ) && 'shop_order' === $query->query['post_type'] &&
isset( $query->is_admin ) && 1 == $query->is_admin
) {
if ( 'wcj_invoicing_' === substr( $orderby, 0, 14 ) ) {
$query->set( 'meta_key', '_' . $orderby );
$query->set( 'orderby', 'meta_value_num' );
}
}
}
/**
* Make columns sortable.
*
* @version 2.9.0
* @since 2.5.8
* @param array $columns
* @return array
*/
function shop_order_sortable_columns( $columns ) {
$custom = array();
foreach ( wcj_get_enabled_invoice_types_ids() as $invoice_type_id ) {
$custom[ $invoice_type_id ] = 'wcj_invoicing_' . $invoice_type_id . '_number_id';
}
return wp_parse_args( $custom, $columns );
}
/**
* enqueue_scripts.
*
* @version 2.5.2
* @since 2.5.2
*/
function enqueue_scripts() {
wp_enqueue_script( 'wcj-pdf-invoicing', wcj_plugin_url() . '/includes/js/wcj-pdf-invoicing.js', array(), false, true );
}
/**
* add_pdf_invoices_admin_actions_buttons_css.
*
* @version 3.1.0
* @since 2.4.7
*/
function add_pdf_invoices_admin_actions_buttons_css() {
echo '<style>' . PHP_EOL;
$invoice_types = wcj_get_enabled_invoice_types();
foreach ( $invoice_types as $invoice_type ) {
echo '.view.' . $invoice_type['id'] . '{ color: ' . $invoice_type['color'] . ' !important; }' . PHP_EOL;
echo '.view.' . $invoice_type['id'] . '_' . 'create' . '{ color: ' . $invoice_type['color'] . ' !important; }' . PHP_EOL;
echo '.view.' . $invoice_type['id'] . '_' . 'delete' . '{ color: ' . $invoice_type['color'] . ' !important; }' . PHP_EOL;
echo '.view.' . $invoice_type['id'] . '::after { content: "\f498" !important; }' . PHP_EOL;
echo '.view.' . $invoice_type['id'] . '_' . 'create' . '::after { content: "\f119" !important; }' . PHP_EOL;
echo '.view.' . $invoice_type['id'] . '_' . 'delete' . '::after { content: "\f153" !important; }' . PHP_EOL;
}
echo '</style>' . PHP_EOL;
}
/**
* add_pdf_invoices_admin_actions.
*
* @version 2.7.0
* @since 2.4.7
*/
function add_pdf_invoices_admin_actions( $actions, $the_order ) {
$invoice_types = wcj_get_enabled_invoice_types();
foreach ( $invoice_types as $invoice_type ) {
if ( wcj_is_invoice_created( wcj_get_order_id( $the_order ), $invoice_type['id'] ) ) {
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_view_btn', 'no' ) ) {
// Document (View) button
$query_args = array( 'order_id' => wcj_get_order_id( $the_order ), 'invoice_type_id' => $invoice_type['id'], 'get_invoice' => '1', );
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled', 'no' ) ) {
$query_args['save_pdf_invoice'] = '1';
}
$the_url = add_query_arg( $query_args, remove_query_arg( array ( 'create_invoice_for_order_id', 'delete_invoice_for_order_id' ) ) );
$the_name = __( 'View', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
$the_action = 'view ' . $invoice_type['id'];
$the_action_id = $invoice_type['id'];
$actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action );
}
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_delete_btn', 'yes' ) ) {
// Delete button
$query_args = array( 'delete_invoice_for_order_id' => wcj_get_order_id( $the_order ), 'invoice_type_id' => $invoice_type['id'] );
$the_url = add_query_arg( $query_args, remove_query_arg( 'create_invoice_for_order_id' ) );
$the_name = __( 'Delete', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
$the_action = 'view ' . $invoice_type['id'] . '_' . 'delete' . ( ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_delete_btn_confirm', 'yes' ) ) ? ' wcj_need_confirmation' : '' );
$the_action_id = $invoice_type['id'] . '_' . 'delete';
$actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action );
}
} else {
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_create_btn', 'yes' ) ) {
// Create button
$query_args = array( 'create_invoice_for_order_id' => wcj_get_order_id( $the_order ), 'invoice_type_id' => $invoice_type['id'] );
$the_url = add_query_arg( $query_args, remove_query_arg( 'delete_invoice_for_order_id' ) );
$the_name = __( 'Create', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
$the_action = 'view ' . $invoice_type['id'] . '_' . 'create' . ( ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_create_btn_confirm', 'yes' ) ) ? ' wcj_need_confirmation' : '' );
$the_action_id = $invoice_type['id'] . '_' . 'create';
$actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action );
}
}
}
return $actions;
}
/**
* add_order_column.
*
* @version 3.1.0
*/
function add_order_column( $columns ) {
$invoice_types = wcj_get_enabled_invoice_types();
foreach ( $invoice_types as $invoice_type ) {
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_page_column', 'yes' ) ) {
$columns[ $invoice_type['id'] ] = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_page_column_text', $invoice_type['title'] );
}
}
return $columns;
}
/**
* Output custom columns for products
*
* @version 2.4.7
* @param string $column
*/
function render_order_columns( $column ) {
$invoice_types_ids = wcj_get_enabled_invoice_types_ids();
if ( ! in_array( $column, $invoice_types_ids ) ) {
return;
}
$order_id = get_the_ID();
$invoice_type_id = $column;
$html = '';
if ( wcj_is_invoice_created( $order_id, $invoice_type_id ) ) {
$the_invoice = wcj_get_invoice( $order_id, $invoice_type_id );
$the_number = $the_invoice->get_invoice_number();
// Document Link
$query_args = array( 'order_id' => $order_id, 'invoice_type_id' => $invoice_type_id, 'get_invoice' => '1', );
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type_id . '_save_as_enabled', 'no' ) ) {
$query_args['save_pdf_invoice'] = '1';
}
$html .= '<a href="' . add_query_arg( $query_args, remove_query_arg( array( 'create_invoice_for_order_id', 'delete_invoice_for_order_id' ) ) ) . '">' .
$the_number . '</a>';
}
echo $html;
}
/**
* add_pdf_invoices_links_to_thankyou_page.
*
* @version 3.6.0
* @since 3.6.0
* @todo option to change priority for the hook (probably for all docs at once)
*/
function add_pdf_invoices_links_to_thankyou_page( $order_id ) {
$invoice_types = wcj_get_enabled_invoice_types();
foreach ( $invoice_types as $invoice_type ) {
if ( ! wcj_is_invoice_created( $order_id, $invoice_type['id'] ) ) {
continue;
}
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_on_thankyou_page', 'no' ) ) {
$query_args = array( 'order_id' => $order_id, 'invoice_type_id' => $invoice_type['id'], 'get_invoice' => '1', );
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled', 'no' ) ) {
$query_args['save_pdf_invoice'] = '1';
}
if ( '' == ( $title = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_thankyou_page_link_text', $invoice_type['title'] ) ) ) {
$title = $invoice_type['title'];
}
echo str_replace( '%link%', '<a target="_blank" href="' . add_query_arg( $query_args ) . '">' . $title . '</a>',
get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_thankyou_page_template',
'<p><strong>' . sprintf( __( 'Your %s:', 'woocommerce-jetpack' ), $invoice_type['title'] ) . ' </strong> %link%</p>' ) );
}
}
}
/**
* add_pdf_invoices_action_links.
*
* @version 2.7.0
*/
function add_pdf_invoices_action_links( $actions, $the_order ) {
$invoice_types = wcj_get_enabled_invoice_types();
foreach ( $invoice_types as $invoice_type ) {
if ( ! wcj_is_invoice_created( wcj_get_order_id( $the_order ), $invoice_type['id'] ) ) {
continue;
}
$my_account_option_name = 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers';
if ( 'yes' === get_option( $my_account_option_name, 'no' ) ) {
$the_action_id = $invoice_type['id'];
$query_args = array( 'order_id' => wcj_get_order_id( $the_order ), 'invoice_type_id' => $invoice_type['id'], 'get_invoice' => '1', );
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled', 'no' ) ) {
$query_args['save_pdf_invoice'] = '1';
}
$the_url = add_query_arg( $query_args );
$the_name = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_link_text' );
if ( '' == $the_name ) {
$the_name = $invoice_type['title'];
}
$the_action = 'view ' . $invoice_type['id'];
$actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action );
}
}
return $actions;
}
/**
* add_invoices_meta_box.
*
* @version 3.1.0
* @since 2.8.0
*/
function add_invoices_meta_box() {
if ( 'yes' === get_option( 'wcj_invoicing_add_order_meta_box', 'yes' ) ) {
add_meta_box(
'wc-booster-pdf-invoicing',
'<span class="dashicons dashicons-media-default" style="color:#23282d;"></span>' . ' ' . __( 'Booster: PDF Invoices', 'woocommerce-jetpack' ),
array( $this, 'create_invoices_meta_box' ),
'shop_order',
'side',
'default'
);
}
}
/**
* create_invoices_meta_box.
*
* @version 3.6.0
* @since 2.8.0
*/
function create_invoices_meta_box() {
$_order = wc_get_order();
$order_id = wcj_get_order_id( $_order );
$invoice_types = wcj_get_enabled_invoice_types();
if ( empty( $invoice_types ) ) {
echo '<p style="font-style:italic;">' . __( 'You have no document types enabled.', 'woocommerce-jetpack' ) . '</p>';
} else {
foreach ( $invoice_types as $invoice_type ) {
$table_data = array();
$the_number = '';
if ( wcj_is_invoice_created( $order_id, $invoice_type['id'] ) ) {
// "Document (View)" link
$query_args = array( 'order_id' => $order_id, 'invoice_type_id' => $invoice_type['id'], 'get_invoice' => '1', );
$target = ( 'yes' === get_option( 'wcj_invoicing_order_meta_box_open_in_new_window', 'yes' ) ? ' target="_blank"' : '' );
if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled', 'no' ) ) {
$query_args['save_pdf_invoice'] = '1';
$target = '';
}
$the_url = add_query_arg( $query_args, remove_query_arg( array ( 'create_invoice_for_order_id', 'delete_invoice_for_order_id' ) ) );
$the_name = __( 'View', 'woocommerce-jetpack' );
$the_invoice = wcj_get_invoice( $order_id, $invoice_type['id'] );
$the_number = ' [#' . $the_invoice->get_invoice_number() . ']';
$view_link = '<a' . $target . ' href="' . $the_url . '">' . $the_name . '</a>';
// "Delete" link
$query_args = array( 'delete_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type['id'] );
$the_url = add_query_arg( $query_args, remove_query_arg( 'create_invoice_for_order_id' ) );
$the_name = __( 'Delete', 'woocommerce-jetpack' );
$delete_link = '<a class="wcj_need_confirmation" href="' . $the_url . '">' . $the_name . '</a>';
// Numbering
if ( 'yes' === get_option( 'wcj_invoicing_add_order_meta_box_numbering', 'yes' ) ) {
$number_option = 'wcj_invoicing_' . $invoice_type['id'] . '_number_id';
$number_input = '<input style="width:100%;" type="number"' .
' id="' . $number_option . '" name="' . $number_option . '" value="' . get_post_meta( $order_id, '_' . $number_option, true ) . '">' .
'<input type="hidden" name="woojetpack_pdf_invoicing_save_post" value="woojetpack_pdf_invoicing_save_post">';
} else {
$number_input = '';
}
// Actions
$actions = array( $view_link . ' | ' . $delete_link . '<br>' . $number_input );
} else {
// "Create" link
$query_args = array( 'create_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type['id'] );
$the_url = add_query_arg( $query_args, remove_query_arg( 'delete_invoice_for_order_id' ) );
$the_name = __( 'Create', 'woocommerce-jetpack' );
$actions = array( '<a class="wcj_need_confirmation" href="' . $the_url . '">' . $the_name . '</a>' );
}
$maybe_toolptip = '';
$_hooks = wcj_get_invoice_create_on( $invoice_type['id'] );
if ( in_array( 'woocommerce_order_partially_refunded_notification', $_hooks ) ) {
$maybe_toolptip = wc_help_tip( __( 'In case of partial refund, you need to reload the page to see created document in this meta box.', 'woocommerce-jetpack' ), true );
}
$table_data[] = array( '<span class="dashicons dashicons-media-default" style="color:' . $invoice_type['color'] . ';"></span>' . ' ' .
$invoice_type['title'] . $the_number . $maybe_toolptip );
$table_data[] = $actions;
echo '<p>' . wcj_get_table_html( $table_data, array( 'table_class' => 'widefat striped' ) ) . '</p>';
}
}
}
}
endif;
return new WCJ_PDF_Invoicing_Display();

View File

@@ -0,0 +1,85 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Email Options
*
* @version 3.7.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Emails' ) ) :
class WCJ_PDF_Invoicing_Emails extends WCJ_Module {
/**
* Constructor.
*
* @version 2.8.0
*/
function __construct() {
$this->id = 'pdf_invoicing_emails';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Email Options', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
if ( $this->is_enabled() ) {
if ( ! wcj_is_module_enabled( 'general' ) || 'no' === get_option( 'wcj_general_advanced_disable_save_sys_temp_dir', 'no' ) ) {
add_filter( 'woocommerce_email_attachments', array( $this, 'add_pdf_invoice_email_attachment' ), PHP_INT_MAX, 3 );
}
}
}
/**
* do_attach_for_payment_method.
*
* @version 2.8.0
*/
function do_attach_for_payment_method( $invoice_type_id, $payment_method ) {
$included_gateways = get_option( 'wcj_invoicing_' . $invoice_type_id . '_payment_gateways', array() );
if ( empty ( $included_gateways ) ) {
return true; // include all
}
return ( in_array( $payment_method, $included_gateways ) );
}
/**
* add_pdf_invoice_email_attachment.
*
* @version 3.7.0
*/
function add_pdf_invoice_email_attachment( $attachments, $status, $order ) {
if ( ! $order || ! is_object( $order ) || 'WC_Order' != get_class( $order ) ) {
return $attachments;
}
$invoice_types_ids = wcj_get_enabled_invoice_types_ids();
$order_id = wcj_get_order_id( $order );
foreach ( $invoice_types_ids as $invoice_type_id ) {
if ( false === $this->do_attach_for_payment_method( $invoice_type_id, wcj_order_get_payment_method( $order ) ) ) {
continue;
}
if ( ! wcj_is_invoice_created( $order_id, $invoice_type_id ) ) {
continue;
}
$send_on_statuses = get_option( 'wcj_invoicing_' . $invoice_type_id . '_attach_to_emails', array() );
if ( '' == $send_on_statuses ) {
$send_on_statuses = array();
}
if ( in_array( $status, $send_on_statuses ) ) {
$the_invoice = wcj_get_pdf_invoice( $order_id, $invoice_type_id );
$file_name = $the_invoice->get_pdf( 'F' );
if ( '' != $file_name ) {
$attachments[] = $file_name;
}
}
}
return $attachments;
}
}
endif;
return new WCJ_PDF_Invoicing_Emails();

View File

@@ -0,0 +1,30 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Footer
*
* @version 2.8.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Footer' ) ) :
class WCJ_PDF_Invoicing_Footer extends WCJ_Module {
/**
* Constructor.
*/
function __construct() {
$this->id = 'pdf_invoicing_footer';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Footer', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
}
}
endif;
return new WCJ_PDF_Invoicing_Footer();

View File

@@ -0,0 +1,32 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Header
*
* @version 2.8.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Header' ) ) :
class WCJ_PDF_Invoicing_Header extends WCJ_Module {
/**
* Constructor.
*
* @version 2.3.0
*/
function __construct() {
$this->id = 'pdf_invoicing_header';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Header', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
}
}
endif;
return new WCJ_PDF_Invoicing_Header();

View File

@@ -0,0 +1,60 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Numbering
*
* @version 3.2.3
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Numbering' ) ) :
class WCJ_PDF_Invoicing_Numbering extends WCJ_Module {
/**
* Constructor.
*
* @version 3.2.3
*/
function __construct() {
$this->id = 'pdf_invoicing_numbering';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Numbering', 'woocommerce-jetpack' );
parent::__construct( 'submodule' );
if ( 'yes' === get_option( 'wcj_invoicing_admin_search_by_invoice', 'no' ) ) {
add_action( 'pre_get_posts', array( $this, 'search_orders_by_invoice_number' ) );
}
}
/**
* search_orders_by_invoice_number.
*
* @version 3.2.3
* @since 3.2.3
*/
function search_orders_by_invoice_number( $query ) {
if (
! is_admin() ||
! isset( $query->query ) ||
! isset( $query->query['s'] ) ||
false === is_numeric( $query->query['s'] ) ||
0 == $query->query['s'] ||
'shop_order' !== $query->query['post_type'] ||
! $query->query_vars['shop_order_search']
) {
return;
}
$invoice_number = $query->query['s'];
$query->query_vars['post__in'] = array();
$query->query['s'] = '';
$query->set( 'meta_key', '_wcj_invoicing_invoice_number_id' );
$query->set( 'meta_value', $invoice_number );
}
}
endif;
return new WCJ_PDF_Invoicing_Numbering();

View File

@@ -0,0 +1,394 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Page Settings
*
* @version 2.8.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Page' ) ) :
class WCJ_PDF_Invoicing_Page extends WCJ_Module {
/**
* Constructor.
*
* @version 2.4.0
*/
function __construct() {
$this->id = 'pdf_invoicing_page';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Page Settings', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
}
/**
* get_page_formats.
*
* @version 2.4.7
* @since 2.4.7
*/
function get_page_formats() {
$page_formats = array(
// ISO 216 A Series + 2 SIS 014711 extensions
'A0',
'A1',
'A2',
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'A9',
'A10',
'A11',
'A12',
// ISO 216 B Series + 2 SIS 014711 extensions
'B0',
'B1',
'B2',
'B3',
'B4',
'B5',
'B6',
'B7',
'B8',
'B9',
'B10',
'B11',
'B12',
// ISO 216 C Series + 2 SIS 014711 extensions + 2 EXTENSION
'C0',
'C1',
'C2',
'C3',
'C4',
'C5',
'C6',
'C7',
'C8',
'C9',
'C10',
'C11',
'C12',
'C76',
'DL',
// SIS 014711 E Series
'E0',
'E1',
'E2',
'E3',
'E4',
'E5',
'E6',
'E7',
'E8',
'E9',
'E10',
'E11',
'E12',
// SIS 014711 G Series
'G0',
'G1',
'G2',
'G3',
'G4',
'G5',
'G6',
'G7',
'G8',
'G9',
'G10',
'G11',
'G12',
// ISO Press
'RA0',
'RA1',
'RA2',
'RA3',
'RA4',
'SRA0',
'SRA1',
'SRA2',
'SRA3',
'SRA4',
// German DIN 476
'4A0',
'2A0',
// Variations on the ISO Standard
'A2_EXTRA',
'A3+',
'A3_EXTRA',
'A3_SUPER',
'SUPER_A3',
'A4_EXTRA',
'A4_SUPER',
'SUPER_A4',
'A4_LONG',
'F4',
'SO_B5_EXTRA',
'A5_EXTRA',
// ANSI Series
'ANSI_E',
'ANSI_D',
'ANSI_C',
'ANSI_B',
'ANSI_A',
// Traditional 'Loose' North American Paper Sizes
'USLEDGER',
'LEDGER',
'ORGANIZERK',
'BIBLE',
'USTABLOID',
'TABLOID',
'ORGANIZERM',
'USLETTER',
'LETTER',
'USLEGAL',
'LEGAL',
'GOVERNMENTLETTER',
'GLETTER',
'JUNIORLEGAL',
'JLEGAL',
// Other North American Paper Sizes
'QUADDEMY',
'SUPER_B',
'QUARTO',
'GOVERNMENTLEGAL',
'FOLIO',
'MONARCH',
'EXECUTIVE',
'ORGANIZERL',
'STATEMENT',
'MEMO',
'FOOLSCAP',
'COMPACT',
'ORGANIZERJ',
// Canadian standard CAN 2-9.60M
'P1',
'P2',
'P3',
'P4',
'P5',
'P6',
// North American Architectural Sizes
'ARCH_E',
'ARCH_E1',
'ARCH_D',
'BROADSHEET',
'ARCH_C',
'ARCH_B',
'ARCH_A',
// --- North American Envelope Sizes ---
// - Announcement Envelopes
'ANNENV_A2',
'ANNENV_A6',
'ANNENV_A7',
'ANNENV_A8',
'ANNENV_A10',
'ANNENV_SLIM',
// - Commercial Envelopes
'COMMENV_N6_1/4',
'COMMENV_N6_3/4',
'COMMENV_N8',
'COMMENV_N9',
'COMMENV_N10',
'COMMENV_N11',
'COMMENV_N12',
'COMMENV_N14',
// - Catalogue Envelopes
'CATENV_N1',
'CATENV_N1_3/4',
'CATENV_N2',
'CATENV_N3',
'CATENV_N6',
'CATENV_N7',
'CATENV_N8',
'CATENV_N9_1/2',
'CATENV_N9_3/4',
'CATENV_N10_1/2',
'CATENV_N12_1/2',
'CATENV_N13_1/2',
'CATENV_N14_1/4',
'CATENV_N14_1/2',
// Japanese (JIS P 0138-61) Standard B-Series
'JIS_B0',
'JIS_B1',
'JIS_B2',
'JIS_B3',
'JIS_B4',
'JIS_B5',
'JIS_B6',
'JIS_B7',
'JIS_B8',
'JIS_B9',
'JIS_B10',
'JIS_B11',
'JIS_B12',
// PA Series
'PA0',
'PA1',
'PA2',
'PA3',
'PA4',
'PA5',
'PA6',
'PA7',
'PA8',
'PA9',
'PA10',
// Standard Photographic Print Sizes
/* 'PASSPORT_PHOTO',
'E',
'L',
'3R',
'KG',
'4R',
'4D',
'2L',
'5R',
'8P',
'6R',
'6P',
'8R',
'6PW',
'S8R',
'4P',
'10R',
'4PW',
'S10R',
'11R',
'S11R',
'12R',
'S12R',
// Common Newspaper Sizes
'NEWSPAPER_BROADSHEET',
'NEWSPAPER_BERLINER',
'NEWSPAPER_TABLOID',
'NEWSPAPER_COMPACT',
// Business Cards
'CREDIT_CARD',
'BUSINESS_CARD',
'BUSINESS_CARD_ISO7810',
'BUSINESS_CARD_ISO216',
'BUSINESS_CARD_IT',
'BUSINESS_CARD_UK',
'BUSINESS_CARD_FR',
'BUSINESS_CARD_DE',
'BUSINESS_CARD_ES',
'BUSINESS_CARD_CA',
'BUSINESS_CARD_US',
'BUSINESS_CARD_JP',
'BUSINESS_CARD_HK',
'BUSINESS_CARD_AU',
'BUSINESS_CARD_DK',
'BUSINESS_CARD_SE',
'BUSINESS_CARD_RU',
'BUSINESS_CARD_CZ',
'BUSINESS_CARD_FI',
'BUSINESS_CARD_HU',
'BUSINESS_CARD_IL',
// Billboards
'4SHEET',
'6SHEET',
'12SHEET',
'16SHEET',
'32SHEET',
'48SHEET',
'64SHEET',
'96SHEET',
// Old European Sizes
// - Old Imperial English Sizes
'EN_EMPEROR',
'EN_ANTIQUARIAN',
'EN_GRAND_EAGLE',
'EN_DOUBLE_ELEPHANT',
'EN_ATLAS',
'EN_COLOMBIER',
'EN_ELEPHANT',
'EN_DOUBLE_DEMY',
'EN_IMPERIAL',
'EN_PRINCESS',
'EN_CARTRIDGE',
'EN_DOUBLE_LARGE_POST',
'EN_ROYAL',
'EN_SHEET',
'EN_HALF_POST',
'EN_SUPER_ROYAL',
'EN_DOUBLE_POST',
'EN_MEDIUM',
'EN_DEMY',
'EN_LARGE_POST',
'EN_COPY_DRAUGHT',
'EN_POST',
'EN_CROWN',
'EN_PINCHED_POST',
'EN_BRIEF',
'EN_FOOLSCAP',
'EN_SMALL_FOOLSCAP',
'EN_POTT',
// - Old Imperial Belgian Sizes
'BE_GRAND_AIGLE',
'BE_COLOMBIER',
'BE_DOUBLE_CARRE',
'BE_ELEPHANT',
'BE_PETIT_AIGLE',
'BE_GRAND_JESUS',
'BE_JESUS',
'BE_RAISIN',
'BE_GRAND_MEDIAN',
'BE_DOUBLE_POSTE',
'BE_COQUILLE',
'BE_PETIT_MEDIAN',
'BE_RUCHE',
'BE_PROPATRIA',
'BE_LYS',
'BE_POT',
'BE_ROSETTE',
// - Old Imperial French Sizes
'FR_UNIVERS',
'FR_DOUBLE_COLOMBIER',
'FR_GRANDE_MONDE',
'FR_DOUBLE_SOLEIL',
'FR_DOUBLE_JESUS',
'FR_GRAND_AIGLE',
'FR_PETIT_AIGLE',
'FR_DOUBLE_RAISIN',
'FR_JOURNAL',
'FR_COLOMBIER_AFFICHE',
'FR_DOUBLE_CAVALIER',
'FR_CLOCHE',
'FR_SOLEIL',
'FR_DOUBLE_CARRE',
'FR_DOUBLE_COQUILLE',
'FR_JESUS',
'FR_RAISIN',
'FR_CAVALIER',
'FR_DOUBLE_COURONNE',
'FR_CARRE',
'FR_COQUILLE',
'FR_DOUBLE_TELLIERE',
'FR_DOUBLE_CLOCHE',
'FR_DOUBLE_POT',
'FR_ECU',
'FR_COURONNE',
'FR_TELLIERE',
'FR_POT', */
);
$page_formats_options = array();
foreach ( $page_formats as $page_format ) {
$page_formats_options[ $page_format ] = $page_format;
}
return $page_formats_options;
}
}
endif;
return new WCJ_PDF_Invoicing_Page();

View File

@@ -0,0 +1,101 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Styling
*
* @version 3.1.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Styling' ) ) :
class WCJ_PDF_Invoicing_Styling extends WCJ_Module {
/**
* Constructor.
*
* @version 2.9.0
*/
function __construct() {
$this->id = 'pdf_invoicing_styling';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Styling', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
add_action( 'init', array( $this, 'manually_download_fonts' ) );
add_action( 'init', array( $this, 'schedule_download_fonts_event' ) );
add_action( 'admin_init', array( $this, 'schedule_download_fonts_event' ) );
add_action( 'wcj_download_tcpdf_fonts_hook', array( $this, 'download_fonts' ) );
}
/**
* get_default_css_template.
*
* @version 3.1.0
* @version 3.1.0
*/
function get_default_css_template( $invoice_type_id ) {
if ( ! isset( $this->default_css_template[ $invoice_type_id ] ) ) {
$default_template_filename = ( false === strpos( $invoice_type_id, 'custom_doc_' ) ? $invoice_type_id : 'custom_doc' );
$default_template_filename = wcj_plugin_path() . '/includes/settings/pdf-invoicing/wcj-' . $default_template_filename . '.css';
if ( file_exists( $default_template_filename ) ) {
ob_start();
include( $default_template_filename );
$this->default_css_template[ $invoice_type_id ] = ob_get_clean();
} else {
$this->default_css_template[ $invoice_type_id ] = '';
}
}
return $this->default_css_template[ $invoice_type_id ];
}
/**
* On an early action hook, check if the hook is scheduled - if not, schedule it.
*
* @version 2.9.0
* @version 2.9.0
* @todo save `$event_timestamp` info (i.e. hook next scheduled time)
*/
function schedule_download_fonts_event() {
$interval = 'hourly';
$event_hook = 'wcj_download_tcpdf_fonts_hook';
$event_timestamp = wp_next_scheduled( $event_hook, array( $interval ) );
if ( ! $event_timestamp ) {
wp_schedule_event( time(), $interval, $event_hook, array( $interval ) );
}
}
/**
* download_fonts.
*
* @version 2.9.0
* @version 2.9.0
*/
function download_fonts( $interval ) {
update_option( 'wcj_download_tcpdf_fonts_hook_timestamp', (int) current_time( 'timestamp' ) );
wcj_check_and_maybe_download_tcpdf_fonts( true );
}
/**
* manually_download_fonts.
*
* @version 2.9.0
* @version 2.9.0
* @todo add success/error message
*/
function manually_download_fonts() {
if ( isset( $_GET['wcj_download_fonts'] ) ) {
delete_option( 'wcj_invoicing_fonts_version' );
delete_option( 'wcj_invoicing_fonts_version_timestamp' );
wcj_check_and_maybe_download_tcpdf_fonts();
wp_safe_redirect( remove_query_arg( 'wcj_download_fonts' ) );
exit;
}
}
}
endif;
return new WCJ_PDF_Invoicing_Styling();

View File

@@ -0,0 +1,60 @@
<?php
/**
* Booster for WooCommerce - PDF Invoicing - Templates
*
* @version 3.1.0
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_PDF_Invoicing_Templates' ) ) :
class WCJ_PDF_Invoicing_Templates extends WCJ_Module {
/**
* Constructor.
*
* @version 2.3.7
*/
function __construct() {
$this->id = 'pdf_invoicing_templates';
$this->parent_id = 'pdf_invoicing';
$this->short_desc = __( 'Templates', 'woocommerce-jetpack' );
$this->desc = '';
parent::__construct( 'submodule' );
}
/**
* get_default_template.
*
* @version 3.1.0
* @since 3.1.0
*/
function get_default_template( $invoice_type_id ) {
if ( ! isset( $this->default_template[ $invoice_type_id ] ) ) {
$default_template_filename = ( false === strpos( $invoice_type_id, 'custom_doc_' ) ? $invoice_type_id : 'custom_doc' );
$default_template_filename = wcj_plugin_path() . '/includes/settings/pdf-invoicing/wcj-content-template-' . $default_template_filename . '.php';
if ( file_exists( $default_template_filename ) ) {
ob_start();
include( $default_template_filename );
$this->default_template[ $invoice_type_id ] = ob_get_clean();
if ( false !== strpos( $invoice_type_id, 'custom_doc' ) ) {
$custom_doc_nr = ( 'custom_doc' === $invoice_type_id ) ? '1' : str_replace( 'custom_doc_', '', $invoice_type_id );
$this->default_template[ $invoice_type_id ] = str_replace( '[wcj_custom_doc_number]', '[wcj_custom_doc_number doc_nr="' . $custom_doc_nr . '"]',
$this->default_template[ $invoice_type_id ] );
$this->default_template[ $invoice_type_id ] = str_replace( '[wcj_custom_doc_date]', '[wcj_custom_doc_date doc_nr="' . $custom_doc_nr . '"]',
$this->default_template[ $invoice_type_id ] );
}
} else {
$this->default_template[ $invoice_type_id ] = '';
}
}
return $this->default_template[ $invoice_type_id ];
}
}
endif;
return new WCJ_PDF_Invoicing_Templates();