Woocommerce: $cart_item['data']->set_price is not working inside custom plugin
<p>Woocommerce: <code>$cart_item['data']-&gt;set_price</code> is not working inside custom plugin . What i need to do ?</p>

<p>please see the following code .</p>

<pre><code> add_action( ‘woocommerce_before_calculate_totals’, ‘woo_add_donation’);


        function woo_add_donation($cart_object) {

foreach ( WC()-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {

                if($cart_item['data']-&gt;id == 21){

                    $cart_item['data']-&gt;set_price(35);
                }

            }

        }
</code></pre>

<p>when i add this code to my theme function.php it work , but when i add this code to my custom plugin's function.php this code is not working .When i debug i understand that upto this :
<code>if($cart_item['data']-&gt;id == 21){</code><br>
code in my plugin work . But  this line is not working:
 <code>$cart_item['data']-&gt;set_price(35);</code> . What i need to do ?<br>
I saw the documentation here <a href="http://woocommerce.wp-a2z.org/oik_api/wc_productset_price/" rel="nofollow">http://woocommerce.wp-a2z.org/oik_api/wc_productset_price/</a></p>