Scenario: FooEvents for Woocommerce has a metafield “WooCommerceEventsDate” which I need to add to the line-item order meta for each line item in an order
Reason: I need this information to be readable by Zapier in order to pass along to Xero
What I’ve tried:
// Save item custom fields label and value as order item meta data
add_action( 'woocommerce_order_status_processing', 'add_order_meta_from_product_meta', 10, 2 );
function add_order_meta_from_product_meta( $item_id, $item ) {
$product = $item-> get_product();
$start = $product->get_meta('WooCommerceEventsDate');
if( ! empty($start) ) {
$order->update_meta_data( 'WooCommerceEventsDate', $start );
$order->save();
}
}
Any help would be greatly appreciated!