0.00  View Cart

Support Easy Booking: Duration Discounts [Resolved] Bad calculation

This topic contains 11 replies, has 2 voices, and was last updated by  Ashanna 3 months, 1 week ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #3261

    Florian
    Participant

    Hello,

    I have some problems trying to create a discount. The settings are in cumulative mode. I want to apply a 150 euros reduction for a 7 days booking and above. As in cumulative mode, it looks like :

    Action : Reduction

    Amount : 150

    Type : Total fixed discount

    From : 7

    To : 7

    However, for a regular price of 70/night and a 7 day booking, I should get a total of 340. I get 420 instead. What is wrong?

    #3263

    Ashanna
    Plugin's author

    Hello,

    You’re right. It works worrectly in “Normal” mode but not in “Cumulative” mode. I’ll check what’s going on and update the plugin as soon as possible, do you have the possibility to switch to “Normal” mode?

    Sorry for the inconvenience.

    Regards,
    Natasha

    #3264

    Florian
    Participant

    Hello,

     

    Thanks for the reply.

    No, I have to use the cumulative mode for my current project.

     

    Kind regards,

    Florian Lorber

    #3265

    Ashanna
    Plugin's author

    Hello,

    I’ve just released an update (1.7.7) which should fix the issue.

    Thanks for reporting it 🙂

    Regards,
    Natasha

    #3272

    Florian
    Participant

    Hello,

     

    It is still not right. I get the proper discount when 7 nights are selected, but as soon as I try to book 8 and more, it goes wrong again.

    See these captures for more details : https://drive.google.com/drive/folders/0B0nfGyRZMcsAMjlqbXRyYlgyazA?usp=sharing

     

    Regards,

     

    Florian Lorber

    #3274

    Ashanna
    Plugin's author

    Ah, I made a little mistake 🙁

    It would be good if you could do the change on your file, then tell me if everything works so I don’t release another update beofre being sure:

    • Open easy-booking-duration-discounts/includes/ebdd-functions.php
    • Find line 105 “continue;”
    • Remove it from line 105 and place it after line 106.

    The whole code from line 96 to 107 should look like this:

    if ( $discount['type'] === 'ebdd_fixed' ) {
                    
    	if ( ( $discount['to'] === 0 && $duration >= $discount['from'] ) || ( $duration >= $discount['from'] && $duration <= $discount['to'] ) ) {
    
    		if ( $discount['action'] === 'ebdd_surcharge' ) {
    			$cumulated_discount += $discount['amount'];
    		} else {
    			$cumulated_discount -= $discount['amount']; 
    		}
                        
    	}
    
    	continue;
    																																  
    }

    Thank you!

    Regards,
    Natasha

    #3283

    Florian
    Participant

    I get different results, but still wrong…

    #3284

    Florian
    Participant

    Now I get 560€ for a 8 night booking, instead of the 410€ expected.

    #3285

    Florian
    Participant

    It seems to behave as in Normal Mode.

    #3286

    Ashanna
    Plugin's author

    Allright, can  you try to replace the above code with this one please:

    if ( $discount['type'] === 'ebdd_fixed' ) {
        
        if (
            ( $discount['to'] == 0 && $duration >= $discount['from'] )
            ||
            ( $discount['to'] != 0 && $duration >= $discount['to'] )
            ||
            ( $duration >= $discount['from'] && $duration < $discount['to'] )
        ) {
    
            if ( $discount['action'] === 'ebdd_surcharge' ) {
                $cumulated_discount += $discount['amount'];
            } else {
                $cumulated_discount -= $discount['amount']; 
            }
            
        }
    
        continue;
    }

    #3287

    Florian
    Participant

    Yes ! It works fine, thank you very much ! 🙂

    By the way, do you plan to work on a number of person based booking system, or do you have any tips in order to achieve that?

     

    Thanks,

     

    #3288

    Ashanna
    Plugin's author

    Hello,

    No it’s not planned, as Easy Booking is used for a lot of different things (like equipemenet renting, etc.) that don’t require to select a number of people. I think you can use WooCommerce Product Addons in order to achieve this (it’s installed on the demo if you want to try).

    Regards,
    Natasha

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

You must be logged in to reply to this topic.