0.00  View Cart

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

add_filter( 'easy_booking_set_booking_price', 'wceb_yith_deposit_price', 10, 2 );

function wceb_yith_deposit_price( $booking_price, $cart_item ) {

	if ( isset( $cart_item['deposit'] ) && true === $cart_item['deposit'] && isset( $cart_item['deposit_value'] ) ) {
		$product = $cart_item['data'];
		$product_id = $product->is_type( 'variation' ) ? yit_get_prop( $product, 'parent_id' ) : $product->get_id();
		$variation_id = $product->is_type( 'variation' ) ? $product->get_id() : false;

		$booking_price = YITH_WCDP_Premium()->get_deposit( $product_id, $booking_price, false, $variation_id );
	}

	return $booking_price;
}

if ( defined( 'YITH_WCDP' ) && ! function_exists( 'yith_wcdp_update_deposit_value' ) ) {

    function yith_wcdp_update_deposit_value( $deposit_value, $product_id, $variation_id, $cart_item ) {

        if ( isset( $cart_item['_booking_price'] ) ) {
            $deposit_value = YITH_WCDP_Premium()->get_deposit( $product_id, $cart_item['_booking_price'], false, $variation_id );
        }

        return $deposit_value;
    }

    add_filter( 'yith_wcdp_deposit_value', 'yith_wcdp_update_deposit_value', 10, 4 );

}

if ( defined( 'YITH_WCDP' ) && ! function_exists( 'yith_wcdp_update_deposit_balance' ) ) {

    function yith_wcdp_update_deposit_balance( $deposit_balance, $product_id, $variation_id, $cart_item ) {

        if ( isset( $cart_item['_booking_price'] ) ) {
            $deposit_balance = max( $cart_item['_booking_price'] - YITH_WCDP_Premium()->get_deposit( $product_id, $cart_item['_booking_price'], false, $variation_id ), 0 );
        }

        return $deposit_balance;
    }

	add_filter( 'yith_wcdp_deposit_balance', 'yith_wcdp_update_deposit_balance', 10, 4 );

}