Dev Resources

  • Home
  • Reference
  • BuddyX Theme
  • Functions
  • Hooks
  • Classes
Filter by type:
Search
Browse: Home / Reference / Classes / WC_Shortcode_My_Account / WC_Shortcode_My_Account::view_order()

WC_Shortcode_My_Account::view_order( int $order_id )

View order page.

Contents

  • Description
    • Parameters
    • Source
  • Related
    • Uses
    • Used By
  • User Contributed Notes

Description #Description


Parameters #Parameters

$order_id

(Required) Order ID.


Top ↑

Source #Source

File: includes/shortcodes/class-wc-shortcode-my-account.php

	public static function view_order( $order_id ) {
		$order = wc_get_order( $order_id );

		if ( ! $order || ! current_user_can( 'view_order', $order_id ) ) {
			echo '<div class="woocommerce-error">' . esc_html__( 'Invalid order.', 'woocommerce' ) . ' <a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '" class="wc-forward">' . esc_html__( 'My account', 'woocommerce' ) . '</a></div>';

			return;
		}

		// Backwards compatibility.
		$status       = new stdClass();
		$status->name = wc_get_order_status_name( $order->get_status() );

		wc_get_template(
			'myaccount/view-order.php',
			array(
				'status'   => $status, // @deprecated 2.2.
				'order'    => $order,
				'order_id' => $order->get_id(),
			)
		);
	}

Expand full source code Collapse full source code


Top ↑

Related #Related

Top ↑

Uses #Uses

Uses
Uses Description
includes/wc-core-functions.php: wc_get_template()

Get other templates (e.g. product attributes) passing attributes and including the file.

includes/wc-order-functions.php: wc_get_order_status_name()

Get the nice name for an order status.

includes/wc-order-functions.php: wc_get_order()

Main function for returning orders, uses the WC_Order_Factory class.

includes/wc-page-functions.php: wc_get_page_permalink()

Retrieve page permalink.

Top ↑

Used By #Used By

Used By
Used By Description
includes/wc-template-functions.php: woocommerce_account_view_order()

My Account > View order template.


Top ↑

User Contributed Notes #User Contributed Notes

You must log in before being able to contribute a note or feedback.

Proudly powered by WordPress