Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add name/description for status block and missing text descriptions i…
Browse files Browse the repository at this point in the history
…n the block.

Closes #10057
  • Loading branch information
mikejolley committed Jul 4, 2023
1 parent 3d393e6 commit 88eda68
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 19 deletions.
4 changes: 2 additions & 2 deletions assets/js/blocks/order-confirmation/status/block.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 2 additions & 3 deletions assets/js/blocks/order-confirmation/status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +14,7 @@ registerBlockType( metadata, {
icon: {
src: (
<Icon
icon={ totals }
icon={ info }
className="wc-block-editor-components-block-icon"
/>
),
Expand Down
4 changes: 2 additions & 2 deletions assets/js/blocks/order-confirmation/summary/block.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
73 changes: 61 additions & 12 deletions src/BlockTypes/OrderConfirmation/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<p class="woocommerce-thankyou-order-received">' . 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
)
) . '</p>';
break;
case 'refunded':
$content .= '<p class="woocommerce-thankyou-order-received">' . 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() )
)
) . '</p>';
break;
case 'completed':
$content .= '<p class="woocommerce-thankyou-order-received">' . 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() )
)
) . '</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.', 'woo-gutenberg-products-block' ), null );
$actions = '';

if ( $this->is_current_customer_order( $order ) ) {
$actions .= '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '" class="button pay">' . esc_html__( 'Try again', 'woo-gutenberg-products-block' ) . '</a> ';
}
if ( $this->is_current_customer_order( $order ) ) {
$actions .= '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '" class="button pay">' . esc_html__( 'Try again', 'woo-gutenberg-products-block' ) . '</a> ';
}

$actions .= '<a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '" class="button pay">' . esc_html_e( 'My account', 'woo-gutenberg-products-block' ) . '</a> ';
$actions .= '<a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '" class="button pay">' . esc_html_e( 'My account', 'woo-gutenberg-products-block' ) . '</a> ';

$content .= '
$content .= '
<p class="woocommerce-thankyou-order-failed">' . $order_received_text . '</p>
<p class="woocommerce-thankyou-order-failed-actions">' . $actions . '</p>
';
} else {
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
$content .= '<p class="woocommerce-thankyou-order-received">' . wp_kses_post( apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woo-gutenberg-products-block' ), $order ) ) . '</p>';
break;
default:
$content .= '<p class="woocommerce-thankyou-order-received">' . 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
)
) . '</p>';
break;
}

return $content;
Expand Down

0 comments on commit 88eda68

Please sign in to comment.