Automattic\WooCommerce\Blocks\Domain\Services
DraftOrders::assert_order_results()
Asserts whether incoming order results are expected given the query this service class executes.
Метод класса: DraftOrders{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->assert_order_results( $order_results, $expected_batch_size );
- $order_results(WC_Order[]) (обязательный)
- The order results being asserted.
- $expected_batch_size(int) (обязательный)
- The expected batch size for the results.
Код DraftOrders::assert_order_results() DraftOrders::assert order results WC 8.7.0
private function assert_order_results( $order_results, $expected_batch_size ) { // if not an array, then just return because it won't get handled // anyways. if ( ! is_array( $order_results ) ) { return; } $suffix = ' This is an indicator that something is filtering WooCommerce or WordPress queries and modifying the query parameters.'; // if count is greater than our expected batch size, then that's a problem. if ( count( $order_results ) > 20 ) { throw new Exception( 'There are an unexpected number of results returned from the query.' . $suffix ); } // if any of the returned orders are not draft (or not a WC_Order), then that's a problem. foreach ( $order_results as $order ) { if ( ! ( $order instanceof WC_Order ) ) { throw new Exception( 'The returned results contain a value that is not a WC_Order.' . $suffix ); } if ( ! $order->has_status( self::STATUS ) ) { throw new Exception( 'The results contain an order that is not a `wc-checkout-draft` status in the results.' . $suffix ); } } }