Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ashanna

    (@morki)

    Hello,

    You can add this code to your functions.php file :

    add_filter('easy_booking_fragments', 'easy_booking_custom_price_fragment', 10, 1);
    
    function easy_booking_custom_price_fragment( $fragments ) {
    
        $product_id = isset( $_POST['product_id'] ) ? absint( $_POST['product_id'] ) : '';
        $variation_id = isset( $_POST['variation_id'] ) ? absint( $_POST['variation_id'] ) : '';
    
        $id = empty( $variation_id ) ? $product_id : $variation_id;
    
        $booking_session = WC()->session->get( 'booking' );
        $new_price = $booking_session[$id]['new_price']; // New booking price
        $args = apply_filters( 'easy_booking_new_price_args', array() );
    
        $duration = $booking_session[$id]['duration'];
    
        $fragments['span.price'] = '<span class="price">This is an approximate price for ' . $duration . ' days: ' . wc_price( $new_price, $args ) . '</span>';
    
        return $fragments;
    }

    Just change the text as you want.

    Thread Starter swd_agency

    (@swd_agency)

    Hi,

    Thank you for the code, but I couldn’t make it working!

    Where is the code that generates the price, in class-wceb-ajax.php?

    I could do something that looks like what I needed, but by adding my HTML code directly in the file class-wceb-ajax.php (L~70-90). Is there a way to do it using the “clean” way?

    Thank you a lot for your answer ??
    Really great plugin!!

    Plugin Author Ashanna

    (@morki)

    Well, the “clean” way is the code I told you in the previous post. What’s not working ? Any error ? Did you modify anything ?

    Thread Starter swd_agency

    (@swd_agency)

    Resolved

    Thread Starter swd_agency

    (@swd_agency)

    omg, what a fool… Everything is alright!!

    Thank you very much for your help and sorry for saying it wasn’t working…

    Plugin Author Ashanna

    (@morki)

    Haha, ok great, I was really wondering why it would not work ! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Text before dynamic price’ is closed to new replies.