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,193 @@
<?php
/**
* Booster for WooCommerce Exporter Customers
*
* @version 3.1.0
* @since 2.5.9
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_Exporter_Customers' ) ) :
class WCJ_Exporter_Customers {
/**
* Constructor.
*
* @version 2.5.9
* @since 2.5.9
*/
function __construct() {
return true;
}
/**
* export_customers.
*
* @version 3.0.0
* @since 2.4.8
*/
function export_customers( $fields_helper ) {
// Standard Fields
$all_fields = $fields_helper->get_customer_export_fields();
$fields_ids = get_option( 'wcj_export_customers_fields', $fields_helper->get_customer_export_default_fields_ids() );
$titles = array();
foreach( $fields_ids as $field_id ) {
$titles[] = $all_fields[ $field_id ];
}
// Get the Data
$data = array();
$data[] = $titles;
$args = array( 'role' => 'customer' );
$args = wcj_maybe_add_date_query( $args );
$customers = get_users( $args );
foreach ( $customers as $customer ) {
$row = array();
foreach( $fields_ids as $field_id ) {
switch ( $field_id ) {
case 'customer-id':
$row[] = $customer->ID;
break;
case 'customer-email':
$row[] = $customer->user_email;
break;
case 'customer-login':
$row[] = $customer->user_login;
break;
case 'customer-nicename':
$row[] = $customer->user_nicename;
break;
case 'customer-url':
$row[] = $customer->user_url;
break;
case 'customer-registered':
$row[] = $customer->user_registered;
break;
case 'customer-display-name':
$row[] = $customer->display_name;
break;
case 'customer-first-name':
$row[] = $customer->first_name;
break;
case 'customer-last-name':
$row[] = $customer->last_name;
break;
case 'customer-debug':
$row[] = '<pre>' . print_r( $customer, true ) . '</pre>';
break;
}
}
$data[] = $row;
}
return $data;
}
/**
* export_customers_from_orders.
*
* @version 3.1.0
* @since 2.4.8
* @todo (maybe) add more order fields (shipping)
*/
function export_customers_from_orders( $fields_helper ) {
// Standard Fields
$all_fields = $fields_helper->get_customer_from_order_export_fields();
$fields_ids = get_option( 'wcj_export_customers_from_orders_fields', $fields_helper->get_customer_from_order_export_default_fields_ids() );
$titles = array();
foreach( $fields_ids as $field_id ) {
$titles[] = $all_fields[ $field_id ];
}
// Get the Data
$data = array();
$data[] = $titles;
$total_customers = 0;
$orders = array();
$offset = 0;
$block_size = 1024;
while( true ) {
$args_orders = array(
'post_type' => 'shop_order',
'post_status' => 'any',
'posts_per_page' => $block_size,
'orderby' => 'date',
'order' => 'DESC',
'offset' => $offset,
'fields' => 'ids',
);
$args_orders = wcj_maybe_add_date_query( $args_orders );
$loop_orders = new WP_Query( $args_orders );
if ( ! $loop_orders->have_posts() ) {
break;
}
foreach ( $loop_orders->posts as $order_id ) {
$order = wc_get_order( $order_id );
$_billing_email = wcj_get_order_billing_email( $order );
if ( isset( $_billing_email ) && '' != $_billing_email && ! in_array( $_billing_email, $orders ) ) {
$emails_to_skip = array(); // `emails_to_skip` is not really used...
if ( ! in_array( $_billing_email, $emails_to_skip ) ) {
$total_customers++;
$row = array();
foreach( $fields_ids as $field_id ) {
switch ( $field_id ) {
case 'customer-nr':
$row[] = $total_customers;
break;
case 'customer-billing-email':
$row[] = $_billing_email;
break;
case 'customer-billing-first-name':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_first_name : $order->get_billing_first_name() );
break;
case 'customer-billing-last-name':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_last_name : $order->get_billing_last_name() );
break;
case 'customer-billing-company':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_company : $order->get_billing_company() );
break;
case 'customer-billing-address-1':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_address_1 : $order->get_billing_address_1() );
break;
case 'customer-billing-address-2':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_address_2 : $order->get_billing_address_2() );
break;
case 'customer-billing-city':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_city : $order->get_billing_city() );
break;
case 'customer-billing-state':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_state : $order->get_billing_state() );
break;
case 'customer-billing-postcode':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_postcode : $order->get_billing_postcode() );
break;
case 'customer-billing-country':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_country : $order->get_billing_country() );
break;
case 'customer-billing-phone':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_phone : $order->get_billing_phone() );
break;
case 'customer-last-order-date':
$row[] = get_the_date( get_option( 'date_format' ), $order_id );
break;
}
}
$data[] = $row;
$orders[] = $_billing_email;
}
}
}
$offset += $block_size;
}
return $data;
}
}
endif;
return new WCJ_Exporter_Customers();

View File

