WC_Email_Customer_Review_Request::is_order_eligible_for_send
Defence-in-depth status check at send time.
The scheduler unschedules the pending action when the order leaves completed, but a race window or a direct invocation of the action hook can still reach trigger() for an order that is no longer in an eligible state. Checking the same woocommerce_review_order_eligible_statuses the page-load endpoint and submission handler use keeps the three entry points consistent.
Method of the class: WC_Email_Customer_Review_Request{}
Hooks from the method
Returns
true|false.
Usage
// protected - for code of main (parent) or child class $result = $this->is_order_eligible_for_send(): bool;
Changelog
| Since 10.8.0 | Introduced. |
WC_Email_Customer_Review_Request::is_order_eligible_for_send() WC Email Customer Review Request::is order eligible for send code WC 10.9.4
protected function is_order_eligible_for_send(): bool {
if ( ! $this->object instanceof WC_Order ) {
return false;
}
/**
* Filter the order statuses that are eligible to receive the review-request email.
*
* Defaults to `completed` only. Same hook the page-load endpoint and the
* submission handler use, so the three entry points stay aligned.
*
* @since 10.8.0
*
* @param string[] $eligible_statuses Default: `[ 'completed' ]`.
* @param WC_Order $order Order being inspected.
*/
$eligible_statuses = (array) apply_filters(
'woocommerce_review_order_eligible_statuses',
array( OrderStatus::COMPLETED ),
$this->object
);
if ( ! in_array( $this->object->get_status(), $eligible_statuses, true ) ) {
return false;
}
// Eligibility can change between scheduling and sending (e.g. the
// admin disables site-wide reviews during the delay window, or the
// customer reviews everything via another entry point). Re-check at
// send time so the email is silently dropped instead of pointing
// the customer at the empty-state page.
return ItemEligibility::has_actionable_items( $this->object );
}