get_order(); $classname = StyleAttributesUtils::get_classes_by_attributes( $attributes, array( 'extra_classes' ) ); if ( isset( $attributes['align'] ) ) { $classname .= " align{$attributes['align']}"; } $block = parent::render( $attributes, $content, $block ); if ( ! $block ) { return ''; } $additional_content = $this->render_confirmation_notice( $order ); if ( $additional_content ) { $block = $block . sprintf( '
%2$s
', esc_attr( trim( $classname ) ), $additional_content ); } return $block; } /** * This renders the content of the block within the wrapper. * * @param \WC_Order $order Order object. * @param string|false $permission If the current user can view the order details or not. * @param array $attributes Block attributes. * @param string $content Original block content. * @return string */ protected function render_content( $order, $permission = false, $attributes = [], $content = '' ) { if ( ! $permission ) { // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment return '

' . wp_kses_post( apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), null ) ) . '

'; } $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 .= '

' . wp_kses_post( /** * Filter the title shown after a checkout is complete. * * @since 9.7.0 * * @param string $title The title. * @param \WC_Order $order The order created during checkout. */ apply_filters( 'woocommerce_thankyou_order_received_title', esc_html__( 'Order cancelled', 'woocommerce' ), $order ) ) . '

'; $content .= '

' . 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 ) ) . '

'; break; case 'refunded': $content .= '

' . wp_kses_post( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment apply_filters( 'woocommerce_thankyou_order_received_title', esc_html__( 'Order refunded', 'woocommerce' ), $order ) ) . '

'; $content .= '

' . 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() ) ) ) . '

'; break; case 'completed': $content .= '

' . wp_kses_post( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment apply_filters( 'woocommerce_thankyou_order_received_title', esc_html__( 'Order completed', 'woocommerce' ), $order ) ) . '

'; $content .= '

' . 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 ) ) . '

'; break; case 'failed': $default_order_failed_text = esc_html__( 'Your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); // Null, not $order: passing the real order would let WC_Gateway_Paypal::order_received_text() // overwrite this failure message with PayPal success copy, since that callback checks the // payment method but not the order status. // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment $legacy_order_failed_text = apply_filters( 'woocommerce_thankyou_order_received_text', $default_order_failed_text, null ); $order_failed_text = is_string( $legacy_order_failed_text ) ? $legacy_order_failed_text : $default_order_failed_text; /** * Filters the message shown when an order has failed. * * Runs after the legacy order-received filter so callbacks can customize the final failed-order message. * * @param string $message The failed order message. * @param \WC_Order $order The failed order. * * @since 11.2.0 */ $filtered_order_failed_text = apply_filters( 'woocommerce_thankyou_order_failed_text', $order_failed_text, $order ); $order_failed_text = is_string( $filtered_order_failed_text ) ? $filtered_order_failed_text : $order_failed_text; $actions = '' . esc_html__( 'Try again', 'woocommerce' ) . ' '; if ( wc_get_page_permalink( 'myaccount' ) ) { $actions .= '' . esc_html__( 'My account', 'woocommerce' ) . ' '; } $content .= '

' . wp_kses_post( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment apply_filters( 'woocommerce_thankyou_order_received_title', esc_html__( 'Order failed', 'woocommerce' ), $order ) ) . '

'; $content .= '

' . wp_kses_post( $order_failed_text ) . '

' . $actions . '

'; break; default: $content .= '

' . wp_kses_post( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment apply_filters( 'woocommerce_thankyou_order_received_title', esc_html__( 'Order received', 'woocommerce' ), $order ) ) . '

'; $content .= '

' . 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 ) ) . '

'; break; } return $content; } /** * This is what gets rendered when the order does not exist. * * @return string */ protected function render_content_fallback() { // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment return '

' . esc_html__( 'Please check your email for the order confirmation.', 'woocommerce' ) . '

'; } /** * If the order is invalid or there is no permission to view the details, tell the user to check email or log-in. * * @param \WC_Order|null $order Order object. * @return string */ protected function render_confirmation_notice( $order = null ) { if ( ! $order ) { $content = '

' . esc_html__( 'If you\'ve just placed an order, give your email a quick check for the confirmation.', 'woocommerce' ); if ( wc_get_page_permalink( 'myaccount' ) ) { $content .= ' ' . sprintf( /* translators: 1: opening a link tag 2: closing a link tag */ esc_html__( 'Have an account with us? %1$sLog in here to view your order details%2$s.', 'woocommerce' ), '', '' ); } $content .= '

'; return $content; } $permission = $this->get_view_order_permissions( $order ); if ( $permission ) { return ''; } $verification_required = $this->email_verification_required( $order ); $verification_permitted = $this->email_verification_permitted( $order ); $my_account_page = wc_get_page_permalink( 'myaccount' ); $content = '

'; $content .= esc_html__( 'Great news! Your order has been received, and a confirmation will be sent to your email address.', 'woocommerce' ); $content .= $my_account_page ? ' ' . sprintf( /* translators: 1: opening a link tag 2: closing a link tag */ esc_html__( 'Have an account with us? %1$sLog in here%2$s to view your order.', 'woocommerce' ), '', '' ) : ''; if ( $verification_required && $verification_permitted ) { $content .= ' ' . esc_html__( 'Alternatively, confirm the email address linked to the order below.', 'woocommerce' ); } $content .= '

'; if ( $verification_required && $verification_permitted ) { $content .= $this->render_verification_form(); } return $content; } /** * Email verification for guest users. * * @return string */ protected function render_verification_form() { // phpcs:ignore WordPress.Security.NonceVerification.Missing $check_submission_notice = ! empty( $_POST ) ? wc_print_notice( esc_html__( 'We were unable to verify the email address you provided. Please try again.', 'woocommerce' ), 'error', [], true ) : ''; return '
' . $check_submission_notice . sprintf( '

', esc_attr( 'verify-email' ), esc_html__( 'Email address', 'woocommerce' ) . ' *' ) . sprintf( '

%3$s

', esc_attr( 'verify-email-submit' ), esc_html__( 'Confirm email and view order', 'woocommerce' ), wp_nonce_field( 'wc_verify_email', '_wpnonce', true, false ), esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ) ) . '
'; } }