@@ -0,0 +1,423 @@
<?php
/**
* Booster for WooCommerce Exporter Orders
*
* @version 3.2.1
* @since 2.5.9
* @author Algoritmika Ltd.
* @todo filter export by date
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_Exporter_Orders' ) ) :
class WCJ_Exporter_Orders {
/**
* Constructor.
*
* @version 2.5.9
* @since 2.5.9
*/
function __construct() {
return true;
}
/**
* get_export_orders_row.
*
* @version 2.7.0
* @since 2.5.9
*/
function get_export_orders_row( $fields_ids, $order_id, $order, $items, $items_product_input_fields, $item, $item_id ) {
$row = array();
foreach( $fields_ids as $field_id ) {
switch ( $field_id ) {
case 'item-product-input-fields':
$row[] = wcj_get_product_input_fields( $item );
break;
case 'item-debug':
$row[] = '<pre>' . print_r( $item, true ) . '</pre>';
break;
case 'item-name':
$row[] = $item['name'];
break;
case 'item-meta':
$row[] = wcj_get_order_item_meta_info( $item_id, $item, $order );
break;
case 'item-variation-meta':
$row[] = ( 0 != $item['variation_id'] ) ? wcj_get_order_item_meta_info( $item_id, $item, $order, true ) : '';
break;
case 'item-qty':
$row[] = $item['qty'];
break;
case 'item-tax-class':
$row[] = $item['tax_class'];
break;
case 'item-product-id':
$row[] = $item['product_id'];
break;
case 'item-variation-id':
$row[] = $item['variation_id'];
break;
case 'item-line-subtotal':
$row[] = $item['line_subtotal'];
break;
case 'item-line-total':
$row[] = $item['line_total'];
break;
case 'item-line-subtotal-tax':
$row[] = $item['line_subtotal_tax'];
break;
case 'item-line-tax':
$row[] = $item['line_tax'];
break;
case 'item-line-total-plus-tax':
$row[] = $item['line_total'] + $item['line_tax'];
break;
case 'item-line-subtotal-plus-tax':
$row[] = $item['line_subtotal'] + $item['line_subtotal_tax'];
break;
case 'order-id':
$row[] = $order_id;
break;
case 'order-number':
$row[] = $order->get_order_number();
break;
case 'order-status':
$row[] = $order->get_status();
break;
case 'order-date':
$row[] = get_the_date( get_option( 'date_format' ), $order_id );
break;
case 'order-time':
$row[] = get_the_time( get_option( 'time_format' ), $order_id );
break;
case 'order-item-count':
$row[] = $order->get_item_count();
break;
case 'order-items':
$row[] = $items;
break;
case 'order-items-product-input-fields':
$row[] = $items_product_input_fields;
break;
case 'order-currency':
$row[] = wcj_get_order_currency( $order );
break;
case 'order-total':
$row[] = $order->get_total();
break;
case 'order-total-tax':
$row[] = $order->get_total_tax();
break;
case 'order-payment-method':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->payment_method_title : $order->get_payment_method_title() );
break;
case 'order-notes':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->customer_note : $order->get_customer_note() );
break;
case 'billing-first-name':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_first_name : $order->get_billing_first_name() );
break;
case 'billing-last-name':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_last_name : $order->get_billing_last_name() );
break;
case 'billing-company':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_company : $order->get_billing_company() );
break;
case 'billing-address-1':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_address_1 : $order->get_billing_address_1() );
break;
case 'billing-address-2':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_address_2 : $order->get_billing_address_2() );
break;
case 'billing-city':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_city : $order->get_billing_city() );
break;
case 'billing-state':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_state : $order->get_billing_state() );
break;
case 'billing-postcode':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_postcode : $order->get_billing_postcode() );
break;
case 'billing-country':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_country : $order->get_billing_country() );
break;
case 'billing-phone':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_phone : $order->get_billing_phone() );
break;
case 'billing-email':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->billing_email : $order->get_billing_email() );
break;
case 'shipping-first-name':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_first_name : $order->get_shipping_first_name() );
break;
case 'shipping-last-name':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_last_name : $order->get_shipping_last_name() );
break;
case 'shipping-company':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_company : $order->get_shipping_company() );
break;
case 'shipping-address-1':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_address_1 : $order->get_shipping_address_1() );
break;
case 'shipping-address-2':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_address_2 : $order->get_shipping_address_2() );
break;
case 'shipping-city':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_city : $order->get_shipping_city() );
break;
case 'shipping-state':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_state : $order->get_shipping_state() );
break;
case 'shipping-postcode':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_postcode : $order->get_shipping_postcode() );
break;
case 'shipping-country':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $order->shipping_country : $order->get_shipping_country() );
break;
}
}
return $row;
}
/**
* export_orders.
*
* @version 3.0.0
* @since 2.4.8
* @todo (maybe) metainfo as separate column
*/
function export_orders( $fields_helper ) {
// Standard Fields
$all_fields = $fields_helper->get_order_export_fields();
$fields_ids = get_option( 'wcj_export_orders_fields', $fields_helper->get_order_export_default_fields_ids() );
$titles = array();
foreach( $fields_ids as $field_id ) {
$titles[] = $all_fields[ $field_id ];
}
// Additional Fields
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_export_orders_fields_additional_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'yes' === get_option( 'wcj_export_orders_fields_additional_enabled_' . $i, 'no' ) ) {
$titles[] = get_option( 'wcj_export_orders_fields_additional_title_' . $i, '' );
}
}
$data = array();
$data[] = $titles;
$offset = 0;
$block_size = 1024;
while( true ) {
$args_orders = array(
'post_type' => 'shop_order',
'post_status' => 'any',
'posts_per_page' => $block_size,
'orderby' => 'date',
'order' => 'DESC',
'offset' => $offset,
'fields' => 'ids',
);
$args_orders = wcj_maybe_add_date_query( $args_orders );
$loop_orders = new WP_Query( $args_orders );
if ( ! $loop_orders->have_posts() ) {
break;
}
foreach ( $loop_orders->posts as $order_id ) {
$order = wc_get_order( $order_id );
if ( isset( $_POST['wcj_filter_by_order_billing_country'] ) && '' != $_POST['wcj_filter_by_order_billing_country'] ) {
if ( $order->billing_country != $_POST['wcj_filter_by_order_billing_country'] ) {
continue;
}
}
$filter_by_product_title = true;
if ( isset( $_POST['wcj_filter_by_product_title'] ) && '' != $_POST['wcj_filter_by_product_title'] ) {
$filter_by_product_title = false;
}
$items = array();
$items_product_input_fields = array();
foreach ( $order->get_items() as $item_id => $item ) {
if ( in_array( 'order-items', $fields_ids ) ) {
$meta_info = ( 0 != $item['variation_id'] ) ? wcj_get_order_item_meta_info( $item_id, $item, $order, true ) : '';
if ( '' != $meta_info ) {
$meta_info = ' [' . $meta_info . ']';
}
$items[] = $item['name'] . $meta_info;
}
if ( in_array( 'order-items-product-input-fields', $fields_ids ) ) {
$item_product_input_fields = wcj_get_product_input_fields( $item );
if ( '' != $item_product_input_fields ) {
$items_product_input_fields[] = $item_product_input_fields;
}
}
if ( ! $filter_by_product_title ) {
// if ( $item['name'] === $_POST['wcj_filter_by_product_title'] ) {
if ( false !== strpos( $item['name'], $_POST['wcj_filter_by_product_title'] ) ) {
$filter_by_product_title = true;
}
}
}
$items = implode( ' / ', $items );
$items_product_input_fields = implode( ' / ', $items_product_input_fields );
if ( ! $filter_by_product_title ) {
continue;
}
$row = $this->get_export_orders_row( $fields_ids, $order_id, $order, $items, $items_product_input_fields, null, null );
// Additional Fields
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_export_orders_fields_additional_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'yes' === get_option( 'wcj_export_orders_fields_additional_enabled_' . $i, 'no' ) ) {
if ( '' != ( $additional_field_value = get_option( 'wcj_export_orders_fields_additional_value_' . $i, '' ) ) ) {
if ( 'meta' === get_option( 'wcj_export_orders_fields_additional_type_' . $i, 'meta' ) ) {
$row[] = $this->safely_get_post_meta( $order_id, $additional_field_value );
} else {
global $post;
$post = get_post( $order_id );
setup_postdata( $post );
$row[] = do_shortcode( $additional_field_value );
wp_reset_postdata();
}
} else {
$row[] = '';
}
}
}
$data[] = $row;
}
$offset += $block_size;
}
return $data;
}
/**
* export_orders_items.
*
* @version 3.2.1
* @since 2.5.9
*/
function export_orders_items( $fields_helper ) {
// Standard Fields
$all_fields = $fields_helper->get_order_items_export_fields();
$fields_ids = apply_filters( 'wcj_export_orders_items_fields', get_option( 'wcj_export_orders_items_fields', $fields_helper->get_order_items_export_default_fields_ids() ) );
$titles = array();
foreach( $fields_ids as $field_id ) {
$titles[] = $all_fields[ $field_id ];
}
// Additional Fields
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_export_orders_items_fields_additional_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'yes' === get_option( 'wcj_export_orders_items_fields_additional_enabled_' . $i, 'no' ) ) {
$titles[] = get_option( 'wcj_export_orders_items_fields_additional_title_' . $i, '' );
}
}
$data = array();
$data[] = $titles;
$offset = 0;
$block_size = 1024;
while( true ) {
$args_orders = array(
'post_type' => 'shop_order',
'post_status' => 'any',
'posts_per_page' => $block_size,
'orderby' => 'date',
'order' => 'DESC',
'offset' => $offset,
'fields' => 'ids',
);
$args_orders = wcj_maybe_add_date_query( $args_orders );
$loop_orders = new WP_Query( $args_orders );
if ( ! $loop_orders->have_posts() ) {
break;
}
foreach ( $loop_orders->posts as $order_id ) {
$order = wc_get_order( $order_id );
if ( isset( $_POST['wcj_filter_by_order_billing_country'] ) && '' != $_POST['wcj_filter_by_order_billing_country'] ) {
if ( $order->billing_country != $_POST['wcj_filter_by_order_billing_country'] ) {
continue;
}
}
foreach ( $order->get_items() as $item_id => $item ) {
$row = $this->get_export_orders_row( $fields_ids, $order_id, $order, null, null, $item, $item_id );
// Additional Fields
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_export_orders_items_fields_additional_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'yes' === get_option( 'wcj_export_orders_items_fields_additional_enabled_' . $i, 'no' ) ) {
if ( '' != ( $additional_field_value = get_option( 'wcj_export_orders_items_fields_additional_value_' . $i, '' ) ) ) {
$field_type = get_option( 'wcj_export_orders_items_fields_additional_type_' . $i, 'meta' );
switch ( $field_type ) {
case 'meta':
$row[] = $this->safely_get_post_meta( $order_id, $additional_field_value );
break;
case 'item_meta':
$row[] = wcj_maybe_implode( wc_get_order_item_meta( $item_id, $additional_field_value ) );
break;
case 'meta_product':
$product_id = ( 0 != $item['variation_id'] ) ? $item['variation_id'] : $item['product_id'];
$row[] = $this->safely_get_post_meta( $product_id, $additional_field_value );
break;
case 'shortcode':
global $post;
$post = get_post( $order_id );
setup_postdata( $post );
$row[] = do_shortcode( $additional_field_value );
wp_reset_postdata();
break;
case 'shortcode_product':
global $post;
$product_id = ( 0 != $item['variation_id'] ) ? $item['variation_id'] : $item['product_id'];
$post = get_post( $product_id );
setup_postdata( $post );
$row[] = do_shortcode( $additional_field_value );
wp_reset_postdata();
break;
}
} else {
$row[] = '';
}
}
}
$data[] = $row;
}
}
$offset += $block_size;
}
return $data;
}
/**
* safely_get_post_meta.
*
* @version 2.6.0
* @since 2.6.0
* @todo handle multidimensional arrays
*/
function safely_get_post_meta( $post_id, $key ) {
$meta = get_post_meta( $post_id, $key, true );
if ( is_array( $meta ) ) {
$meta = implode( ', ', $meta );
}
return $meta;
}
}
endif;
return new WCJ_Exporter_Orders();

