Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation
CreateAccount::render_content
This renders the content of the block within the wrapper.
Method of the class: CreateAccount{}
No Hooks.
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:''
CreateAccount::render_content() CreateAccount::render content code WC 10.6.2
protected function render_content( $order, $permission = false, $attributes = [], $content = '' ) {
if ( ! $permission || ! $this->is_feature_enabled() ) {
return '';
}
// Check registration is possible for this order/customer, and if not, return early.
if ( is_user_logged_in() || email_exists( $order->get_billing_email() ) ) {
return '';
}
$result = $this->process_form_post( $order );
$notice = '';
if ( is_wp_error( $result ) ) {
$notice = wc_print_notice( $result->get_error_message(), 'error', [], true );
} elseif ( $result ) {
return $this->render_confirmation();
}
$processor = new \WP_HTML_Tag_Processor(
$content .
'<div class="wc-block-order-confirmation-create-account-form-wrapper">' .
$notice .
'<div class="wc-block-order-confirmation-create-account-form"></div>' .
'</div>'
);
if ( ! $processor->next_tag( array( 'class_name' => 'wp-block-woocommerce-order-confirmation-create-account' ) ) ) {
return $content;
}
$processor->set_attribute( 'class', '' );
$processor->set_attribute( 'style', '' );
$processor->add_class( 'wc-block-order-confirmation-create-account-content' );
if ( ! $processor->next_tag( array( 'class_name' => 'wc-block-order-confirmation-create-account-form' ) ) ) {
return $content;
}
$processor->set_attribute( 'data-customer-email', $order->get_billing_email() );
$processor->set_attribute( 'data-nonce-token', wp_create_nonce( 'wc_create_account' ) );
if ( ! empty( $attributes['hasDarkControls'] ) ) {
$processor->add_class( 'has-dark-controls' );
}
return $processor->get_updated_html();
}