sellkit
/
includes
/
block-editor
/
blocks
/
checkout
/
inner-blocks
/
contact-information
/
class.php
class.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 2.7.0, at includes/block-editor/blocks/checkout/inner-blocks/contact-information/class.php
| 1 | <?php |
| 2 | namespace Sellkit\Blocks\Inner_Block; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | /** |
| 7 | * Contact Information class. |
| 8 | * |
| 9 | * @since 2.3.0 |
| 10 | * @package Sellkit\Blocks\Inner_Block |
| 11 | */ |
| 12 | class Checkout_Contact_Information { |
| 13 | /** |
| 14 | * Register block meta. |
| 15 | * |
| 16 | * @since 2.3.0 |
| 17 | */ |
| 18 | public function register_block_meta() { |
| 19 | register_block_type_from_metadata( |
| 20 | __DIR__ |
| 21 | ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Render contact information. |
| 26 | * |
| 27 | * @param string $content Block content. |
| 28 | * @param array $attributes Block attributes. |
| 29 | * @since 2.3.0 |
| 30 | * @return string |
| 31 | */ |
| 32 | public function checkout_contact_information( $content, $attributes ) { |
| 33 | if ( is_user_logged_in() ) { |
| 34 | $this_user = wp_get_current_user(); |
| 35 | $email = get_user_meta( $this_user->ID, 'billing_email', true ); |
| 36 | |
| 37 | if ( empty( $email ) ) { |
| 38 | $email = $this_user->user_email; |
| 39 | } |
| 40 | |
| 41 | add_filter( 'sellkit_checkout_block_create_website_account', function() { |
| 42 | return esc_html( $attributes['contactDescriptionText'] ); |
| 43 | } ); |
| 44 | |
| 45 | ob_start(); |
| 46 | ?> |
| 47 | <div class="sellkit-checkout-widget-login-section sellkit-checkout-widget-logged-user sellkit-checkout-local-fields <?php echo esc_attr( $attributes['customClassName'] ); ?>"> |
| 48 | <div class="header heading"><?php echo esc_html( $attributes['contactHeadingText'] ); ?></div> |
| 49 | <div class="sellkit-checkout-widget-email-holder"> |
| 50 | <div class="sellkit-checkout-fields-wrapper sellkit-widget-checkout-fields sellkit-checkout-excluded-wrapper-fields sellkit-login-section"> |
| 51 | <div style="position:relative"> |
| 52 | <span class="free-label"> |
| 53 | <?php echo esc_html__( 'Email address', 'sellkit' ); ?> |
| 54 | </span> |
| 55 | </div> |
| 56 | <p class="log-email"> |
| 57 | <span class="woocommerce-input-wrapper"> |
| 58 | <input |
| 59 | type="email" |
| 60 | class="input-text validate-email" |
| 61 | name="billing_email" |
| 62 | id="billing_email" |
| 63 | readonly |
| 64 | placeholder="<?php echo esc_html__( 'Email Address', 'sellkit' ); ?>" |
| 65 | value="<?php echo esc_attr( $email ); ?>" |
| 66 | autocomplete="email" |
| 67 | /> |
| 68 | </span> |
| 69 | </p> |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | <?php |
| 74 | $final_content = ob_get_clean(); |
| 75 | |
| 76 | return str_replace( '</div>', $final_content . '</div>', $content ); |
| 77 | } |
| 78 | |
| 79 | ob_start(); |
| 80 | ?> |
| 81 | <div class="sellkit-checkout-widget-login-section sellkit-checkout-local-fields <?php echo esc_attr( $attributes['customClassName'] ); ?>"> |
| 82 | <div class="header heading"><?php echo esc_html( $attributes['contactHeadingText'] ); ?></div> |
| 83 | <div class="sellkit-checkout-widget-email-holder"> |
| 84 | <div class="sellkit-checkout-fields-wrapper sellkit-widget-checkout-fields sellkit-checkout-excluded-wrapper-fields sellkit-login-section"> |
| 85 | <div style="position:relative"> |
| 86 | <span class="free-label"> |
| 87 | <?php echo esc_html__( 'Email address', 'sellkit' ); ?> |
| 88 | </span> |
| 89 | </div> |
| 90 | <p> |
| 91 | <span class="woocommerce-input-wrapper"> |
| 92 | <input |
| 93 | type="text" |
| 94 | name="billing_email" |
| 95 | id="billing_email" |
| 96 | class="login-mail validate-email" |
| 97 | placeholder="<?php echo esc_html__( 'Email Address', 'sellkit' ); ?>" |
| 98 | autocomplete="email" |
| 99 | autocapitalize="none" |
| 100 | autocorrect="off" |
| 101 | spellcheck="false" |
| 102 | inputmode="email" |
| 103 | > |
| 104 | </span> |
| 105 | <span class="sellkit-checkout-widget-email-error login-section-error"> |
| 106 | <?php echo esc_html__( 'Email address is not valid.', 'sellkit' ); ?> |
| 107 | </span> |
| 108 | <span class="sellkit-checkout-widget-email-empty login-section-error"> |
| 109 | <?php echo esc_html__( 'Email address is empty.', 'sellkit' ); ?> |
| 110 | </span> |
| 111 | <span class="jupiter-checkout-widget-email-search"> |
| 112 | <i class="fas fa-sync fa-spin"></i> |
| 113 | <?php echo esc_html__( 'Checking...', 'sellkit' ); ?> |
| 114 | </span> |
| 115 | </p> |
| 116 | </div> |
| 117 | </div> |
| 118 | <div class="login_hidden_section sellkit-checkout-widget-username-field"> |
| 119 | <?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?> |
| 120 | <div class="sellkit-checkout-fields-wrapper sellkit-widget-checkout-fields sellkit-checkout-excluded-wrapper-fields sellkit-login-section"> |
| 121 | <div style="position:relative"> |
| 122 | <span class="free-label"> |
| 123 | <?php echo esc_html__( 'Username', 'sellkit' ); ?> |
| 124 | </span> |
| 125 | </div> |
| 126 | <p> |
| 127 | <input |
| 128 | type="text" |
| 129 | class="login-username" |
| 130 | name="account_username" |
| 131 | id="register_user" |
| 132 | placeholder="<?php echo esc_html__( 'Username', 'sellkit' ); ?>" |
| 133 | > |
| 134 | <span class="sellkit-checkout-widget-username-error login-section-error"> |
| 135 | <?php echo esc_html__( 'An account is already registered with that username. Please choose another..', 'sellkit' ); ?> |
| 136 | </span> |
| 137 | </p> |
| 138 | </div> |
| 139 | <?php endif; ?> |
| 140 | </div> |
| 141 | <div class="login_hidden_section sellkit-checkout-widget-password-field"> |
| 142 | <div class="sellkit-checkout-fields-wrapper sellkit-widget-checkout-fields sellkit-checkout-excluded-wrapper-fields sellkit-login-section"> |
| 143 | <div style="position:relative"> |
| 144 | <span class="free-label"> |
| 145 | <?php echo esc_html__( 'Password', 'sellkit' ); ?> |
| 146 | </span> |
| 147 | </div> |
| 148 | <p> |
| 149 | <input |
| 150 | type="password" |
| 151 | class="login-pass" |
| 152 | <?php |
| 153 | if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) { |
| 154 | echo 'name="account_password"'; |
| 155 | echo 'id="register_pass"'; |
| 156 | } else { |
| 157 | echo 'name="account_password"'; |
| 158 | echo 'id="login_pass"'; |
| 159 | } |
| 160 | ?> |
| 161 | placeholder="<?php echo esc_html__( 'Password', 'sellkit' ); ?>" |
| 162 | > |
| 163 | </p> |
| 164 | </div> |
| 165 | </div> |
| 166 | <?php if ( 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) ) : ?> |
| 167 | <div class="create-desc"> |
| 168 | <div class="sellkit-checkout-fields-wrapper sellkit-widget-checkout-fields sellkit-checkout-excluded-wrapper-fields sellkit-login-section"> |
| 169 | <p> |
| 170 | <input |
| 171 | type="checkbox" |
| 172 | class="sellkit-create-account-checkbox woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" |
| 173 | id="createaccount" |
| 174 | name="createaccount" |
| 175 | value="1" |
| 176 | > |
| 177 | <label for="createaccount" class="sellkit-create-account-checkbox-label"> |
| 178 | <?php echo esc_html( $attributes['contactDescriptionText'] ); ?> |
| 179 | </label> |
| 180 | </p> |
| 181 | </div> |
| 182 | </div> |
| 183 | <?php endif; ?> |
| 184 | <div class="login-wrapper login_hidden_section"> |
| 185 | <div class="sellkit-checkout-fields-wrapper sellkit-widget-checkout-fields sellkit-login-section"> |
| 186 | <span class="login-submit sellkit-checkout-widget-secondary-button"> |
| 187 | <?php echo esc_html__( 'Login', 'sellkit' ); ?> |
| 188 | </span> |
| 189 | <label class="login-result"></label> |
| 190 | </div> |
| 191 | </div> |
| 192 | </div> |
| 193 | <?php |
| 194 | |
| 195 | $final_content = ob_get_clean(); |
| 196 | |
| 197 | return str_replace( '</div>', $final_content . '</div>', $content ); |
| 198 | } |
| 199 | } |
| 200 |