FOX - WooCommerce Currency Switcher Professional

WooCommerce Easy Booking (by @_Ashanna)

Plugin link: WooCommerce Easy Booking

The code is taken from here: http://herownsweetcode.com/easy-booking/documentation/easy-booking/compatibility-with-other-plugins/woocommerce-currency-switcher/


Add next code to your theme functions.php (Easy Booking 2.0.9 or higher):

add_filter( 'easy_booking_two_dates_price', 'currency_switcher_new_price', 2, 1 );

function currency_switcher_new_price( $booking_price ) {

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

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

    }

    return $booking_price;
}

add_filter( 'easy_booking_one_date_price', 'currency_switcher_new_price', 2, 1 );

function currency_switcher_new_price( $booking_price ) {

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

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

    }

    return $booking_price;
}

 


Add next code to your theme functions.php (Easy Booking 2.0.6 or lower):

add_filter( 'easy_booking_get_new_item_price', 'currency_switcher_new_price', 2, 4 );

function currency_switcher_new_price( $booking_price, $product, $_product, $duration ) {

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

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

    }

    return $booking_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;
}