Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation

Status::render_content()protectedWC 1.0

This renders the content of the block within the wrapper.

Method of the class: Status{}

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->render_content( $order, $permission, $attributes, $content );
$order(\WC_Order) (required)
Order object.
$permission(string|false)
If the current user can view the order details or not.
Default: false
$attributes(array)
Block attributes.
Default: []
$content(string)
Original block content.
Default: ''

Status::render_content() code WC 8.9.0

protected function render_content( $order, $permission = false, $attributes = [], $content = '' ) {
	if ( ! $permission ) {
		// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
		return '<p>' . wp_kses_post( apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), null ) ) . '</p>';
	}

	$content = $this->get_hook_content( 'woocommerce_before_thankyou', [ $order->get_id() ] );
	$status  = $order->get_status();

	// Unlike the core handling, this includes some extra messaging for completed orders so the text is appropriate for other order statuses.
	switch ( $status ) {
		case 'cancelled':
			$content .= '<p>' . wp_kses_post(
					// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
				apply_filters(
					'woocommerce_thankyou_order_received_text',
					esc_html__( 'Your order has been cancelled.', 'woocommerce' ),
					$order
				)
			) . '</p>';
			break;
		case 'refunded':
				$content .= '<p>' . wp_kses_post(
					sprintf(
						// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
						apply_filters(
							'woocommerce_thankyou_order_received_text',
							// translators: %s: date and time of the order refund.
							esc_html__( 'Your order was refunded %s.', 'woocommerce' ),
							$order
						),
						wc_format_datetime( $order->get_date_modified() )
					)
				) . '</p>';
			break;
		case 'completed':
			$content .= '<p>' . wp_kses_post(
				// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
				apply_filters(
					'woocommerce_thankyou_order_received_text',
					esc_html__( 'Thank you. Your order has been fulfilled.', 'woocommerce' ),
					$order
				)
			) . '</p>';
			break;
		case 'failed':
			// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
			$order_received_text = apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ), null );
			$actions             = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '" class="button">' . esc_html__( 'Try again', 'woocommerce' ) . '</a> ';

			if ( wc_get_page_permalink( 'myaccount' ) ) {
				$actions .= '<a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '" class="button">' . esc_html__( 'My account', 'woocommerce' ) . '</a> ';
			}

			$content .= '
			<p>' . $order_received_text . '</p>
			<p class="wc-block-order-confirmation-status__actions">' . $actions . '</p>
		';
			break;
		default:
			$content .= '<p>' . wp_kses_post(
				// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
				apply_filters(
					'woocommerce_thankyou_order_received_text',
					esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ),
					$order
				)
			) . '</p>';
			break;
	}

	return $content;
}