1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Wcap_Add_Cart_Popup_Modal' ) ) {
class Wcap_Add_Cart_Popup_Modal {
public static function wcap_add_to_cart_popup_settings() {
$wcap_atc_enabled = get_option( 'wcap_atc_enable_modal' );
$wcap_disabled_field = '';
if ( 'off' == $wcap_atc_enabled ) {
$wcap_disabled_field = 'disabled="disabled"';
}
?>
<div id = "wcap_popup_main_div" class = "wcap_popup_main_div ">
<table id = "wcap_popup_main_table" class = "wcap_popup_main_table test_borders">
<tr id = "wcap_popup_main_table_tr" class = "wcap_popup_main_table_tr test_borders">
<td id = "wcap_popup_main_table_td_settings" class = "wcap_popup_main_table_td_settings test_borders">
<?php Wcap_Add_Cart_Popup_Modal::wcap_enable_modal_section( $wcap_disabled_field ); ?>
<div class = "wcap_atc_all_fields_container" >
<?php Wcap_Add_Cart_Popup_Modal::wcap_add_heading_section( $wcap_disabled_field ); ?>
<?php Wcap_Add_Cart_Popup_Modal::wcap_add_text_section( $wcap_disabled_field ); ?>
<?php Wcap_Add_Cart_Popup_Modal::wcap_email_placeholder_section( $wcap_disabled_field ); ?>
<?php Wcap_Add_Cart_Popup_Modal::wcap_button_section( $wcap_disabled_field ); ?>
<?php Wcap_Add_Cart_Popup_Modal::wcap_mandatory_modal_section( $wcap_disabled_field ); ?>
<?php Wcap_Add_Cart_Popup_Modal::wcap_non_mandatory_modal_section_field( $wcap_disabled_field ); ?>
</div>
</td>
<td id = "wcap_popup_main_table_td_preview" class = "wcap_popup_main_table_td_preview test_borders">
<div class = "wcap_atc_all_fields_container" >
<?php Wcap_Add_Cart_Popup_Modal::wcap_add_to_cart_popup_modal_preview( $wcap_disabled_field ); ?>
</div>
</td>
</tr>
<tr>
<td>
<div class = "wcap_atc_all_fields_container" >
<p class = "submit">
<input type = "submit" name = "submit" id = "submit" class = "button button-primary" value = "Save Changes" <?php echo $wcap_disabled_field; ?> >
<input type = "submit" name = "submit" id = "submit" class = "wcap_reset_button button button-primary" value = "Reset to default configuration" <?php echo $wcap_disabled_field; ?> >
</p>
</div>
</td>
</tr>
</table>
</div>
<?php
}
public static function wcap_enable_modal_section( $wcap_disabled_field ){
?>
<table class = "wcap_enable_atc wcap_atc_between_fields_space" id = "wcap_enable_atc" >
<th id = "wcap_button_section_table_heading" class = "wcap_button_section_table_heading"> Enable Add to cart popup modal </th>
<tr>
<td>
<?php
$wcap_atc_enabled = get_option('wcap_atc_enable_modal');
$active_text = __( $wcap_atc_enabled, 'woocommerce-ac' );
?>
<button type = "button" class = "wcap-enable-atc-modal wcap-toggle-atc-modal-enable-status" wcap-atc-switch-modal-enable = <?php echo $wcap_atc_enabled; ?> >
<?php echo $active_text; ?>
</button>
</td>
</tr>
</table>
<?php
}
public static function wcap_add_to_cart_popup_save_settings() {
if ( $_POST ['wcap_heading_section_text_email'] ) {
update_option ( 'wcap_heading_section_text_email', $_POST ['wcap_heading_section_text_email'] );
}
if ( $_POST ['wcap_popup_heading_color_picker'] ) {
update_option ( 'wcap_popup_heading_color_picker', $_POST ['wcap_popup_heading_color_picker'] );
}
if ( $_POST ['wcap_text_section_text'] ) {
update_option ( 'wcap_text_section_text', $_POST ['wcap_text_section_text'] );
}
if ( $_POST ['wcap_popup_text_color_picker'] ) {
update_option ( 'wcap_popup_text_color_picker', $_POST ['wcap_popup_text_color_picker'] );
}
if ( $_POST ['wcap_email_placeholder_section_input_text'] ) {
update_option ( 'wcap_email_placeholder_section_input_text', $_POST ['wcap_email_placeholder_section_input_text'] );
}
if ( $_POST ['wcap_button_section_input_text'] ) {
update_option ( 'wcap_button_section_input_text', $_POST ['wcap_button_section_input_text'] );
}
if ( $_POST ['wcap_button_color_picker'] ) {
update_option ( 'wcap_button_color_picker', $_POST ['wcap_button_color_picker'] );
}
if ( isset( $_POST ['wcap_button_text_color_picker'] ) ){
update_option ( 'wcap_button_text_color_picker', $_POST ['wcap_button_text_color_picker'] );
}
if ( isset( $_POST ['wcap_non_mandatory_modal_section_fields_input_text'] ) ) {
update_option( 'wcap_non_mandatory_text', $_POST ['wcap_non_mandatory_modal_section_fields_input_text'] );
}
}
public static function wcap_add_heading_section( $wcap_disabled_field ) {
?>
<div id = "wcap_heading_section_div" class = "wcap_heading_section_div wcap_atc_between_fields_space">
<table id = "wcap_heading_section_table" class = "wcap_heading_section_table">
<th id = "wcap_heading_section_table_heading" class ="wcap_heading_section_table_heading"> Modal Heading </th>
<tr id = "wcap_heading_section_tr" class = "wcap_heading_section_tr" >
<td id = "wcap_heading_section_text_field" class = "wcap_heading_section_text_field test_borders">
<input id = "wcap_heading_section_text_email" v-model = "wcap_heading_section_text_email" name = "wcap_heading_section_text_email"class = "wcap_heading_section_text_email"
<?php echo $wcap_disabled_field; ?> >
</td>
<td id = "wcap_heading_section_text_field_color" class = "wcap_heading_section_text_field_color test_borders">
<?php $wcap_popup_heading_color_picker = get_option( 'wcap_popup_heading_color_picker' ); ?>
<span class = "colorpickpreview" style = "background:<?php echo $wcap_popup_heading_color_picker; ?>"></span>
<input class = "wcap_popup_heading_color_picker colorpick" name = "wcap_popup_heading_color_picker" value = "{{wcap_popup_heading_color}}" v-model = "wcap_popup_heading_color" v-on:input = "wcap_atc_popup_heading.color = $event.target.value"
<?php echo $wcap_disabled_field; ?> >
</td>
</tr>
</table>
</div>
<?php
}
public static function wcap_add_text_section( $wcap_disabled_field ) {
?>
<div id = "wcap_text_section_div" class = "wcap_text_section_div wcap_atc_between_fields_space">
<table id = "wcap_text_section_table" class = "wcap_text_section_table">
<th id = "wcap_text_section_table_heading" class = "wcap_text_section_table_heading"> Modal Text </th>
<tr id = "wcap_text_section_tr" class = "wcap_text_section_tr" >
<td id = "wcap_text_section_text_field" class = "wcap_text_section_text_field test_borders">
<input id = "wcap_text_section_text" v-model = "wcap_text_section_text_field" class="wcap_text_section_input_text" name = "wcap_text_section_text"
<?php echo $wcap_disabled_field; ?> >
</td>
<td id = "wcap_text_section_field_color" class = "wcap_text_section_field_color test_borders">
<?php $wcap_atc_popup_text_color = get_option( 'wcap_popup_text_color_picker' ); ?>
<span class = "colorpickpreview" style = "background:<?php echo $wcap_atc_popup_text_color; ?>"></span>
<input class = "wcap_popup_text_color_picker colorpick" name = "wcap_popup_text_color_picker" value = "{{wcap_popup_text_color}}" v-model = "wcap_popup_text_color" v-on:input = "wcap_atc_popup_text.color = $event.target.value"
<?php echo $wcap_disabled_field; ?> >
</td>
</tr>
</table>
</div>
<?php
}
public static function wcap_email_placeholder_section( $wcap_disabled_field ) {
?>
<div id = "wcap_email_placeholder_section_div" class = "wcap_email_placeholder_section_div wcap_atc_between_fields_space">
<table id = "wcap_email_placeholder_section_table" class = "wcap_email_placeholder_section_table">
<th id = "wcap_email_placeholder_section_table_heading" class = "wcap_email_placeholder_section_table_heading"> Email placeholder </th>
<tr id = "wcap_email_placeholder_section_tr" class = "wcap_email_placeholder_section_tr" >
<td id = "wcap_email_placeholder_section_text_field" class = "wcap_email_placeholder_section_text_field test_borders">
<input id = "wcap_email_placeholder_section_input_text" v-model = "wcap_email_placeholder_section_input_text" class="wcap_email_placeholder_section_input_text" name = "wcap_email_placeholder_section_input_text"
<?php echo $wcap_disabled_field; ?> >
</td>
</tr>
</table>
</div>
<?php
}
public static function wcap_button_section( $wcap_disabled_field ) {
?>
<div id = "wcap_button_section_div" class = "wcap_button_section_div wcap_atc_between_fields_space">
<table id = "wcap_button_section_table" class = "wcap_button_section_table">
<th id = "wcap_button_section_table_heading" class="wcap_button_section_table_heading"> Add to cart button text </th>
<tr>
<td id = "wcap_button_section_text_field" class = "wcap_button_section_text_field test_borders">
<input id = "wcap_button_section_input_text" v-model = "wcap_button_section_input_text" class="wcap_button_section_input_text" name = "wcap_button_section_input_text"
<?php echo $wcap_disabled_field ; ?> >
</td>
</tr>
<tr id = "wcap_button_color_section_tr" class = "wcap_button_color_section_tr">
<td id = "wcap_button_color_section_text_field" class = "wcap_button_color_section_text_field test_borders">
<?php $wcap_atc_button_bg_color = get_option( 'wcap_button_color_picker' ); ?>
<span class = "colorpickpreview" style = "background:<?php echo $wcap_atc_button_bg_color; ?>"></span>
<input id = "wcap_button_color_picker" value = "{{wcap_button_bg_color}}" v-model ="wcap_button_bg_color" v-on:input="wcap_atc_button.backgroundColor = $event.target.value" class="wcap_button_color_picker colorpick" name = "wcap_button_color_picker"
<?php echo $wcap_disabled_field; ?> >
</td>
<td id = "wcap_button_text_color_section_text_field" class = "wcap_button_text_color_section_text_field test_borders">
<?php $wcap_button_text_color_picker = get_option('wcap_button_text_color_picker'); ?>
<span class = "colorpickpreview" style = "background:<?php echo $wcap_button_text_color_picker; ?>"></span>
<input id = "wcap_button_text_color_picker" value = "{{wcap_button_text_color}}" v-model = "wcap_button_text_color" v-on:input = "wcap_atc_button.color = $event.target.value" class="wcap_button_text_color_picker colorpick" name = "wcap_button_text_color_picker"
<?php echo $wcap_disabled_field; ?> >
</td>
</tr>
</table>
</div>
<?php
}
public static function wcap_mandatory_modal_section( $wcap_disabled_field ) {
?>
<table class = "wcap_atc_between_fields_space">
<th id = "wcap_button_section_table_heading" class = "wcap_button_section_table_heading"> Email address is mandatory ? </th>
<tr>
<td>
<?php
$wcap_atc_email_mandatory = get_option( 'wcap_atc_mandatory_email' );
$active_text = __( $wcap_atc_email_mandatory, 'woocommerce-ac' );
?>
<button type = "button" class = "wcap-switch-atc-modal-mandatory wcap-toggle-atc-modal-mandatory" wcap-atc-switch-modal-mandatory = <?php echo $wcap_atc_email_mandatory; ?>
<?php echo $wcap_disabled_field; ?> >
<?php echo $active_text; ?> </button>
</td>
</tr>
</table>
<?php
}
public static function wcap_non_mandatory_modal_section_field( $wcap_disabled_field ) {
$wcap_get_mandatory_field = get_option( 'wcap_atc_mandatory_email' );
$wcap_disabled_email_field = '';
if ( 'on' == $wcap_get_mandatory_field ) {
$wcap_disabled_email_field = 'disabled="disabled"';
}
?>
<div id = "wcap_non_mandatory_modal_section_fields_div" class = "wcap_non_mandatory_modal_section_fields_div wcap_atc_between_fields_space">
<table id = "wcap_non_mandatory_modal_section_fields_div_table" class = "wcap_non_mandatory_modal_section_fields_div_table">
<th id = "wcap_non_mandatory_modal_section_fields_table_heading"
class="wcap_non_mandatory_modal_section_fields_table_heading"> Not mandatory text </th>
<tr id = "wcap_non_mandatory_modal_section_fields_tr" class = "wcap_non_mandatory_modal_section_fields_tr" >
<td id = "wcap_non_mandatory_modal_section_fields_text_field" class = "wcap_non_mandatory_modal_section_fields_text_field test_borders">
<input id = "wcap_non_mandatory_modal_section_fields_input_text" v-model = "wcap_non_mandatory_modal_input_text" class = "wcap_non_mandatory_modal_section_fields_input_text" name = "wcap_non_mandatory_modal_section_fields_input_text"
<?php echo $wcap_disabled_field;
echo $wcap_disabled_email_field;
?> >
</td>
</tr>
</table>
</div>
<?php
}
public static function wcap_add_to_cart_popup_modal_preview( $wcap_disabled_field ) {
?>
<div class = "wcap_container">
<div class = "wcap_popup_wrapper">
<div class = "wcap_popup_content">
<div class = "wcap_popup_heading_container">
<div class = "wcap_popup_icon_container" >
<span class = "wcap_popup_icon" >
<span class = "wcap_popup_plus_sign" v-bind:style = "wcap_atc_button">
</span>
</span>
</div>
<div class = "wcap_popup_text_container">
<h2 class = "wcap_popup_heading" v-bind:style = "wcap_atc_popup_heading" >{{wcap_heading_section_text_email}}</h2>
<div class = "wcap_popup_text" v-bind:style = "wcap_atc_popup_text" >{{wcap_text_section_text_field}}</div>
</div>
</div>
<div class = "wcap_popup_form">
<form action = "" name = "wcap_modal_form">
<div class = "wcap_popup_input_field_container" >
<input class = "wcap_popup_input" type = "text" value = "" name = "email" placeholder = {{wcap_email_placeholder_section_input_text}}
<?php echo $wcap_disabled_field; ?> readonly >
</div>
<button class = "wcap_popup_button" v-bind:style = "wcap_atc_button"
<?php echo $wcap_disabled_field ; ?> >{{wcap_button_section_input_text}}</button>
<br>
<br>
<div id = "wcap_non_mandatory_text_wrapper" class = "wcap_non_mandatory_text_wrapper">
<a class = "wcap_popup_non_mandatory_button" href = "" > {{wcap_non_mandatory_modal_input_text}}</a>
</div>
</form>
</div>
<div class = "wcap_popup_close" ></div>
</div>
</div>
</div>
<?php
}
}
}