WC_Privacy::anonymize_refunded_orders()public staticWC 9.8.0

Find and Anonymize refunded orders.

Method of the class: WC_Privacy{}

Returns

Int. Number of orders processed.

Usage

$result = WC_Privacy::anonymize_refunded_orders( $limit );
$limit(int)
Limit orders to process per batch.
Default: 20

Changelog

Since 9.8.0 Introduced.

WC_Privacy::anonymize_refunded_orders() code WC 9.8.5

public static function anonymize_refunded_orders( $limit = 20 ) {
	$option = wc_parse_relative_date_option( get_option( 'woocommerce_anonymize_refunded_orders' ) );

	if ( empty( $option['number'] ) ) {
		return 0;
	}

	return self::anonymize_orders_query(
		/**
		 * Filter to modify the query arguments for anonymizing refunded orders.
		 *
		 * @since 9.8.0
		 *
		 * @param string $date_created The date before which orders should be anonymized.
		 * @param int    $limit The maximum number of orders to process in each batch.
		 * @param string $status The status of the orders to be anonymized.
		 * @param string $type The type of orders to be anonymized.
		 */
		apply_filters(
			'woocommerce_anonymize_refunded_orders_query_args',
			array(
				'date_created' => '<' . strtotime( '-' . $option['number'] . ' ' . $option['unit'] ),
				'limit'        => $limit, // Batches of 20.
				'status'       => OrderInternalStatus::REFUNDED,
				'type'         => 'shop_order',
			)
		)
	);
}