From 88eda68fd318bc818e64921face49f99a699a231 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 3 Jul 2023 11:24:29 +0100 Subject: [PATCH] Add name/description for status block and missing text descriptions in the block. Closes #10057 --- .../order-confirmation/status/block.json | 4 +- .../order-confirmation/status/index.tsx | 5 +- .../order-confirmation/summary/block.json | 4 +- src/BlockTypes/OrderConfirmation/Status.php | 73 ++++++++++++++++--- 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/assets/js/blocks/order-confirmation/status/block.json b/assets/js/blocks/order-confirmation/status/block.json index e1819f089ac..378b824c81e 100644 --- a/assets/js/blocks/order-confirmation/status/block.json +++ b/assets/js/blocks/order-confirmation/status/block.json @@ -1,8 +1,8 @@ { "name": "woocommerce/order-confirmation-status", "version": "1.0.0", - "title": "Order Confirmation Status", - "description": "Displays a confirmation of the status of an order.", + "title": "Order Status", + "description": "Display a \"thank you\" message, or a sentence regarding the current order status.", "category": "woocommerce", "keywords": [ "WooCommerce" ], "supports": { diff --git a/assets/js/blocks/order-confirmation/status/index.tsx b/assets/js/blocks/order-confirmation/status/index.tsx index b83b17bf6af..8d41e28f2b9 100644 --- a/assets/js/blocks/order-confirmation/status/index.tsx +++ b/assets/js/blocks/order-confirmation/status/index.tsx @@ -2,8 +2,7 @@ * External dependencies */ import { registerBlockType } from '@wordpress/blocks'; -import { Icon } from '@wordpress/icons'; -import { totals } from '@woocommerce/icons'; +import { Icon, info } from '@wordpress/icons'; /** * Internal dependencies @@ -15,7 +14,7 @@ registerBlockType( metadata, { icon: { src: ( ), diff --git a/assets/js/blocks/order-confirmation/summary/block.json b/assets/js/blocks/order-confirmation/summary/block.json index 635f509d0a8..18e2646c97f 100644 --- a/assets/js/blocks/order-confirmation/summary/block.json +++ b/assets/js/blocks/order-confirmation/summary/block.json @@ -1,8 +1,8 @@ { "name": "woocommerce/order-confirmation-summary", "version": "1.0.0", - "title": "Order Confirmation Summary", - "description": "Display a summary of a new order on the order confirmation page.", + "title": "Order Summary", + "description": "Display the order summary on the order confirmation page.", "category": "woocommerce", "keywords": [ "WooCommerce" ], "supports": { diff --git a/src/BlockTypes/OrderConfirmation/Status.php b/src/BlockTypes/OrderConfirmation/Status.php index c818a5a10e2..166c9062ee1 100644 --- a/src/BlockTypes/OrderConfirmation/Status.php +++ b/src/BlockTypes/OrderConfirmation/Status.php @@ -52,25 +52,74 @@ protected function render( $attributes, $content, $block ) { */ protected function render_content( $order ) { $content = $this->get_hook_content( 'woocommerce_before_thankyou', [ $order ] ); + $status = $order->get_status(); - if ( $order->has_status( '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.', 'woo-gutenberg-products-block' ), null ); - $actions = ''; + // Unlike the core handling, this includes some extra messaging for completed orders to the text is appropriate for other order statuses. + switch ( $status ) { + case 'cancelled': + $content .= '

' . wp_kses_post( + // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment + apply_filters( + 'woocommerce_thankyou_order_received_text', + esc_html__( 'Your order has been cancelled.', 'woo-gutenberg-products-block' ), + $order + ) + ) . '

'; + break; + case 'refunded': + $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.', 'woo-gutenberg-products-block' ), + $order + ), + wc_format_datetime( $order->get_date_modified() ) + ) + ) . '

'; + break; + case 'completed': + $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 completion. + esc_html__( 'Your order has been processed and was marked complete %s.', 'woo-gutenberg-products-block' ), + $order + ), + wc_format_datetime( $order->get_date_completed() ) + ) + ) . '

'; + 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.', 'woo-gutenberg-products-block' ), null ); + $actions = ''; - if ( $this->is_current_customer_order( $order ) ) { - $actions .= '' . esc_html__( 'Try again', 'woo-gutenberg-products-block' ) . ' '; - } + if ( $this->is_current_customer_order( $order ) ) { + $actions .= '' . esc_html__( 'Try again', 'woo-gutenberg-products-block' ) . ' '; + } - $actions .= '' . esc_html_e( 'My account', 'woo-gutenberg-products-block' ) . ' '; + $actions .= '' . esc_html_e( 'My account', 'woo-gutenberg-products-block' ) . ' '; - $content .= ' + $content .= '

' . $order_received_text . '

' . $actions . '

'; - } else { - // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment - $content .= '

' . wp_kses_post( apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woo-gutenberg-products-block' ), $order ) ) . '

'; + break; + default: + $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.', 'woo-gutenberg-products-block' ), + $order + ) + ) . '

'; + break; } return $content;