| @@ -39,18 +39,12 @@ | ||
| 39 | 39 | */ |
| 40 | 40 | private static function get_settings_tabs() { |
| 41 | 41 | $tabs = array( |
| 42 | 42 | 'general' => 'General', |
| 43 | - 'woocommerce' => 'WooCommerce', | |
| 44 | - 'whatsapp_chat_button' => 'WhatsApp Chat Button', | |
| 43 | + 'click_to_chat' => 'Click to Chat', | |
| 45 | 44 | 'api' => 'API', |
| 46 | - 'advanced' => 'Advanced', | |
| 45 | + 'advanced' => 'Advanced' | |
| 47 | 46 | ); |
| 48 | - | |
| 49 | - if ( ! class_exists( 'WooCommerce' ) ) { | |
| 50 | - unset($tabs['woocommerce']); | |
| 51 | - } | |
| 52 | - | |
| 53 | 47 | return $tabs; |
| 54 | 48 | } |
| 55 | 49 | |
| 56 | 50 | /** |
| @@ -92,14 +86,41 @@ | ||
| 92 | 86 | 'default' => '' |
| 93 | 87 | ), |
| 94 | 88 | ); |
| 95 | 89 | |
| 90 | + if ( class_exists( 'WooCommerce' ) ) { | |
| 91 | + $settings = array_merge( $settings, array( | |
| 92 | + array( | |
| 93 | + 'title' => 'WooCommerce', | |
| 94 | + 'type' => 'title', | |
| 95 | + 'description' => '' | |
| 96 | + ), | |
| 97 | + array( | |
| 98 | + 'id' => 'enable_opt_in_checkbox_checkout', | |
| 99 | + 'title' => 'Opt-in Consent on Checkout', | |
| 100 | + 'type' => 'checkbox', | |
| 101 | + 'default' => '', | |
| 102 | + 'label' => 'Enable', | |
| 103 | + 'name' => 'enable_opt_in_checkbox_checkout', | |
| 104 | + 'description' => 'Add an opt-in checkbox to WooCommerce checkout form. Once enabled, WhatsApp notification will be sent only to customers who opt-in during checkout.' | |
| 105 | + ), | |
| 106 | + array( | |
| 107 | + 'id' => 'checkout_opt_in_checkbox_text', | |
| 108 | + 'title' => 'Opt-in Checkbox Text', | |
| 109 | + 'type' => 'textarea', | |
| 110 | + 'placeholder' => 'Enter text for the opt-in checkbox', | |
| 111 | + 'default' => 'Receive updates on WhatsApp', | |
| 112 | + 'name' => 'checkout_opt_in_checkbox_text', | |
| 113 | + ) | |
| 114 | + ) ); | |
| 115 | + } | |
| 116 | + | |
| 96 | 117 | break; |
| 97 | - case 'whatsapp_chat_button': | |
| 118 | + case 'click_to_chat': | |
| 98 | 119 | $settings = array( |
| 99 | 120 | array( |
| 100 | - 'title' => 'WhatsApp Chat Button', | |
| 101 | - 'description' => 'Add a WhatsApp chat button to your website to let your visitors start chat with you on WhatsApp.', | |
| 121 | + 'title' => 'Click to Chat', | |
| 122 | + 'description' => 'Show click to chat button on your website to let your visitors start WhatsApp chat with you.', | |
| 102 | 123 | 'type' => 'title', |
| 103 | 124 | ), |
| 104 | 125 | array( |
| 105 | 126 | 'id' => 'ctc_enable', |
| @@ -130,9 +151,16 @@ | ||
| 130 | 151 | 'name' => 'ctc_button_style', |
| 131 | 152 | 'class' => 'chat-button-style', |
| 132 | 153 | 'type' => 'select', |
| 133 | 154 | 'default' => '', |
| 134 | - 'options' => self::get_button_styles(), | |
| 155 | + 'options' => array( | |
| 156 | + 'default' => 'Select button style', | |
| 157 | + 'btn-style-1' => 'Style 1' , | |
| 158 | + 'btn-style-2' => 'Style 2', | |
| 159 | + 'btn-style-3' => 'Style 3', | |
| 160 | + 'btn-style-4' => 'Style 4', | |
| 161 | + 'btn-custom-image' => 'Add your own image' | |
| 162 | + ), | |
| 135 | 163 | 'description' => 'Select a button style. Preview will be shown on bottom right of this screen. You can update button style by writing custom CSS in your theme.', |
| 136 | 164 | ), |
| 137 | 165 | array( |
| 138 | 166 | 'id' => 'ctc_custom_button_image_url', |
| @@ -197,59 +225,8 @@ | ||
| 197 | 225 | 'description' => 'Enabling this option will activate the activity logging feature. You can view activity logs <a href="/wp-admin/admin.php?page=notifier-tools">here</a>.' , |
| 198 | 226 | ), |
| 199 | 227 | ); |
| 200 | 228 | break; |
| 201 | - case 'woocommerce': | |
| 202 | - if ( class_exists( 'WooCommerce' ) ) { | |
| 203 | - $settings = array( | |
| 204 | - array( | |
| 205 | - 'title' => 'Checkout', | |
| 206 | - 'description' => '', | |
| 207 | - 'type' => 'title', | |
| 208 | - ), | |
| 209 | - array( | |
| 210 | - 'id' => 'enable_opt_in_checkbox_checkout', | |
| 211 | - 'title' => 'Opt-in Consent on Checkout', | |
| 212 | - 'type' => 'checkbox', | |
| 213 | - 'default' => '', | |
| 214 | - 'label' => 'Enable', | |
| 215 | - 'name' => 'enable_opt_in_checkbox_checkout', | |
| 216 | - 'description' => 'Add an opt-in checkbox to WooCommerce checkout form. Once enabled, WhatsApp notification will be sent only to customers who opt-in during checkout.' | |
| 217 | - ), | |
| 218 | - array( | |
| 219 | - 'id' => 'checkout_opt_in_checkbox_text', | |
| 220 | - 'title' => 'Opt-in Checkbox Text', | |
| 221 | - 'type' => 'textarea', | |
| 222 | - 'placeholder' => 'Enter text for the opt-in checkbox', | |
| 223 | - 'default' => 'Receive updates on WhatsApp', | |
| 224 | - 'name' => 'checkout_opt_in_checkbox_text', | |
| 225 | - ), | |
| 226 | - array( | |
| 227 | - 'title' => 'Abandoned Cart', | |
| 228 | - 'description' => '', | |
| 229 | - 'type' => 'title', | |
| 230 | - ), | |
| 231 | - array( | |
| 232 | - 'id' => 'enable_abandonment_cart_tracking', | |
| 233 | - 'title' => 'Abandoned cart tracking', | |
| 234 | - 'type' => 'checkbox', | |
| 235 | - 'default' => '', | |
| 236 | - 'label' => 'Start capturing abandoned carts', | |
| 237 | - 'name' => 'enable_abandonment_cart_tracking', | |
| 238 | - 'description' => 'Enable this to start capturing abandoned carts in database. Carts will be considered as abandoned if order is not placed by the user after adding items in the cart within cart abandoned cut-off time set below.' | |
| 239 | - ), | |
| 240 | - array( | |
| 241 | - 'id' => 'abandonment_cart_cron_run_time', | |
| 242 | - 'title' => 'Cart abandoned cut-off time', | |
| 243 | - 'type' => 'number', | |
| 244 | - 'placeholder' => 'Enter time in minutes. Eg. 20', | |
| 245 | - 'description' => 'Enter time in minutes after which the cart will be considered as abandoned. This is the time from when items are added / updated in cart.', | |
| 246 | - 'default' => '20', | |
| 247 | - 'custom_attributes' => array('min' => 20), | |
| 248 | - ), | |
| 249 | - ); | |
| 250 | - } | |
| 251 | - break; | |
| 252 | 229 | } |
| 253 | 230 | $settings = apply_filters( 'notifier_$tab_settings_fields', $settings ); |
| 254 | 231 | return $settings; |
| 255 | 232 | } |
| @@ -596,35 +573,12 @@ | ||
| 596 | 573 | } |
| 597 | 574 | } |
| 598 | 575 | |
| 599 | 576 | /** |
| 600 | - * Get button styles | |
| 601 | - */ | |
| 602 | - public static function get_button_styles(){ | |
| 603 | - return array( | |
| 604 | - 'default' => 'Select button style', | |
| 605 | - 'btn-style-1' => 'Style 1' , | |
| 606 | - 'btn-style-2' => 'Style 2', | |
| 607 | - 'btn-style-3' => 'Style 3', | |
| 608 | - 'btn-style-4' => 'Style 4', | |
| 609 | - 'btn-custom-image' => 'Add your own image' | |
| 610 | - ); | |
| 611 | - } | |
| 612 | - | |
| 613 | - /** | |
| 614 | 577 | * Show Chat Button Preview |
| 615 | 578 | */ |
| 616 | 579 | public static function preview_btn_style(){ |
| 617 | 580 | $btn_style = isset($_POST['btn_style']) ? sanitize_text_field($_POST['btn_style']) : ''; |
| 618 | - | |
| 619 | - $button_styles = self::get_button_styles(); | |
| 620 | - $button_style_keys = array_keys($button_styles); | |
| 621 | - | |
| 622 | - if(! in_array($btn_style, $button_style_keys)){ | |
| 623 | - wp_send_json( array( | |
| 624 | - 'preview' => 'Invalid request' | |
| 625 | - ) ); | |
| 626 | - } | |
| 627 | 581 | |
| 628 | 582 | ob_start(); |
| 629 | 583 | include_once NOTIFIER_PATH.'templates/buttons/'.$btn_style.'.php'; |
| 630 | 584 | $btn_output = ob_get_clean(); |