WC_Product_CSV_Exporter::get_percent_complete
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.
Method of the class: WC_Product_CSV_Exporter{}
No Hooks.
Returns
int.
Usage
$WC_Product_CSV_Exporter = new WC_Product_CSV_Exporter(); $WC_Product_CSV_Exporter->get_percent_complete();
Changelog
| Since 11.3.0 | Introduced. |
WC_Product_CSV_Exporter::get_percent_complete() WC Product CSV Exporter::get percent complete code 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 );
}