WooCommerce Cart - Dynamic Price variable pass into custom price hook
<p>I am getting the dynamic custom price in a variable that I want to pass to the hooked function in <strong>woocommerce_before_calculate_totals</strong> hook in cart. But it isn't working.</p>

<p>This is my code:</p>

<pre><code>  $add=200; //I want to pass this variable in add_action hook
  add_action( 'woocommerce_before_calculate_totals', 'add_custom_total_price');
  function add_custom_total_price($cart_object) {
     global $woocommerce;
     $custom_price =$add; // This is my custom price
    foreach ( $cart_object-&gt;cart_contents as $key =&gt; $value ) {
       $value['data']-&gt;price = $custom_price;
    }
 } 
</code></pre>

<p>How can I achieve this?</p>

<p>Thanks</p>