WC_Product_CSV_Exporter::get_percent_complete │ public │ WC 11.3.0

Get total percentage complete.

Variations appended after the paginated query are written on this page, but total_rows does not include them. Leave them out of this calculation so the export finishes at 100 instead of stopping early or requesting pages forever.

Метод класса: WC_Product_CSV_Exporter{}

Хуков нет.

Возвращает

int.

Использование

$WC_Product_CSV_Exporter = new WC_Product_CSV_Exporter();
$WC_Product_CSV_Exporter->get_percent_complete();

Список изменений

С версии 11.3.0 Введена.

Код WC_Product_CSV_Exporter::get_percent_complete() WC 11.3.0

public function get_percent_complete() {
	if ( 0 === $this->total_rows ) {
		return 100;
	}

	$exported = parent::get_total_exported() - $this->rows_outside_query;

	return (int) floor( ( max( 0, $exported ) / $this->total_rows ) * 100 );
}