WooCommerce Price Update

I am creating a WooCommerce booking site like:

“On the single product page, the base price is $400, when the user chooses a date, the price will then be updated, for example the user chose December 1 which has additional $50 charge, the total price would then be $450.”

Read More

Now, my problems/questions would be:

How do I retrieve the Additional Monthly price? would it be okay if it is from another table on MySQL?

How do I updated the price in the single product page of WooCommrce, should there be a hook that I need to use?

Related posts

1 comment

  1. add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
    
    function add_custom_price( $cart_object ) {
     $custom_price = 10; // This will be your custom price  
     foreach ( $cart_object->cart_contents as $key => $value ) {
        if ($key === $YOUR_PRODUCT_ID) {
         $value['data']->price = $custom_price;
        }
     }
    }
    

    This will allow you to change the price of the product when the user goes to the cart page, modify the IF statement to include the metadata of the date chosen and you can create cases to change prices based on certain dates. I highly recommend using a plugin instead of doing this. It will be very difficult to maintain. @scriptonomy already mentioned this but the plugin is very good its worth every penny. woothemes.com/products/woocommerce-bookings

Comments are closed.