Automattic\WooCommerce\Internal\OrderReviews

ItemEligibility::decidepublic staticWC 10.8.0

Decide how an order line item should render on the Review Order page.

Returns one of the STATUS_* constants plus the matched comment (when one exists for this order) and the product id.

Method of the class: ItemEligibility{}

No Hooks.

Returns

Array{status:String,. comment:?WP_Comment, product_id:int, variation_id:int}

Usage

$result = ItemEligibility::decide( $item, $order ): array;
$item(WC_Order_Item_Product) (required)
Order line item.
$order(WC_Order) (required)
Order being reviewed.

Changelog

Since 10.8.0 Introduced.

ItemEligibility::decide() code WC 10.9.1

public static function decide( WC_Order_Item_Product $item, WC_Order $order ): array {
	$product_id   = (int) $item->get_product_id();
	$variation_id = (int) $item->get_variation_id();
	$result       = array(
		'status'       => self::STATUS_FORM,
		'comment'      => null,
		'product_id'   => $product_id,
		'variation_id' => $variation_id,
	);

	if ( $product_id <= 0 || ! comments_open( $product_id ) ) {
		$result['status'] = self::STATUS_SKIP;
		return $result;
	}

	$result['comment'] = self::find_existing_review( $product_id, $variation_id, $order );
	return $result;
}