Automattic\WooCommerce\Internal\Admin\Orders

PageController::get_edit_url()publicWC 1.0

Helper method to generate edit link for an order.

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

Хуков нет.

Возвращает

Строку. Edit link.

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

$PageController = new PageController();
$PageController->get_edit_url( $order_id ) : string;
$order_id(int) (обязательный)
Order ID.

Код PageController::get_edit_url() WC 8.9.0

public function get_edit_url( int $order_id ) : string {
	if ( ! wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() ) {
		return admin_url( 'post.php?post=' . absint( $order_id ) ) . '&action=edit';
	}

	$order = wc_get_order( $order_id );

	// Confirm we could obtain the order object (since it's possible it will not exist, due to a sync issue, or may
	// have been deleted in a separate concurrent request).
	if ( false === $order ) {
		wc_get_logger()->debug(
			sprintf(
				/* translators: %d order ID. */
				__( 'Attempted to determine the edit URL for order %d, however the order does not exist.', 'woocommerce' ),
				$order_id
			)
		);
		$order_type = 'shop_order';
	} else {
		$order_type = $order->get_type();
	}

	return add_query_arg(
		array(
			'action' => 'edit',
			'id'     => absint( $order_id ),
		),
		$this->get_base_page_url( $order_type )
	);
}