Automattic\WooCommerce\Database\Migrations\CustomOrderTable
CLIRunner::get_verify_order_count()
Helper method to get count for orders needing verification.
Method of the class: CLIRunner{}
No Hooks.
Return
Int
. Order count.
Usage
// private - for code of main (parent) class only $result = $this->get_verify_order_count( $order_id_start, $order_id_end, $order_types, $log ): int;
- $order_id_start(int) (required)
- Order ID to start from.
- $order_id_end(int) (required)
- Order ID to end at.
- $order_types(array) (required)
- List of order types to verify.
- $log(true|false)
- Whether to also log an error message.
Default: true
CLIRunner::get_verify_order_count() CLIRunner::get verify order count code WC 9.7.1
private function get_verify_order_count( int $order_id_start, int $order_id_end, array $order_types, bool $log = true ): int { global $wpdb; $order_types_placeholder = implode( ',', array_fill( 0, count( $order_types ), '%s' ) ); // phpcs:disable WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Inputs are prepared. $order_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type in ($order_types_placeholder) AND ID >= %d AND ID <= %d", array_merge( $order_types, array( $order_id_start, $order_id_end, ) ) ) ); // phpcs:enable if ( $log ) { WP_CLI::log( sprintf( /* Translators: %1$d is the number of orders to be verified. */ _n( 'There is %1$d order to be verified.', 'There are %1$d orders to be verified.', $order_count, 'woocommerce' ), $order_count ) ); } return $order_count; }