WooCommerce add_to_cart() with custom price [closed]

Currently there is no straight way to add custom price to product which is added through function $woocommerce->cart->add_to_cart (Documentation) but we have a bypass way that i explain in code below

global $woocommerce;
$custom_price = 1000;
// Cart item data to send & save in order
$cart_item_data = array('custom_price' => $custom_price);   
// woocommerce function to add product into cart check its documentation also 
// what we need here is only $product_id & $cart_item_data other can be default.
$woocommerce->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
// Calculate totals
$woocommerce->cart->calculate_totals();
// Save cart to session
$woocommerce->cart->set_session();
// Maybe set cart cookies
$woocommerce->cart->maybe_set_cart_cookies();

in your functions file you can place below code

 function woocommerce_custom_price_to_cart_item( $cart_object ) {  
    if( !WC()->session->__isset( "reload_checkout" )) {
        foreach ( $cart_object->cart_contents as $key => $value ) {
            if( isset( $value["custom_price"] ) ) {
                //for woocommerce version lower than 3
                //$value['data']->price = $value["custom_price"];
                //for woocommerce version +3
                $value['data']->set_price($value["custom_price"]);
            }
        }  
    }  
}
add_action( 'woocommerce_before_calculate_totals', 'woocommerce_custom_price_to_cart_item', 99 );

and you are good to go