0.00  View cart

Support Easy Booking: Pricing [Resolved] Fixed price per period?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #7556
    Christoph
    Participant

    Hi,

    I wonder if it is possible to set a fixed price for a period.

    Example:

    Product price: 20$
    Period: 6 nights or any other amount of nights
    Cost: 20$

    I think it should be possible by the option “Booking duration” in the product, but I am missing an option “Customer selection” or so. Or am I missing something else?

    Thanks for an answer,

    Best regards,

    Christoph

     

    #7557
    Ashanna
    Plugin's author

    Hello,

    You can use this filter to always return the base price (without multiplying it by booking duration):

    add_filter( 'easy_booking_two_dates_price', 'easy_booking_return_base_price', 10, 5 );
     
    function easy_booking_return_base_price( $booking_price, $product, $_product, $data, $price_type ) {
        
        $prices_include_tax = get_option('woocommerce_prices_include_tax');
        $price = ( $price_type === 'regular_price' ) ? $_product->get_regular_price() : $_product->get_price();
        $args = array( 'price' => $price );       
        $price = $prices_include_tax === 'yes' ? wc_get_price_including_tax( $_product, $args ) : wc_get_price_excluding_tax( $_product, $args );
     
        return $price;
        
    }

    Add the code to your theme’s functions.php.

    Then, if I understand well:

    • Set product price to $20.
    • Booking duration: Daily
    • Minimum booking duration: 6

    Now this will be applied to all your bookable products. You can have a more specific (but not free) solution with the Duration Discounts add-on.

    Tell me if this is not what you needed 🙂

    Regards,
    Natasha

    #7558
    Christoph
    Participant

    Hi Natasha,

    thank you for the quick answer. Your snippet works, unfortunately as you said only for all products. If I needed it only on specific simple or variable product pages, that would work, I could implement a check in my code. But I need it in a bundle product. Within the bundle, there is 1 variable (bookable) product where I only need the base price, the other product prices in the bundle are calculated per duration as it already works from default in your plugin.

    I already bought the duration discount plugin, but how is this configurable on a variation level?

    I tried many possibilities, but it didn’t work.

    Best regards,

    Christoph

    #7559
    Ashanna
    Plugin's author

    Ok, so I think you could do this:

    add_filter( 'easy_booking_two_dates_price', 'easy_booking_return_base_price', 10, 5 );
     
    function easy_booking_return_base_price( $booking_price, $product, $_product, $data, $price_type ) {
        
        $product_id = $product->get_id();
        $child_id   = $_product->get_id();
    
        if ( $product_id == '79' && $child_id == '93' ) {
    
            $prices_include_tax = get_option('woocommerce_prices_include_tax');
            $price = ( $price_type === 'regular_price' ) ? $_product->get_regular_price() : $_product->get_price();
            $args = array( 'price' => $price );       
            $price = $prices_include_tax === 'yes' ? wc_get_price_including_tax( $_product, $args ) : wc_get_price_excluding_tax( $_product, $args );
            return $price;
    
        }
     
        return $booking_price;
        
    }

    Replace 79 with the ID of your bundle (parent product) and 93 with the ID of the bundled variable product.

    Otherwise, you can mix bookable and non-bookable items in a bundle. This way you can have some products with a “normal” price (not multiplied). There’s only a small issue in the plugin right now (I’ll fix it in the next update), but if you want to try now:

    • In woocommerce-easy-booking-system/includes/class-wceb-ajax.php
    • Find lines 260-264 and replace them with:
    $child_new_price = wc_format_decimal( $children_prices[$child_id]['price'] );
    
    if ( isset( $children_prices[$child_id]['regular_price'] ) ) {
        $child_new_regular_price = wc_format_decimal( $children_prices[$child_id]['regular_price'] );
    }

    Now you can have your variable product not bookable and the price will not be multiplied.

    #7560
    Christoph
    Participant

    Hi Natasha,

    thank you, but unfortunately your snippet doesn’t work for me. I am sure to have set the IDs correctly. Are you sure, it also works with x variations as childs below the variable product?

    On the other side, I managed to solve it directly in class-wceb-ajax.php in line 249:

    if ($child_id !== 47011)	{
    								if ( $number_of_dates === 'two' ) {
    									$price *= $duration;
    								}
    							}

    However, your solution would have been a lot more smarter 😉  I can’t tell where the problem is, I think the code isn’t even considered.

    I certainly would have preferred a non-bookable product, but in this case, we definetly need the booking functionality.

    Best regards,

    Christoph

    #7563
    Ashanna
    Plugin's author

    Hello,

    Good if it works, but it will be overwritten by updates, so it’s not a very good solution.

    It works with variations, in this case $child_id needs to be the ID of the variation (not the parent product). And $product_id is the ID of the bundle product.

    To be sure that the code is considered, use this instead:

    add_filter( 'easy_booking_two_dates_price', 'easy_booking_return_base_price', 10, 5 );
     
    function easy_booking_return_base_price( $booking_price, $product, $_product, $data, $price_type ) {
    
    	$prices_include_tax = get_option('woocommerce_prices_include_tax');
    	$price = ( $price_type === 'regular_price' ) ? $_product->get_regular_price() : $_product->get_price();
    	$args = array( 'price' => $price );       
    	$price = $prices_include_tax === 'yes' ? wc_get_price_including_tax( $_product, $args ) : wc_get_price_excluding_tax( $_product, $args );
    	return $price;
        
    }

    It should return the base price (not multiplied) for everything. If it doesn’t, then maybe you didn’t put the code at the right place?

    Regards,
    Natasha

    #7568
    Christoph
    Participant

    Hi Natasha,

    thanks a lot!

    I was misleaded, I thought the child_id should be the id of the variable product. Sorry about that.

    Now, as I tested the variations’ id, and it works fine.

     

    Best regards,

    Christoph

     

    #7569
    Ashanna
    Plugin's author

    Sorry, I should have been more precise!

    Good if it works 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘[Resolved] Fixed price per period?’ is closed to new replies.

Want to know what's next with Easy Booking? Check the roadmap!