true, ); } // end defaults; /** * List of keys of the default fields we want to display on the builder. * * @since 2.0.0 * @return array */ public function default_fields() { return array( 'name', 'placeholder', 'tooltip', ); } // end default_fields; /** * If you want to force a particular attribute to a value, declare it here. * * @since 2.0.0 * @return array */ public function force_attributes() { return array( 'id' => 'email_address', 'required' => true, ); } // end force_attributes; /** * Returns the list of additional fields specific to this type. * * @since 2.0.0 * @return array */ public function get_fields() { return array( 'display_notices' => array( 'type' => 'toggle', 'title' => __('Display Notices', 'wp-ultimo'), 'desc' => __('When the customer is already logged in, a box with the customer\'s username and a link to logout is displayed instead of the email field. Disable this option if you do not want that box to show up.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, 'html_attr' => array( 'v-model' => 'display_notices', ), ), ); } // end get_fields; /** * Returns the field/element actual field array to be used on the checkout form. * * @since 2.0.0 * * @param array $attributes Attributes saved on the editor form. * @return array An array of fields, not the field itself. */ public function to_fields_array($attributes) { $checkout_fields = array(); if (is_user_logged_in()) { if ($attributes['display_notices']) { $checkout_fields['login_note'] = array( 'type' => 'note', 'title' => __('Not you?', 'wp-ultimo'), 'desc' => array($this, 'render_not_you_customer_message'), 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'wrapper_html_attr' => array( 'style' => $this->calculate_style_attr(), ), ); } // end if; } else { if ($attributes['display_notices']) { $checkout_fields['login_note'] = array( 'type' => 'note', 'title' => __('Existing customer?', 'wp-ultimo'), 'desc' => array($this, 'render_existing_customer_message'), 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'wrapper_html_attr' => array( 'style' => $this->calculate_style_attr(), ), ); } // end if; $checkout_fields['email_address'] = array( 'type' => 'text', 'id' => 'email_address', 'name' => $attributes['name'], 'placeholder' => $attributes['placeholder'], 'tooltip' => $attributes['tooltip'], 'value' => $this->get_value(), 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'wrapper_html_attr' => array( 'style' => $this->calculate_style_attr(), ), ); } // end if; return $checkout_fields; } // end to_fields_array; /** * Renders the login message for users that are not logged in. * * @since 2.0.0 * @return string */ public function render_existing_customer_message() { $login_url = wp_login_url(add_query_arg('logged', '1')); ob_start(); ?>
Log in using your account.', 'wp-ultimo'), wp_get_current_user()->display_name, $login_url); ?>