Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation

AbstractOrderConfirmationBlock::get_view_order_permissions()protectedWC 1.0

View mode for order details based on the order, current user, and settings.

Method of the class: AbstractOrderConfirmationBlock{}

Return

String|false. Returns "full" if the user can view all order details. False if they can view no details.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_view_order_permissions( $order );
$order(\WC_Order|null) (required)
Order object.

AbstractOrderConfirmationBlock::get_view_order_permissions() code WC 9.8.2

protected function get_view_order_permissions( $order ) {
	if ( ! $order || ! $this->has_valid_order_key( $order ) ) {
		return false; // Always disallow access to invalid orders and those without a valid key.
	}

	// For customers with accounts, verify the order belongs to the current user or disallow access.
	if ( $this->is_customer_order( $order ) ) {
		/**
		 * Indicates if known (non-guest) shoppers need to be logged in before we let
		 * them access the order received page.
		 *
		 * @param bool $verify_known_shoppers If verification is required.
		 *
		 * @since 8.4.0
		 */
		$verify_known_shoppers = apply_filters( 'woocommerce_order_received_verify_known_shoppers', true );

		// If verification for known shoppers is disabled, we can show the order details.
		if ( ! $verify_known_shoppers ) {
			return 'full';
		}

		return $this->is_current_customer_order( $order ) ? 'full' : false;
	}

	// Guest orders are displayed only within the grace period or after verification. If email verification is required, return false.
	return $this->email_verification_required( $order ) ? false : 'full';
}