Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation
Status::render_content │ protected │ WC 1.0
This renders the content of the block within the wrapper.
Method of the class: Status{}
Returns
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() Status::render content code
WC 10.4.3
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 .= '<h1>' . wp_kses_post(
/**
* Filter the title shown after a checkout is complete.
*
* @since 9.6.0
*
* @param string $title The title.
* @param WC_Order|false $order The order created during checkout, or false if order data is not available.
*/
apply_filters(
'woocommerce_thankyou_order_received_title',
esc_html__( 'Order cancelled', 'woocommerce' ),
$order
)
) . '</h1>';
$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 .= '<h1>' . wp_kses_post(
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
apply_filters(
'woocommerce_thankyou_order_received_title',
esc_html__( 'Order refunded', 'woocommerce' ),
$order
)
) . '</h1>';
$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 .= '<h1>' . wp_kses_post(
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
apply_filters(
'woocommerce_thankyou_order_received_title',
esc_html__( 'Order completed', 'woocommerce' ),
$order
)
) . '</h1>';
$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 .= '<h1>' . wp_kses_post(
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
apply_filters(
'woocommerce_thankyou_order_received_title',
esc_html__( 'Order failed', 'woocommerce' ),
$order
)
) . '</h1>';
$content .= '
<p>' . $order_received_text . '</p>
<p class="wc-block-order-confirmation-status__actions">' . $actions . '</p>
';
break;
default:
$content .= '<h1>' . wp_kses_post(
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
apply_filters(
'woocommerce_thankyou_order_received_title',
esc_html__( 'Order received', 'woocommerce' ),
$order
)
) . '</h1>';
$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;
}