Title: Set price through hook is not working anymore
Last modified: June 21, 2023

---

# Set price through hook is not working anymore

 *  Resolved [Ishor Ale Magar](https://wordpress.org/support/users/smartdev2023/)
 * (@smartdev2023)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/set-proi/)
 * Hello support,
 * The price change with this hook is not working anymore, is there any alternatives?
 *     ```wp-block-code
       add_action( 'woocommerce_before_calculate_totals', 'set_item_cart_prices', 20, 1 );
       function set_item_cart_prices( $cart ) {
           if ( is_admin() && ! defined( 'DOING_AJAX' ) )
               return;
   
           if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
               return;
   
           // Loop through cart items
           foreach ( $cart->get_cart() as $cart_item ){
               if( ! is_user_logged_in() ){
                   $cart_item['data']->set_price( $cart_item['data']->get_regular_price() );
               }
           }
       }
       ```
   
 * It was working before but it is not working anymore.
 * Please suggest.
    -  This topic was modified 2 years, 9 months ago by [Ishor Ale Magar](https://wordpress.org/support/users/smartdev2023/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * (@xue28)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/set-proi/#post-16852244)
 * Hi [@smartdev2023](https://wordpress.org/support/users/smartdev2023/)
 * Thanks for reaching out!
 * I understand that the code snippet above is not working as expected on your end.
 * This is a bit of a complicated topic that would need some customization to address.
   Unfortunately, [custom coding](https://woocommerce.com/support-policy/) is not
   something we can assist with directly. However, I’ll keep this thread open for
   a bit to see if anyone from the community can lend a hand.
 * If you have any other questions related to development or custom coding, don’t
   hesitate to reach out to some of the great resources we have available for support.
   The WooCommerce community is filled with talented open-source developers, and
   many of them are active on the channels listed below:
    - [WooCommerce Developer Resources Portal](https://developer.woocommerce.com/)
    - [WooCommerce Advanced Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
    - [WooCommerce Developer Slack Channel](https://woocommerce.com/community-slack/)
    - Hire a [WooCommerce Expert](https://woocommerce.com/experts/)
 * Hope this helps!
 *  Thread Starter [Ishor Ale Magar](https://wordpress.org/support/users/smartdev2023/)
 * (@smartdev2023)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/set-proi/#post-16853395)
 * Hello support,
 * One of the plugin was overriding the hook, which was causing the issue.
 * Thanks
 *  [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * (@xue28)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/set-proi/#post-16863515)
 * Hi [@smartdev2023](https://wordpress.org/support/users/smartdev2023/)
 * I’m glad you were able to find the culprit of your issue here and thus resolved
   the issue. 🙂
 * Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Set price through hook is not working anymore’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [compatibility issue](https://wordpress.org/support/topic-tag/compatibility-issue/)

 * 3 replies
 * 2 participants
 * Last reply from: [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/set-proi/#post-16863515)
 * Status: resolved