0.00  View cart

Support Easy Booking: Pricing Global Discount for All Booking Product

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #7562


    I would like to ask.

    I have the following use case.

    I have rooms which has base price set to 2,000THB (for example)

    On Fri, Sat, Public holiday these rooms price will be 2,500THB

    Now, We have seasonal sales I would like to discount all rooms all days for 20% or fixed discount 500THB.

    How can I apply global discount for all booking product ?

    • For all date using custom price also.

    Is there any actions/filters hook for this scenario ? (I can write some code.)


    Plugin's author


    There is not filter or action hook, you can use this function but it’s a bit risky (read carefully please):

    function set_seasonal_prices() {
        $seasonal_prices = array(
            0 => array(
                'type'     => 'ebp_daterange',
                'date'     => array( '2019-12-20', '2019-12-31' ),
                'repeat'   => 'on',
                'price'    => '1500',
                'unit'     => 'ebp_single'
        $args = array(
            'post_type'      => array( 'product', 'product_variation' ),
            'posts_per_page' => -1,
            'post_status'    => 'publish'
        $query = new WP_Query( $args );
        while ( $query->have_posts() ) : $query->the_post();
            global $post;
            $post_id = $post->ID;
            // Get already set prices
            $product_prices = (array) get_post_meta( $post_id, '_ebp_product_prices', true );
            // Merge arrays
            $prices = array_merge( $product_prices, $seasonal_prices );
            update_post_meta( $post_id, '_ebp_product_prices', $prices );

    Now be careful. Put it in your theme’s functions.php and reload your website once. Then remove the function. I insist on loading your website only once, otherwise prices will be added several times and then you’ll need to delete all prices in order to start fresh. So please make a backup of your database before using this.

    Replace array( ‘2019-12-20’, ‘2019-12-31’ ) in line 6 with your own dates. You an also set “repeat” to “off” if you want (line 7).

    I hope this helps. And sorry it’s a bit far-fetched, I need to add more filters/action hooks to the plugins. I’m also thinking about adding “Global prices” (like the other addons) that will apply to all products. I didn’t want to do it at first because all products can have a different price, but it seems that a lot of people need this feature.


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

You must be logged in to reply to this topic.

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