Automattic\WooCommerce\Internal\OrderReviews
ItemEligibility::decide
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.
Метод класса: ItemEligibility{}
Хуков нет.
Возвращает
array{status:string, comment:?WP_Comment, product_id:int, variation_id:int}.
Использование
$result = ItemEligibility::decide( $item, $order ): array;
- $item(WC_Order_Item_Product) (обязательный)
- Order line item.
- $order(WC_Order) (обязательный)
- Order being reviewed.
Список изменений
| С версии 10.8.0 | Введена. |
Код ItemEligibility::decide() ItemEligibility::decide WC 11.2.2
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;
}