'Woocommerce update admin order item price based on user meta

I'm trying to update item price for orders with users that have a custom field marked as "true". The item price needs to be updated to a custom field that is in the product. The price should either convert if I hit recalculate. This is what I have so far.

`function action_woocommerce_new_order_item( $item_id, $item, $order_id ) { // only run this from the WP admin section if ( !is_admin() ) return;

$product = wc_get_product( $item->get_product_id() );

if ( !$product )
        return;

$current_price = $product->get_price();
$order = wc_get_order( $order_id );
$order_user = $order->get_user();
$order_user_id = $order->get_user_id();


$users_cost_price = get_user_meta( $order_user_id, 'cost_yes', true );
$users_cost_price = ( $users_cost_price = 1 );

$cost_price= get_users_cost_price( $current_price, 'alg_wc_cog_item_cost');

}; add_action( 'woocommerce_new_order_item', 'action_woocommerce_new_order_item', 10, 3 ); `



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source