Automattic\WooCommerce\Internal\Admin\Orders

EditLock::render_dialog()publicWC 1.0

Outputs HTML for the lock dialog based on the status of the lock on the order (if any). Depending on who owns the lock, this could be a message with the chance to take over or a message indicating that someone else has taken over the order.

Method of the class: EditLock{}

No Hooks.

Return

null. Nothing (null).

Usage

$EditLock = new EditLock();
$EditLock->render_dialog( $order );
$order(\WC_Order) (required)
Order object.

EditLock::render_dialog() code WC 9.3.3

<?php
public function render_dialog( $order ) {
	$lock   = $this->get_lock( $order );
	$user   = $lock ? get_user_by( 'id', $lock['user_id'] ) : false;
	$locked = $user && ( get_current_user_id() !== $user->ID );

	$edit_url = wc_get_container()->get( \Automattic\WooCommerce\Internal\Admin\Orders\PageController::class )->get_edit_url( $order->get_id() );

	$sendback_url = wp_get_referer();
	if ( ! $sendback_url ) {
		$sendback_url = wc_get_container()->get( \Automattic\WooCommerce\Internal\Admin\Orders\PageController::class )->get_base_page_url( $order->get_type() );
	}

	$sendback_text = __( 'Go back', 'woocommerce' );
	?>
	<div id="post-lock-dialog" class="notification-dialog-wrap <?php echo $locked ? '' : 'hidden'; ?> order-lock-dialog">
		<div class="notification-dialog-background"></div>
		<div class="notification-dialog">
		<?php if ( $locked ) : ?>
		<div class="post-locked-message">
			<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
			<p class="currently-editing wp-tab-first" tabindex="0">
			<?php
			// translators: %s is a user's name.
			echo esc_html( sprintf( __( '%s is currently editing this order. Do you want to take over?', 'woocommerce' ), esc_html( $user->display_name ) ) );
			?>
			</p>
			<p>
				<a class="button" href="<?php echo esc_url( $sendback_url ); ?>"><?php echo esc_html( $sendback_text ); ?></a>
				<a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'claim-lock', '1', wp_nonce_url( $edit_url, 'claim-lock-' . $order->get_id() ) ) ); ?>"><?php esc_html_e( 'Take over', 'woocommerce' ); ?></a>
			</p>
		</div>
		<?php else : ?>
		<div class="post-taken-over">
			<div class="post-locked-avatar"></div>
			<p class="wp-tab-first" tabindex="0">
			<span class="currently-editing"></span><br />
			</p>
			<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback_url ); ?>"><?php echo esc_html( $sendback_text ); ?></a></p>
		</div>
		<?php endif; ?>
		</div>
	</div>
	<?php
}