function woo_ce_get_order_fields($format = 'full') { $export_type = 'order'; $fields = array(); $fields[] = array('name' => 'purchase_id', 'label' => __('Order ID', 'woo_ce')); $fields[] = array('name' => 'post_id', 'label' => __('Post ID', 'woo_ce')); $fields[] = array('name' => 'purchase_total', 'label' => __('Order Total', 'woo_ce')); $fields[] = array('name' => 'purchase_subtotal', 'label' => __('Order Subtotal', 'woo_ce')); $fields[] = array('name' => 'order_currency', 'label' => __('Order Currency', 'woo_ce')); $fields[] = array('name' => 'order_discount', 'label' => __('Order Discount', 'woo_ce')); $fields[] = array('name' => 'coupon_code', 'label' => __('Coupon Code', 'woo_ce')); $fields[] = array('name' => 'purchase_total_tax', 'label' => __('Order Total Tax', 'woo_ce')); /* $fields[] = array( 'name' => 'order_incl_tax', 'label' => __( 'Order Incl. Tax', 'woo_ce' ) ); */ $fields[] = array('name' => 'order_excl_tax', 'label' => __('Order Subtotal Excl. Tax', 'woo_ce')); /* $fields[] = array( 'name' => 'order_tax_rate', 'label' => __( 'Order Tax Rate', 'woo_ce' ) ); */ $fields[] = array('name' => 'order_sales_tax', 'label' => __('Sales Tax Total', 'woo_ce')); $fields[] = array('name' => 'order_shipping_tax', 'label' => __('Shipping Tax Total', 'woo_ce')); $fields[] = array('name' => 'order_tax_percentage', 'label' => __('Order Tax Percentage', 'woo_ce')); $fields[] = array('name' => 'payment_gateway_id', 'label' => __('Payment Gateway ID', 'woo_ce')); $fields[] = array('name' => 'payment_gateway', 'label' => __('Payment Gateway', 'woo_ce')); $fields[] = array('name' => 'shipping_method_id', 'label' => __('Shipping Method ID', 'woo_ce')); $fields[] = array('name' => 'shipping_method', 'label' => __('Shipping Method', 'woo_ce')); $fields[] = array('name' => 'shipping_cost', 'label' => __('Shipping Cost', 'woo_ce')); $fields[] = array('name' => 'shipping_weight', 'label' => __('Shipping Weight', 'woo_ce')); $fields[] = array('name' => 'payment_status', 'label' => __('Order Status', 'woo_ce')); $fields[] = array('name' => 'post_status', 'label' => __('Post Status', 'woo_ce')); $fields[] = array('name' => 'order_key', 'label' => __('Order Key', 'woo_ce')); $fields[] = array('name' => 'purchase_date', 'label' => __('Order Date', 'woo_ce')); $fields[] = array('name' => 'purchase_time', 'label' => __('Order Time', 'woo_ce')); $fields[] = array('name' => 'customer_message', 'label' => __('Customer Message', 'woo_ce')); $fields[] = array('name' => 'customer_note', 'label' => __('Customer Note', 'woo_ce')); $fields[] = array('name' => 'order_notes', 'label' => __('Order Notes', 'woo_ce')); $fields[] = array('name' => 'total_quantity', 'label' => __('Total Quantity', 'woo_ce')); $fields[] = array('name' => 'total_order_items', 'label' => __('Total Order Items', 'woo_ce')); $fields[] = array('name' => 'user_id', 'label' => __('User ID', 'woo_ce')); $fields[] = array('name' => 'user_name', 'label' => __('Username', 'woo_ce')); $fields[] = array('name' => 'user_role', 'label' => __('User Role', 'woo_ce')); $fields[] = array('name' => 'ip_address', 'label' => __('Checkout IP Address', 'woo_ce')); $fields[] = array('name' => 'browser_agent', 'label' => __('Checkout Browser Agent', 'woo_ce')); $fields[] = array('name' => 'billing_full_name', 'label' => __('Billing: Full Name', 'woo_ce')); $fields[] = array('name' => 'billing_first_name', 'label' => __('Billing: First Name', 'woo_ce')); $fields[] = array('name' => 'billing_last_name', 'label' => __('Billing: Last Name', 'woo_ce')); $fields[] = array('name' => 'billing_company', 'label' => __('Billing: Company', 'woo_ce')); $fields[] = array('name' => 'billing_address', 'label' => __('Billing: Street Address (Full)', 'woo_ce')); $fields[] = array('name' => 'billing_address_1', 'label' => __('Billing: Street Address 1', 'woo_ce')); $fields[] = array('name' => 'billing_address_2', 'label' => __('Billing: Street Address 2', 'woo_ce')); $fields[] = array('name' => 'billing_city', 'label' => __('Billing: City', 'woo_ce')); $fields[] = array('name' => 'billing_postcode', 'label' => __('Billing: ZIP Code', 'woo_ce')); $fields[] = array('name' => 'billing_state', 'label' => __('Billing: State (prefix)', 'woo_ce')); $fields[] = array('name' => 'billing_state_full', 'label' => __('Billing: State', 'woo_ce')); $fields[] = array('name' => 'billing_country', 'label' => __('Billing: Country (prefix)', 'woo_ce')); $fields[] = array('name' => 'billing_country_full', 'label' => __('Billing: Country', 'woo_ce')); $fields[] = array('name' => 'billing_phone', 'label' => __('Billing: Phone Number', 'woo_ce')); $fields[] = array('name' => 'billing_email', 'label' => __('Billing: E-mail Address', 'woo_ce')); $fields[] = array('name' => 'shipping_full_name', 'label' => __('Shipping: Full Name', 'woo_ce')); $fields[] = array('name' => 'shipping_first_name', 'label' => __('Shipping: First Name', 'woo_ce')); $fields[] = array('name' => 'shipping_last_name', 'label' => __('Shipping: Last Name', 'woo_ce')); $fields[] = array('name' => 'shipping_company', 'label' => __('Shipping: Company', 'woo_ce')); $fields[] = array('name' => 'shipping_address', 'label' => __('Shipping: Street Address (Full)', 'woo_ce')); $fields[] = array('name' => 'shipping_address_1', 'label' => __('Shipping: Street Address 1', 'woo_ce')); $fields[] = array('name' => 'shipping_address_2', 'label' => __('Shipping: Street Address 2', 'woo_ce')); $fields[] = array('name' => 'shipping_city', 'label' => __('Shipping: City', 'woo_ce')); $fields[] = array('name' => 'shipping_postcode', 'label' => __('Shipping: ZIP Code', 'woo_ce')); $fields[] = array('name' => 'shipping_state', 'label' => __('Shipping: State (prefix)', 'woo_ce')); $fields[] = array('name' => 'shipping_state_full', 'label' => __('Shipping: State', 'woo_ce')); $fields[] = array('name' => 'shipping_country', 'label' => __('Shipping: Country (prefix)', 'woo_ce')); $fields[] = array('name' => 'shipping_country_full', 'label' => __('Shipping: Country', 'woo_ce')); $fields[] = array('name' => 'order_items_product_id', 'label' => __('Order Items: Product ID', 'woo_ce')); $fields[] = array('name' => 'order_items_variation_id', 'label' => __('Order Items: Variation ID', 'woo_ce')); $fields[] = array('name' => 'order_items_sku', 'label' => __('Order Items: SKU', 'woo_ce')); $fields[] = array('name' => 'order_items_name', 'label' => __('Order Items: Product Name', 'woo_ce')); $fields[] = array('name' => 'order_items_variation', 'label' => __('Order Items: Product Variation', 'woo_ce')); $fields[] = array('name' => 'order_items_description', 'label' => __('Order Items: Product Description', 'woo_ce')); $fields[] = array('name' => 'order_items_excerpt', 'label' => __('Order Items: Product Excerpt', 'woo_ce')); $fields[] = array('name' => 'order_items_tax_class', 'label' => __('Order Items: Tax Class', 'woo_ce')); $fields[] = array('name' => 'order_items_quantity', 'label' => __('Order Items: Quantity', 'woo_ce')); $fields[] = array('name' => 'order_items_total', 'label' => __('Order Items: Total', 'woo_ce')); $fields[] = array('name' => 'order_items_subtotal', 'label' => __('Order Items: Subtotal', 'woo_ce')); $fields[] = array('name' => 'order_items_rrp', 'label' => __('Order Items: RRP', 'woo_ce')); $fields[] = array('name' => 'order_items_stock', 'label' => __('Order Items: Stock', 'woo_ce')); $fields[] = array('name' => 'order_items_tax', 'label' => __('Order Items: Tax', 'woo_ce')); $fields[] = array('name' => 'order_items_tax_subtotal', 'label' => __('Order Items: Tax Subtotal', 'woo_ce')); $tax_rates = woo_ce_get_order_tax_rates(); if (!empty($tax_rates)) { foreach ($tax_rates as $tax_rate) { $fields[] = array('name' => sprintf('order_items_tax_rate_%d', $tax_rate['rate_id']), 'label' => sprintf(__('Order Items: Tax Rate - %s', 'woo_ce'), $tax_rate['label'])); } } unset($tax_rates, $tax_rate); $fields[] = array('name' => 'order_items_type', 'label' => __('Order Items: Type', 'woo_ce')); $fields[] = array('name' => 'order_items_category', 'label' => __('Order Items: Category', 'woo_ce')); $fields[] = array('name' => 'order_items_tag', 'label' => __('Order Items: Tag', 'woo_ce')); $fields[] = array('name' => 'order_items_total_sales', 'label' => __('Order Items: Total Sales', 'woo_ce')); $fields[] = array('name' => 'order_items_weight', 'label' => __('Order Items: Weight', 'woo_ce')); $fields[] = array('name' => 'order_items_total_weight', 'label' => __('Order Items: Total Weight', 'woo_ce')); /* $fields[] = array( 'name' => '', 'label' => __( '', 'woo_ce' ) ); */ // Allow Plugin/Theme authors to add support for additional columns $fields = apply_filters('woo_ce_' . $export_type . '_fields', $fields, $export_type); switch ($format) { case 'summary': $output = array(); $size = count($fields); for ($i = 0; $i < $size; $i++) { if (isset($fields[$i])) { $output[$fields[$i]['name']] = 'on'; } } return $output; break; case 'full': default: $sorting = woo_ce_get_option($export_type . '_sorting', array()); $size = count($fields); for ($i = 0; $i < $size; $i++) { $fields[$i]['reset'] = $i; $fields[$i]['order'] = isset($sorting[$fields[$i]['name']]) ? $sorting[$fields[$i]['name']] : $i; } // Check if we are using PHP 5.3 and above if (version_compare(phpversion(), '5.3') >= 0) { usort($fields, woo_ce_sort_fields('order')); } return $fields; break; } }
function woo_ce_extend_order_items_unique_columns( $fields = array(), $i = 0, $original_columns = array() ) { // WooCommerce Tax Rates $tax_rates = woo_ce_get_order_tax_rates(); if( !empty( $tax_rates ) ) { foreach( $tax_rates as $tax_rate ) { if( isset( $original_columns[sprintf( 'order_item_%d_tax_rate_%d', $i, $tax_rate['rate_id'] )] ) ) $fields[] = sprintf( __( 'Order Item #%d: Tax Rate - %s', 'woo_ce' ), $i, $tax_rate['label'] ); } } unset( $tax_rates, $tax_rate ); // Product Add-ons - http://www.woothemes.com/ if( $product_addons = woo_ce_get_product_addons() ) { foreach( $product_addons as $product_addon ) { if( isset( $original_columns[sprintf( 'order_item_%d_product_addon_%s', $i, $product_addon->post_name )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, $product_addon->post_title ); } } // WooCommerce Checkout Add-Ons - http://www.skyverge.com/product/woocommerce-checkout-add-ons/ if( function_exists( 'init_woocommerce_checkout_add_ons' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_checkout_addon_id', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_checkout_addon_id', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_checkout_addon_label', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_checkout_addon_label', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_checkout_addon_value', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_check_addon_value', 'name', 'unique' ) ); } // WooCommerce Brands Addon - http://woothemes.com/woocommerce/ // WooCommerce Brands - http://proword.net/Woocommerce_Brands/ if( class_exists( 'WC_Brands' ) || class_exists( 'woo_brands' ) || taxonomy_exists( apply_filters( 'woo_ce_brand_term_taxonomy', 'product_brand' ) ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_brand', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_brand', 'name', 'unique' ) ); } // Product Vendors - http://www.woothemes.com/products/product-vendors/ if( class_exists( 'WooCommerce_Product_Vendors' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_vendor', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_vendor', 'name', 'unique' ) ); } // Cost of Goods - http://www.skyverge.com/product/woocommerce-cost-of-goods-tracking/ if( class_exists( 'WC_COG' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_cost_of_goods', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_cost_of_goods', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_total_cost_of_goods', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_total_cost_of_goods', 'name', 'unique' ) ); } // WooCommerce MSRP Pricing - http://woothemes.com/woocommerce/ if( function_exists( 'woocommerce_msrp_activate' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_msrp', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_msrp', 'name', 'unique' ) ); } // Gravity Forms - http://woothemes.com/woocommerce if( class_exists( 'RGForms' ) && class_exists( 'woocommerce_gravityforms' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_gf_form_id', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_gf_form_id', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_gf_form_label', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_gf_form_label', 'name', 'unique' ) ); // Check if there are any Products linked to Gravity Forms if( $gf_fields = woo_ce_get_gravity_form_fields() ) { foreach( $gf_fields as $key => $gf_field ) { if( isset( $original_columns[sprintf( 'order_item_%d_gf_%d_%s', $i, $gf_field['formId'], $gf_field['id'] )] ) ) $fields[] = sprintf( apply_filters( 'woo_ce_extend_order_items_unique_columns_gf_fields', __( 'Order Item #%d: %s - %s', 'woo_ce' ) ), $i, $gf_field['formTitle'], $gf_field['label'] ); } } } // Local Pickup Plus - http://www.woothemes.com/products/local-pickup-plus/ if( class_exists( 'WC_Local_Pickup_Plus' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_pickup_location', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_pickup_location', 'name', 'unique' ) ); } // WooCommerce Bookings - http://www.woothemes.com/products/woocommerce-bookings/ if( class_exists( 'WC_Bookings' ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_booking_id', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_booking_id', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_booking_date', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_booking_date', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_booking_type', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_booking_type', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_booking_start_date', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_booking_start_date', 'name', 'unique' ) ); if( isset( $original_columns[sprintf( 'order_item_%d_booking_end_date', $i )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, woo_ce_get_order_field( 'order_items_booking_end_date', 'name', 'unique' ) ); } // WooCommerce TM Extra Product Options - http://codecanyon.net/item/woocommerce-extra-product-options/7908619 if( class_exists( 'TM_Extra_Product_Options' ) ) { if( $tm_fields = woo_ce_get_extra_product_option_fields() ) { foreach( $tm_fields as $tm_field ) { if( isset( $original_columns[sprintf( 'order_item_%d_tm_%s', $i, sanitize_key( $tm_field['name'] ) )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, $tm_field['name'] ); } } } // Attributes if( $attributes = woo_ce_get_product_attributes() ) { foreach( $attributes as $attribute ) { if( isset( $original_columns[sprintf( 'order_item_%d_attribute_%s', $i, sanitize_key( $attribute->attribute_name ) )] ) ) { if( empty( $attribute->attribute_label ) ) $attribute->attribute_label = $attribute->attribute_name; $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, $attribute->attribute_label ); } } } // Custom Order Items fields $custom_order_items = woo_ce_get_option( 'custom_order_items', '' ); if( !empty( $custom_order_items ) ) { foreach( $custom_order_items as $custom_order_item ) { if( !empty( $custom_order_item ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_%s', $i, $custom_order_item )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, $custom_order_item ); } } } // Custom Product fields $custom_products = woo_ce_get_option( 'custom_products', '' ); if( !empty( $custom_products ) ) { foreach( $custom_products as $custom_product ) { if( !empty( $custom_product ) ) { if( isset( $original_columns[sprintf( 'order_item_%d_%s', $i, $custom_product )] ) ) $fields[] = sprintf( __( 'Order Item #%d: %s', 'woo_ce' ), $i, $custom_product ); } } } return $fields; }