Home › Forums › General Issues › How to receive wc customer acf in order export › Reply To: How to receive wc customer acf in order export
I solved it for my needs.
I also added this acf for the orders.
And on a new order I copy the customer acf value to the order acf.
function my_new_order( $order_id ) {
$order = new WC_Order( $order_id );
if ( !$order ) return;
$customer_id = $order->get_customer_id();
if ( !$customer_id ) return;
$customer = new WC_Customer($customer_id);
if ( !$customer ) return;
$customer_number = $customer->get_meta('customernumber');
if ( !$customer_number ) return;
$order->add_meta_data('customernumber', $customer_number);
$res = $order->save_meta_data();
}
add_action( 'woocommerce_checkout_order_processed', 'my_new_order', 10, 1);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.