View File

@@ -0,0 +1,295 @@
<?php
/**
* Booster for WooCommerce Exporter Products
*
* @version 3.0.0
* @since 2.5.9
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_Exporter_Products' ) ) :
class WCJ_Exporter_Products {
/**
* Constructor.
*
* @version 2.5.9
* @since 2.5.9
*/
function __construct() {
return true;
}
/**
* get_variable_or_grouped_product_info.
*
* @version 2.7.0
* @since 2.5.7
*/
function get_variable_or_grouped_product_info( $_product, $which_info ) {
$all_variations_data = array();
foreach ( $_product->get_children() as $child_id ) {
$variation = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->get_child( $child_id ) : wc_get_product( $child_id ) );
switch ( $which_info ) {
case 'price':
$all_variations_data[] = ( '' === $variation->get_price() ) ? '-' : $variation->get_price();
break;
case 'regular_price':
$all_variations_data[] = ( '' === $variation->get_regular_price() ) ? '-' : $variation->get_regular_price();
break;
case 'sale_price':
$all_variations_data[] = ( '' === $variation->get_sale_price() ) ? '-' : $variation->get_sale_price();
break;
case 'total_stock':
$all_variations_data[] = ( null === wcj_get_product_total_stock( $variation ) ) ? '-' : wcj_get_product_total_stock( $variation );
break;
case 'stock_quantity':
$all_variations_data[] = ( null === $variation->get_stock_quantity() ) ? '-' : $variation->get_stock_quantity();
break;
}
}
return implode( '/', $all_variations_data );
}
/**
* export_products.
*
* @version 3.0.0
* @since 2.5.3
* @todo product attributes
*/
function export_products( $fields_helper ) {
// Standard Fields
$all_fields = $fields_helper->get_product_export_fields();
$fields_ids = get_option( 'wcj_export_products_fields', $fields_helper->get_product_export_default_fields_ids() );
$titles = array();
foreach( $fields_ids as $field_id ) {
$titles[] = $all_fields[ $field_id ];
}
// Additional Fields
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_export_products_fields_additional_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'yes' === get_option( 'wcj_export_products_fields_additional_enabled_' . $i, 'no' ) ) {
$titles[] = get_option( 'wcj_export_products_fields_additional_title_' . $i, '' );
}
}
$data = array();
$data[] = $titles;
$offset = 0;
$block_size = 1024;
while( true ) {
$args = array(
'post_type' => 'product',
'post_status' => 'any',
'posts_per_page' => $block_size,
'orderby' => 'date',
'order' => 'DESC',
'offset' => $offset,
'fields' => 'ids',
);
$args = wcj_maybe_add_date_query( $args );
$loop = new WP_Query( $args );
if ( ! $loop->have_posts() ) {
break;
}
foreach ( $loop->posts as $product_id ) {
$_product = wc_get_product( $product_id );
$products = array( $product_id => $_product );
$parent_product_id = '';
if ( $_product->is_type( 'variable' ) ) {
$parent_product_id = $product_id;
$export_products_variable = get_option( 'wcj_export_products_variable', 'variable_only' );
if ( 'variations_only' === $export_products_variable || 'variable_and_variations' === $export_products_variable ) {
if ( 'variations_only' === $export_products_variable ) {
$products = array();
}
foreach ( $_product->get_children() as $child_id ) {
$products[ $child_id ] = wc_get_product( $child_id );
}
}
}
foreach ( $products as $product_id => $_product ) {
$row = array();
foreach( $fields_ids as $field_id ) {
switch ( $field_id ) {
case 'product-id':
$row[] = $product_id;
break;
case 'parent-product-id':
$row[] = $parent_product_id;
break;
case 'product-name':
$row[] = $_product->get_title();
break;
case 'product-sku':
$row[] = $_product->get_sku();
break;
case 'product-stock-quantity':
$row[] = ( $_product->is_type( 'variable' ) || $_product->is_type( 'grouped' ) ?
$this->get_variable_or_grouped_product_info( $_product, 'stock_quantity' ) : $_product->get_stock_quantity() );
break;
case 'product-stock':
$row[] = ( $_product->is_type( 'variable' ) || $_product->is_type( 'grouped' ) ?
$this->get_variable_or_grouped_product_info( $_product, 'total_stock' ) : wcj_get_product_total_stock( $_product ) );
break;
case 'product-regular-price':
$row[] = ( $_product->is_type( 'variable' ) || $_product->is_type( 'grouped' ) ?
$this->get_variable_or_grouped_product_info( $_product, 'regular_price' ) : $_product->get_regular_price() );
break;
case 'product-sale-price':
$row[] = ( $_product->is_type( 'variable' ) || $_product->is_type( 'grouped' ) ?
$this->get_variable_or_grouped_product_info( $_product, 'sale_price' ) : $_product->get_sale_price() );
break;
case 'product-price':
$row[] = ( $_product->is_type( 'variable' ) || $_product->is_type( 'grouped' ) ?
$this->get_variable_or_grouped_product_info( $_product, 'price' ) : $_product->get_price() );
break;
case 'product-type':
$row[] = $_product->get_type();
break;
/* case 'product-attributes':
$row[] = ( ! empty( $_product->get_attributes() ) ? serialize( $_product->get_attributes() ) : '' );
break; */
case 'product-image-url':
$row[] = wcj_get_product_image_url( $product_id, 'full' );
break;
case 'product-short-description':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->post->post_excerpt : $_product->get_short_description() );
break;
case 'product-description':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->post->post_content : $_product->get_description() );
break;
case 'product-status':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->post->post_status : $_product->get_status() );
break;
case 'product-url':
$row[] = $_product->get_permalink();
break;
case 'product-shipping-class':
$row[] = $_product->get_shipping_class();
break;
case 'product-shipping-class-id':
$row[] = $_product->get_shipping_class_id();
break;
case 'product-width':
$row[] = $_product->get_width();
break;
case 'product-length':
$row[] = $_product->get_length();
break;
case 'product-height':
$row[] = $_product->get_height();
break;
case 'product-weight':
$row[] = $_product->get_weight();
break;
case 'product-downloadable':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->downloadable : $_product->get_downloadable() );
break;
case 'product-virtual':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->virtual : $_product->get_virtual() );
break;
case 'product-sold-individually':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->sold_individually : $_product->get_sold_individually() );
break;
case 'product-tax-status':
$row[] = $_product->get_tax_status();
break;
case 'product-tax-class':
$row[] = $_product->get_tax_class();
break;
case 'product-manage-stock':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->manage_stock : $_product->get_manage_stock() );
break;
case 'product-stock-status':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->stock_status : $_product->get_stock_status() );
break;
case 'product-backorders':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->backorders : $_product->get_backorders() );
break;
case 'product-featured':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->featured : $_product->get_featured() );
break;
case 'product-visibility':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->visibility : $_product->get_catalog_visibility() );
break;
case 'product-price-including-tax':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->get_price_including_tax() : wc_get_price_including_tax( $_product ) );
break;
case 'product-price-excluding-tax':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->get_price_excluding_tax() : wc_get_price_excluding_tax( $_product ) );
break;
case 'product-display-price':
$row[] = wcj_get_product_display_price( $_product );
break;
case 'product-average-rating':
$row[] = $_product->get_average_rating();
break;
case 'product-rating-count':
$row[] = $_product->get_rating_count();
break;
case 'product-review-count':
$row[] = $_product->get_review_count();
break;
case 'product-categories':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->get_categories() : wc_get_product_category_list( $product_id ) );
break;
case 'product-tags':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->get_tags() : wc_get_product_tag_list( $product_id ) );
break;
case 'product-dimensions':
$row[] = ( WCJ_IS_WC_VERSION_BELOW_3 ? $_product->get_dimensions() : wc_format_dimensions( $_product->get_dimensions( false ) ) );
break;
case 'product-formatted-name':
$row[] = $_product->get_formatted_name();
break;
case 'product-availability':
$availability = $_product->get_availability();
$row[] = $availability['availability'];
break;
case 'product-availability-class':
$availability = $_product->get_availability();
$row[] = $availability['class'];
break;
}
}
// Additional Fields
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_export_products_fields_additional_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'yes' === get_option( 'wcj_export_products_fields_additional_enabled_' . $i, 'no' ) ) {
if ( '' != ( $additional_field_value = get_option( 'wcj_export_products_fields_additional_value_' . $i, '' ) ) ) {
if ( 'meta' === get_option( 'wcj_export_products_fields_additional_type_' . $i, 'meta' ) ) {
$row[] = get_post_meta( $product_id, $additional_field_value, true );
} else {
global $post;
$post = get_post( $product_id );
setup_postdata( $post );
$row[] = do_shortcode( $additional_field_value );
wp_reset_postdata();
}
} else {
$row[] = '';
}
}
}
$data[] = $row;
}
}
$offset += $block_size;
}
return $data;
}
}
endif;
return new WCJ_Exporter_Products();

