Title: PHP product data
Last modified: March 6, 2018

---

# PHP product data

 *  [haircaresway](https://wordpress.org/support/users/haircaresway/)
 * (@haircaresway)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/php-product-data/)
 * Hi, i would like to change the price in the back hand depending and the number
   of booked room and days (dynamic pricing), which variable in the hook should 
   i change to achieve this purpose ?
 * add_action(‘woocommerce_before_calculate_totals’, ‘set_custom_price’);
 * function set_custom_price($cart_obj) {
    foreach ($cart_obj->get_cart() as $key
   => $value) { if ($value[‘product_id’] == 3735) { $value[‘data’]->set_price(9.90);
   $new_price = $value[‘data’]->get_price(); } } }

The topic ‘PHP product data’ is closed to new replies.

 * ![](https://ps.w.org/booking-system/assets/icon-256x256.png?rev=2192807)
 * [Pinpoint Booking System - Version 2](https://wordpress.org/plugins/booking-system/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/booking-system/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/booking-system/)
 * [Active Topics](https://wordpress.org/support/plugin/booking-system/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/booking-system/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/booking-system/reviews/)

## Tags

 * [dynamic pricing](https://wordpress.org/support/topic-tag/dynamic-pricing/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)

 * 0 replies
 * 1 participant
 * Last reply from: [haircaresway](https://wordpress.org/support/users/haircaresway/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/php-product-data/)
 * Status: not a support question