- changed status to resolved
BUG - WC_Product_Appointment_Rule_Manager::check_availability_rules_against_date
Issue #414
resolved
The code have multiple returns [1099] and [1114] causing newly added woocommerce_appointments_is_date_appointable filter never to execute.
Cheers,
Mattias
/**
* Check a date against the availability rules
*
* @version 4.0.0 Added woocommerce_appointments_is_date_appointable filter hook
* @version 2.7 Moved to this class from WC_Product_Appointment
* only apply rules if within their scope
* keep appointment value alive within the loop to ensure the next rule with higher power can override
* @version 2.6 Removed all calls to break 2 to ensure we get to the highest
* priority rules, otherwise higher order/priority rules will not
* override lower ones and the function exit with the wrong value.
*
*
* @param WC_Product_Appointment $appointable_product
* @param int $staff_id
* @param int $check_date timestamp
* @return bool available or not
*/
public static function check_availability_rules_against_date( $appointable_product, $check_date, $staff_id, $get_capacity = false, $appointable = null ) {
if ( is_null( $appointable ) ) {
$appointable = $appointable_product->get_default_availability();
}
// Rules.
$rules = $appointable_product->get_availability_rules( $staff_id );
// Capacity.
$capacity = $appointable_product->get_available_qty( $staff_id );
#var_dump($capacity);
foreach ( $rules as $rule ) {
if ( self::does_rule_apply( $rule, $check_date ) ) {
// passing $appointable into the next check as it overrides the previous value
$appointable = self::check_timestamp_against_rule( $check_date, $rule, $appointable, $capacity, $get_capacity );
}
}
return $appointable;
/**
* Is date appointable hook.
*
* Filter allows for overriding whether or not date is appointable. Filters should return true
* if appointable or false if not.
*
* @since 4.0.0
*
* @param bool $appointable available or not
* @param WC_Product_Appointment $appointable_product
* @param int $staff_id
* @param int $check_date timestamp
*/
return apply_filters( 'woocommerce_appointments_is_date_appointable', $appointable, $appointable_product, $check_date, $staff_id, $get_capacity );
}
Comments (1)
-
- Log in to comment
Fixed with 4.1.5