Hi,
If it can help someone, There is an error in add_credits_to_user_account function.
The function get_current_user_id always return 0 as value, so the credit amount is not added to the good user.
Replace this function by this one: get_post_meta( $order->id , ‘_customer_user’, true );
the function :
function add_credits_to_user_account ( $order_id )
{
$order = new WC_Order( $order_id );
$customer_id = get_post_meta( $order->id , '_customer_user', true );
if ( count( $order->get_items() ) > 0 )
{
foreach ( $order->get_items() as $item )
{
$product_name = $item['name'];
$product_id = $item['product_id'];
$product_variation_id = $item['variation_id'];
$credit_amount = floatval(get_post_meta($product_id, "_credits_amount", true));
$current_users_wallet_ballance = floatval(customer_id,"_uw_balance", true));
update_user_meta(customer_id, "_uw_balance", ($credit_amount+$current_users_wallet_ballance));
}
}
}