0.00  View Cart

Compatibility with “WooCommerce Currency Switcher” by realmag777

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

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;
}