0

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!

  • Check this answer - https://stackoverflow.com/questions/52094274/hooks-for-order-creation-exclusively-in-woocommerce-3 you need the proper hook to save meta in your order. Here is an example how to access your order and save your meta - https://wp-kama.com/plugin/woocommerce/hook/woocommerce_new_order . Check this too - https://stackoverflow.com/questions/49863814/trying-to-save-order-item-meta-data-with-woocommerce-new-order-item-hook – Martin Mirchev Oct 29 '21 at 06:06

0 Answers0