Automattic\WooCommerce\Internal\Admin\Orders
EditLock::lock
Assigns an order's edit lock to the current user.
Method of the class: EditLock{}
No Hooks.
Returns
Array|true|false. FALSE if no user is logged-in, an array in the same format as {@see get_lock()} otherwise.
Usage
$EditLock = new EditLock(); $EditLock->lock( $order );
- $order(WC_Order) (required)
- The order to apply the lock to.
EditLock::lock() EditLock::lock code WC 10.4.3
public function lock( \WC_Order $order ) {
$user_id = get_current_user_id();
if ( ! $user_id ) {
return false;
}
$order->update_meta_data( self::META_KEY_NAME, time() . ':' . $user_id );
$order->save_meta_data();
return $order->get_meta( self::META_KEY_NAME, true, 'edit' );
}