Automattic\WooCommerce\Internal\DataStores\StockNotifications

StockNotificationsDataStore::after_meta_change │ private │ WC 1.0

Perform after meta change operations.

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

Хуков нет.

Возвращает

bool. True if changes were applied, false otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->after_meta_change( $notification ): bool;
$notification(Notification) (обязательный) (передается по ссылке — &)
The notification object.

Код StockNotificationsDataStore::after_meta_change() WC 11.2.2

private function after_meta_change( &$notification ): bool {

	$current_time      = time();
	$current_date_time = new \WC_DateTime( "@$current_time", new \DateTimeZone( 'UTC' ) );

	$should_save =
		$notification->get_id() > 0
		&& $notification->get_date_modified( 'edit' ) < $current_date_time
		&& empty( $notification->get_changes() );

	if ( $should_save ) {
		$notification->set_date_modified( $current_time );
		$saved = $notification->save();
		return ! is_wp_error( $saved );
	}

	return false;
}