Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation
Status::render_content()
This renders the content of the block within the wrapper.
Метод класса: Status{}
Хуки из метода
Возвращает
Строку
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render_content( $order, $permission, $attributes, $content );
- $order(\WC_Order) (обязательный)
- Order object.
- $permission(строка|false)
- If the current user can view the order details or not.
По умолчанию: false - $attributes(массив)
- Block attributes.
По умолчанию: [] - $content(строка)
- Original block content.
По умолчанию: ''
Код Status::render_content() Status::render content WC 9.6.1
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; }