View File

@@ -0,0 +1,354 @@
<?php
/**
* Booster for WooCommerce Export Fields Helper
*
* @version 2.7.0
* @since 2.5.9
* @author Algoritmika Ltd.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'WCJ_Export_Fields_Helper' ) ) :
class WCJ_Export_Fields_Helper {
/**
* Constructor.
*
* @version 2.7.0
* @since 2.5.9
*/
function __construct() {
return true;
}
/**
* get_customer_from_order_export_fields.
*
* @version 2.5.9
* @since 2.5.9
*/
function get_customer_from_order_export_fields() {
return array(
'customer-nr' => __( 'Customer Nr.', 'woocommerce-jetpack' ),
'customer-billing-email' => __( 'Billing Email', 'woocommerce-jetpack' ),
'customer-billing-first-name' => __( 'Billing First Name', 'woocommerce-jetpack' ),
'customer-billing-last-name' => __( 'Billing Last Name', 'woocommerce-jetpack' ),
'customer-billing-company' => __( 'Billing Company', 'woocommerce-jetpack' ),
'customer-billing-address-1' => __( 'Billing Address 1', 'woocommerce-jetpack' ),
'customer-billing-address-2' => __( 'Billing Address 2', 'woocommerce-jetpack' ),
'customer-billing-city' => __( 'Billing City', 'woocommerce-jetpack' ),
'customer-billing-state' => __( 'Billing State', 'woocommerce-jetpack' ),
'customer-billing-postcode' => __( 'Billing Postcode', 'woocommerce-jetpack' ),
'customer-billing-country' => __( 'Billing Country', 'woocommerce-jetpack' ),
'customer-billing-phone' => __( 'Billing Phone', 'woocommerce-jetpack' ),
'customer-last-order-date' => __( 'Last Order Date', 'woocommerce-jetpack' ),
);
}
/**
* get_customer_from_order_export_default_fields_ids.
*
* @version 2.5.9
* @since 2.5.9
*/
function get_customer_from_order_export_default_fields_ids() {
return array(
'customer-nr',
'customer-billing-email',
'customer-billing-first-name',
'customer-billing-last-name',
'customer-last-order-date',
);
}
/**
* get_customer_export_fields.
*
* @version 2.5.9
* @since 2.5.9
*/
function get_customer_export_fields() {
return array(
'customer-id' => __( 'Customer ID', 'woocommerce-jetpack' ),
'customer-email' => __( 'Email', 'woocommerce-jetpack' ),
'customer-first-name' => __( 'First Name', 'woocommerce-jetpack' ),
'customer-last-name' => __( 'Last Name', 'woocommerce-jetpack' ),
'customer-login' => __( 'Login', 'woocommerce-jetpack' ),
'customer-nicename' => __( 'Nicename', 'woocommerce-jetpack' ),
'customer-url' => __( 'URL', 'woocommerce-jetpack' ),
'customer-registered' => __( 'Registered', 'woocommerce-jetpack' ),
'customer-display-name' => __( 'Display Name', 'woocommerce-jetpack' ),
// 'customer-debug' => __( 'Debug', 'woocommerce-jetpack' ),
);
}
/**
* get_customer_export_default_fields_ids.
*
* @version 2.5.9
* @since 2.5.9
*/
function get_customer_export_default_fields_ids() {
return array(
'customer-id',
'customer-email',
'customer-first-name',
'customer-last-name',
);
}
/**
* get_order_items_export_fields.
*
* @version 2.5.9
* @since 2.5.9
*/
function get_order_items_export_fields() {
return array(
'order-id' => __( 'Order ID', 'woocommerce-jetpack' ),
'order-number' => __( 'Order Number', 'woocommerce-jetpack' ),
'order-status' => __( 'Order Status', 'woocommerce-jetpack' ),
'order-date' => __( 'Order Date', 'woocommerce-jetpack' ),
'order-time' => __( 'Order Time', 'woocommerce-jetpack' ),
'order-item-count' => __( 'Order Item Count', 'woocommerce-jetpack' ),
'order-currency' => __( 'Order Currency', 'woocommerce-jetpack' ),
'order-total' => __( 'Order Total', 'woocommerce-jetpack' ),
'order-total-tax' => __( 'Order Total Tax', 'woocommerce-jetpack' ),
'order-payment-method' => __( 'Order Payment Method', 'woocommerce-jetpack' ),
'order-notes' => __( 'Order Notes', 'woocommerce-jetpack' ),
'billing-first-name' => __( 'Billing First Name', 'woocommerce-jetpack' ),
'billing-last-name' => __( 'Billing Last Name', 'woocommerce-jetpack' ),
'billing-company' => __( 'Billing Company', 'woocommerce-jetpack' ),
'billing-address-1' => __( 'Billing Address 1', 'woocommerce-jetpack' ),
'billing-address-2' => __( 'Billing Address 2', 'woocommerce-jetpack' ),
'billing-city' => __( 'Billing City', 'woocommerce-jetpack' ),
'billing-state' => __( 'Billing State', 'woocommerce-jetpack' ),
'billing-postcode' => __( 'Billing Postcode', 'woocommerce-jetpack' ),
'billing-country' => __( 'Billing Country', 'woocommerce-jetpack' ),
'billing-phone' => __( 'Billing Phone', 'woocommerce-jetpack' ),
'billing-email' => __( 'Billing Email', 'woocommerce-jetpack' ),
'shipping-first-name' => __( 'Shipping First Name', 'woocommerce-jetpack' ),
'shipping-last-name' => __( 'Shipping Last Name', 'woocommerce-jetpack' ),
'shipping-company' => __( 'Shipping Company', 'woocommerce-jetpack' ),
'shipping-address-1' => __( 'Shipping Address 1', 'woocommerce-jetpack' ),
'shipping-address-2' => __( 'Shipping Address 2', 'woocommerce-jetpack' ),
'shipping-city' => __( 'Shipping City', 'woocommerce-jetpack' ),
'shipping-state' => __( 'Shipping State', 'woocommerce-jetpack' ),
'shipping-postcode' => __( 'Shipping Postcode', 'woocommerce-jetpack' ),
'shipping-country' => __( 'Shipping Country', 'woocommerce-jetpack' ),
'item-name' => __( 'Item Name', 'woocommerce-jetpack' ),
'item-meta' => __( 'Item Meta', 'woocommerce-jetpack' ),
'item-variation-meta' => __( 'Item Variation Meta', 'woocommerce-jetpack' ),
'item-qty' => __( 'Item Quantity', 'woocommerce-jetpack' ),
'item-tax-class' => __( 'Item Tax Class', 'woocommerce-jetpack' ),
'item-product-id' => __( 'Item Product ID', 'woocommerce-jetpack' ),
'item-variation-id' => __( 'Item Variation ID', 'woocommerce-jetpack' ),
'item-line-subtotal' => __( 'Item Line Subtotal', 'woocommerce-jetpack' ),
'item-line-total' => __( 'Item Line Total', 'woocommerce-jetpack' ),
'item-line-subtotal-tax' => __( 'Item Line Subtotal Tax', 'woocommerce-jetpack' ),
'item-line-tax' => __( 'Item Line Tax', 'woocommerce-jetpack' ),
'item-line-subtotal-plus-tax' => __( 'Item Line Subtotal Plus Tax', 'woocommerce-jetpack' ),
'item-line-total-plus-tax' => __( 'Item Line Total Plus Tax', 'woocommerce-jetpack' ),
'item-product-input-fields' => __( 'Item Product Input Fields', 'woocommerce-jetpack' ),
// 'item-debug' => __( 'Item Debug', 'woocommerce-jetpack' ),
);
}
/**
* get_order_items_export_default_fields_ids.
*
* @version 2.5.9
* @since 2.5.9
*/
function get_order_items_export_default_fields_ids() {
return array(
'order-number',
'order-status',
'order-date',
'order-currency',
'order-payment-method',
'item-name',
'item-variation-meta',
'item-qty',
'item-tax-class',
'item-product-id',
'item-variation-id',
'item-line-total',
'item-line-tax',
'item-line-total-plus-tax',
);
}
/**
* get_order_export_fields.
*
* @version 2.5.7
* @since 2.5.6
*/
function get_order_export_fields() {
return array(
'order-id' => __( 'Order ID', 'woocommerce-jetpack' ),
'order-number' => __( 'Order Number', 'woocommerce-jetpack' ),
'order-status' => __( 'Order Status', 'woocommerce-jetpack' ),
'order-date' => __( 'Order Date', 'woocommerce-jetpack' ),
'order-time' => __( 'Order Time', 'woocommerce-jetpack' ),
'order-item-count' => __( 'Order Item Count', 'woocommerce-jetpack' ),
'order-items' => __( 'Order Items', 'woocommerce-jetpack' ),
'order-items-product-input-fields' => __( 'Order Items Product Input Fields', 'woocommerce-jetpack' ),
'order-currency' => __( 'Order Currency', 'woocommerce-jetpack' ),
'order-total' => __( 'Order Total', 'woocommerce-jetpack' ),
'order-total-tax' => __( 'Order Total Tax', 'woocommerce-jetpack' ),
'order-payment-method' => __( 'Order Payment Method', 'woocommerce-jetpack' ),
'order-notes' => __( 'Order Notes', 'woocommerce-jetpack' ),
'billing-first-name' => __( 'Billing First Name', 'woocommerce-jetpack' ),
'billing-last-name' => __( 'Billing Last Name', 'woocommerce-jetpack' ),
'billing-company' => __( 'Billing Company', 'woocommerce-jetpack' ),
'billing-address-1' => __( 'Billing Address 1', 'woocommerce-jetpack' ),
'billing-address-2' => __( 'Billing Address 2', 'woocommerce-jetpack' ),
'billing-city' => __( 'Billing City', 'woocommerce-jetpack' ),
'billing-state' => __( 'Billing State', 'woocommerce-jetpack' ),
'billing-postcode' => __( 'Billing Postcode', 'woocommerce-jetpack' ),
'billing-country' => __( 'Billing Country', 'woocommerce-jetpack' ),
'billing-phone' => __( 'Billing Phone', 'woocommerce-jetpack' ),
'billing-email' => __( 'Billing Email', 'woocommerce-jetpack' ),
'shipping-first-name' => __( 'Shipping First Name', 'woocommerce-jetpack' ),
'shipping-last-name' => __( 'Shipping Last Name', 'woocommerce-jetpack' ),
'shipping-company' => __( 'Shipping Company', 'woocommerce-jetpack' ),
'shipping-address-1' => __( 'Shipping Address 1', 'woocommerce-jetpack' ),
'shipping-address-2' => __( 'Shipping Address 2', 'woocommerce-jetpack' ),
'shipping-city' => __( 'Shipping City', 'woocommerce-jetpack' ),
'shipping-state' => __( 'Shipping State', 'woocommerce-jetpack' ),
'shipping-postcode' => __( 'Shipping Postcode', 'woocommerce-jetpack' ),
'shipping-country' => __( 'Shipping Country', 'woocommerce-jetpack' ),
);
}
/**
* get_order_export_default_fields_ids.
*
* @version 2.5.7
* @since 2.5.6
*/
function get_order_export_default_fields_ids() {
return array(
'order-id',
'order-number',
'order-status',
'order-date',
'order-time',
'order-item-count',
'order-items',
'order-currency',
'order-total',
'order-total-tax',
'order-payment-method',
'order-notes',
'billing-first-name',
'billing-last-name',
'billing-company',
'billing-address-1',
'billing-address-2',
'billing-city',
'billing-state',
'billing-postcode',
'billing-country',
'billing-phone',
'billing-email',
'shipping-first-name',
'shipping-last-name',
'shipping-company',
'shipping-address-1',
'shipping-address-2',
'shipping-city',
'shipping-state',
'shipping-postcode',
'shipping-country',
);
}
/**
* get_product_export_fields.
*
* @version 2.6.0
* @since 2.5.7
*/
function get_product_export_fields() {
return array(
'product-id' => __( 'Product ID', 'woocommerce-jetpack' ),
'parent-product-id' => __( 'Parent Product ID', 'woocommerce-jetpack' ),
'product-name' => __( 'Name', 'woocommerce-jetpack' ),
'product-sku' => __( 'SKU', 'woocommerce-jetpack' ),
'product-stock' => __( 'Total Stock', 'woocommerce-jetpack' ),
'product-stock-quantity' => __( 'Stock Quantity', 'woocommerce-jetpack' ),
'product-regular-price' => __( 'Regular Price', 'woocommerce-jetpack' ),
'product-sale-price' => __( 'Sale Price', 'woocommerce-jetpack' ),
'product-price' => __( 'Price', 'woocommerce-jetpack' ),
'product-type' => __( 'Type', 'woocommerce-jetpack' ),
// 'product-attributes' => __( 'Attributes', 'woocommerce-jetpack' ),
'product-image-url' => __( 'Image URL', 'woocommerce-jetpack' ),
'product-short-description' => __( 'Short Description', 'woocommerce-jetpack' ),
'product-description' => __( 'Description', 'woocommerce-jetpack' ),
'product-status' => __( 'Status', 'woocommerce-jetpack' ),
'product-url' => __( 'URL', 'woocommerce-jetpack' ),
'product-shipping-class' => __( 'Shipping Class', 'woocommerce-jetpack' ),
'product-shipping-class-id' => __( 'Shipping Class ID', 'woocommerce-jetpack' ),
'product-width' => __( 'Width', 'woocommerce-jetpack' ),
'product-length' => __( 'Length', 'woocommerce-jetpack' ),
'product-height' => __( 'Height', 'woocommerce-jetpack' ),
'product-weight' => __( 'Weight', 'woocommerce-jetpack' ),
'product-downloadable' => __( 'Downloadable', 'woocommerce-jetpack' ),
'product-virtual' => __( 'Virtual', 'woocommerce-jetpack' ),
'product-sold-individually' => __( 'Sold Individually', 'woocommerce-jetpack' ),
'product-tax-status' => __( 'Tax Status', 'woocommerce-jetpack' ),
'product-tax-class' => __( 'Tax Class', 'woocommerce-jetpack' ),
'product-manage-stock' => __( 'Manage Stock', 'woocommerce-jetpack' ),
'product-stock-status' => __( 'Stock Status', 'woocommerce-jetpack' ),
'product-backorders' => __( 'Backorders', 'woocommerce-jetpack' ),
'product-featured' => __( 'Featured', 'woocommerce-jetpack' ),
'product-visibility' => __( 'Visibility', 'woocommerce-jetpack' ),
'product-price-including-tax' => __( 'Price Including Tax', 'woocommerce-jetpack' ),
'product-price-excluding-tax' => __( 'Price Excluding Tax', 'woocommerce-jetpack' ),
'product-display-price' => __( 'Display Price', 'woocommerce-jetpack' ),
'product-average-rating' => __( 'Average Rating', 'woocommerce-jetpack' ),
'product-rating-count' => __( 'Rating Count', 'woocommerce-jetpack' ),
'product-review-count' => __( 'Review Count', 'woocommerce-jetpack' ),
'product-categories' => __( 'Categories', 'woocommerce-jetpack' ),
'product-tags' => __( 'Tags', 'woocommerce-jetpack' ),
'product-dimensions' => __( 'Dimensions', 'woocommerce-jetpack' ),
'product-formatted-name' => __( 'Formatted Name', 'woocommerce-jetpack' ),
'product-availability' => __( 'Availability', 'woocommerce-jetpack' ),
'product-availability-class' => __( 'Availability Class', 'woocommerce-jetpack' ),
);
}
/**
* get_product_export_default_fields_ids.
*
* @version 2.5.7
* @since 2.5.7
*/
function get_product_export_default_fields_ids() {
return array(
'product-id',
'product-name',
'product-sku',
'product-stock',
'product-regular-price',
'product-sale-price',
'product-price',
'product-type',
'product-image-url',
'product-short-description',
'product-status',
'product-url',
);
}
}
endif;
return new WCJ_Export_Fields_Helper();