0.00  View Cart

Compatibility with “WooCommerce Currency Switcher” by realmag777

Add this code to your theme’s functions.php:

add_filter( 'easy_booking_one_date_price', 'currency_switcher_new_price', 20, 5 );
add_filter( 'easy_booking_two_dates_price', 'currency_switcher_new_price', 10, 5 );

function currency_switcher_new_price( $new_price, $product, $_product, $booking_data, $price_type ) {

    if ( class_exists('WOOCS') ) {
        global $WOOCS;

        $currencies = $WOOCS->get_currencies();
        $new_price = $WOOCS->back_convert( $new_price, $currencies[$WOOCS->current_currency]['rate'] );

    }

    return $new_price;
}

add_filter( 'easy_booking_fragments', 'currency_switcher_price_fragment', 10, 1 );

function currency_switcher_price_fragment( $fragments ) {
    if ( isset( $fragments['booking_price'] ) && class_exists('WOOCS') ) {
        global $WOOCS;

        $currencies = $WOOCS->get_currencies();
        $fragments['booking_price'] = $fragments['booking_price'] * $currencies[$WOOCS->current_currency]['rate'];
    }

    return $fragments;
}