Automattic\WooCommerce\Internal\Admin

WcPaySubscriptionsPage::get_store_recent_sales_eligibility()privateWC 1.0

Returns true if the store has an order that has been paid within the last 30 days.

{} Это метод класса: WcPaySubscriptionsPage{}

Хуков нет.

Возвращает

true|false.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_store_recent_sales_eligibility();

Код WcPaySubscriptionsPage::get_store_recent_sales_eligibility() WC 6.6.1

private function get_store_recent_sales_eligibility() {
	$transient_key = 'woocommerce-wcpay-subscriptions_recent_sales_eligibility';

	// Load from cache.
	$is_eligible_cached = get_transient( $transient_key );

	// Valid cache found.
	if ( false !== $is_eligible_cached ) {
		return wc_string_to_bool( $is_eligible_cached );
	}

	// Get a single order that has been paid within the last 30 days.
	$orders = wc_get_orders(
		array(
			'date_created' => '>' . strtotime( '-30 days' ),
			'status'       => wc_get_is_paid_statuses(),
			'limit'        => 1,
			'return'       => 'ids',
		)
	);

	$is_eligible = count( $orders ) >= 1;
	set_transient( $transient_key, wc_bool_to_string( $is_eligible ), DAY_IN_SECONDS );

	return $is_eligible;
}