Automattic\WooCommerce\Internal\DataStores\StockNotifications
StockNotificationsDataStore::after_meta_change
Perform after meta change operations.
Method of the class: StockNotificationsDataStore{}
No Hooks.
Returns
true|false. True if changes were applied, false otherwise.
Usage
// private - for code of main (parent) class only $result = $this->after_meta_change( $notification ): bool;
- $notification(Notification) (required) (passed by reference — &)
- The notification object.
StockNotificationsDataStore::after_meta_change() StockNotificationsDataStore::after meta change code WC 10.3.6
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;
}