this code adds shipping information for each product
class WOE_add_product_shipping{
var $items_shipping;
function __construct() {
add_filter('woe_get_order_product_fields', array($this,'add_shipping_fields'), 10, 2);
add_filter('woe_order_export_started',array($this,'fetch_product_shipping'), 10, 1);
add_filter('woe_fetch_order_product',array($this,'fill_product_shipping'), 10, 5);
}
function add_shipping_fields($fields,$format) {
$names = array('first_name','last_name','company','country','address_1','address_2','city','state','postcode');
foreach($names as $f) {
$fields['shipping_'.$f] = array('label'=>"Product Shipping ".$f,'checked' => 1, 'colname'=>"Product Shipping ".$f);
}
return $fields;
}
function fetch_product_shipping($order_id) {
//reset values
$this->items_shipping = array();
$shipping_packages = get_post_meta($order_id, '_wcms_packages', true );
foreach($shipping_packages as $pack) {
$addr = $pack['destination'];
foreach($pack["contents"] as $item) {
$key = $item['product_id']."-".$item['variation_id'];
$this->items_shipping[$key] = $addr;
}
}
return $order_id;
}
function fill_product_shipping($row, $order, $item, $product, $item_meta) {
$key = $item['product_id']."-".$item['variation_id'];
if( isset($this->items_shipping[$key]) ) {
foreach($this->items_shipping[$key] as $k=>$v) {
$k = 'shipping_'.$k;
if( isset($row[$k]) )
$row[$k] = $v;
}
}
return $row;
}
}
new WOE_add_product_shipping();