Advanced Order Export For WooCommerce

This compatibility allows the store owner to export the tracking information for an order.

Requirements

To enable this compatibility, you must have Advanced Order Export For WooCommerce plugin installed and activated. Please ensure that you are using the latest versions of both plugins to ensure optimal compatibility.

Overview

To export the tracking information for an order use the below code snippet to functions.php file.

//prepare title for providers , once
global $woe_ast_provider_title;
global $wpdb;
$woe_ast_provider_title = array();
$woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
$providers = $wpdb->get_results( "SELECT ts_slug,provider_name FROM {$woo_shippment_table_name} WHERE provider_name IS NOT NULL", ARRAY_A );
$woe_ast_provider_title = wp_list_pluck($providers,"provider_name","ts_slug");

//fill product tracking information 
add_filter( 'woe_fetch_order_product', function($row, $order, $item, $product, $item_meta ){
	global $woe_ast_provider_title;

	if( class_exists("WC_Advanced_Shipment_Tracking_Actions") )
		$st = WC_Advanced_Shipment_Tracking_Actions::get_instance();
	elseif( class_exists("AST_Pro_Actions") )
		$st = AST_Pro_Actions::get_instance();
	else
		return $row;
	$tracking_items = $st->get_tracking_items( $order->get_id() );
	if( !$tracking_items ) 
		return $row;

	//we have tracking information for this order
	$tracking_numbers = array();
	$tracking_providers = array();
	$shipping_dates = array();
	foreach($tracking_items as $tracking_item) {
		//free version have only global information
		if( !isset($tracking_item["products_list"]) OR empty($tracking_item["products_list"]) ) {
			$tracking_numbers[] = $tracking_item['tracking_number'];
			$tracking_providers[] = isset($woe_ast_provider_title[$tracking_item['tracking_provider']]) ? $woe_ast_provider_title[$tracking_item['tracking_provider']] : $tracking_item['tracking_provider'];
			$shipping_dates[] = date_i18n( wc_date_format(), $tracking_item['date_shipped']);
			continue;
		}
		// Paid addon  "Tracking per items" is active!
		foreach($tracking_item["products_list"] as $tracked_product) {
			if($tracked_product->item_id == $item->get_id() ) {
				$tracking_numbers[] = $tracking_item['tracking_number'];
				$tracking_providers[] = isset($woe_ast_provider_title[$tracking_item['tracking_provider']]) ? $woe_ast_provider_title[$tracking_item['tracking_provider']] : $tracking_item['tracking_provider'];
				$shipping_dates[] = date_i18n( wc_date_format(), $tracking_item['date_shipped']);
			}
		}
	}
	//only set exported columns
	if( isset($row['tracking_number']))
		$row['tracking_number'] = join(",", $tracking_numbers);
	if( isset($row['tracking_provider']))
		$row['tracking_provider'] = join(",", $tracking_providers);
	if( isset($row['shipping_date']))
		$row['shipping_date'] = join(",", $shipping_dates);
	return $row;
},10,5);

$129.00

Billed annually

Buy Now