0.00  View Cart

Add this code to your theme’s functions.php (only tested with the free version):

add_filter( 'woocommerce_add_cart_item_data', 'wceb_yith_deposit_data', 35, 3 );

function wceb_yith_deposit_data( $cart_item_meta, $product_id, $variation_id ) {

	if ( class_exists( 'YITH_WCDP' ) ) {

		if( YITH_WCDP()->is_deposit_enabled_on_product( $product_id ) ) {

			$deposit_forced = YITH_WCDP()->is_deposit_mandatory( $product_id );

			$process_deposit = ( $deposit_forced && ! defined( 'YITH_WCDP_PROCESS_SUBORDERS' ) ) || ( isset( $_REQUEST['payment_type'] ) && $_REQUEST['payment_type'] == 'deposit' );

			if ( apply_filters( 'yith_wcdp_process_deposit', $process_deposit ) && isset( $cart_item_meta['_booking_price'] ) ) {

		        $cart_item_meta['deposit_value'] = YITH_WCDP()->get_deposit( $product_id, $cart_item_meta['_booking_price'] ) * $cart_item_meta['_booking_duration'];
		        $cart_item_meta['deposit_balance'] = max( $cart_item_meta['_booking_price'] - $cart_item_meta['deposit_value'], 0 );

			}
		}

	}

	return $cart_item_meta;
}

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

function wceb_yith_deposit_price( $booking_price, $cart_item ) {

	if ( class_exists( 'YITH_WCDP' ) ) {

		$product = $cart_item['data'];
		$product_id = $product->id;

		if ( YITH_WCDP()->is_deposit_enabled_on_product( $product ) ) {

			$deposit_forced = YITH_WCDP()->is_deposit_mandatory( $product_id );

			if ( ( $deposit_forced && ! defined( 'YITH_WCDP_PROCESS_SUBORDERS' ) ) || ( isset( $_REQUEST['payment_type'] ) && $_REQUEST['payment_type'] == 'deposit' ) ) {

				$booking_price = YITH_WCDP()->get_deposit( $product_id, $cart_item['_booking_price'] ) * $cart_item['_booking_duration'];
			}
		}

	}

	return $booking_price;
}