
A chatbot is a software component that simulates conversation with human users. These bots are increasingly being used at ecommerce stores to greatly improve user experience by offering product suggestion and answering common customer queries.
The advantage of WordPress chatbots is that they are available 24/7 and filter out the routine questions that would otherwise take up the human support agents’ time. Thus chatbots are a particularly effective option for reducing the operational expenses of customer support.
How Chatbots add Value to Your WooCommerce Store
Chatbots have become a common component of many WooCommerce stores because:
- They can serve a number of customers simultaneously without slowing down.
- Customers get personalized shopping recommendations and price checks.
- Chatbots are a great way of delivering location based services and offers
- Chatbots help in conversions by providing product discovery and product suggestions.
Add a Custom Chatbot to Your WooCommerce Store
The good news is that you could easily add a custom chatbot to your WooCommerce store without any major hassle. Of course, you could always opt for a pre-built chatbot, but you loose the advantage of a custom built chatbot that integrates well into your WooCommerce store.
I will now present a structure that you could use to create and integrate a chatbot into your WooCommerce store. This structure comprises of the main structure file, Cw-woo-chat-bot.php and functions.php
Note : This chatbot is based on WooWBot WooCommerce Chat Bot
Here is the code of the main class: class_CW_Chatbot_Woo
class CW_Chatbot_Woo { private $id = 'cwbotwoo'; private static $instance; public static function cw_chatbot_wo_get_instance() { if (!self::$instance) { self::$instance = new self(); self::$instance->cw_chatbot_wo_init(); } return self::$instance; } private function __construct() { } public function cw_chatbot_wo_init() { if (!class_exists('WooCommerce') || version_compare(get_option('woocommerce_db_version'), CW_CHATBOT_WOO_REQUIRED_WOOCOMMERCE_VERSION, '<')) { add_action('admin_notices', array($this, 'woocommerce_inactive_notice_for_woo_chatbot')); return; } add_action('admin_menu', array($this, 'cw_chatbot_wo_admin_menu')); if ((!empty($_GET["page"])) && ($_GET["page"] == "cwbotwoo")) { add_action('admin_init', array($this, 'cw_chatbot_wo_save_options')); } if (is_admin()) { add_action('admin_enqueue_scripts', array($this, 'cw_chatbot_wo_admin_scripts')); } if (!is_admin()) { add_action('wp_enqueue_scripts', array($this, 'cw_chatbot_wo_frontend_scripts')); } } public function cw_chatbot_wo_admin_menu() { add_submenu_page('woocommerce', __('WoowBot', 'woochatbot'), __('WoowBot', 'woochatbot'), 'manage_woocommerce', $this->id, array($this, 'cw_chatbot_wo_admin_page')); } public function cw_chatbot_wo_admin_scripts($hook) { global $woocommerce, $wp_scripts; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; if (((!empty($_GET["page"])) && ($_GET["page"] == "cwbotwoo")) || ($hook == "widgets.php")) { wp_enqueue_script('jquery'); wp_enqueue_style('woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css'); wp_register_style('cwcb-woo-chatbot-admin-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/admin-style.css', basename(__FILE__)), '', CW_CHATBOT_WOO_VERSION, 'screen'); wp_enqueue_style('cwcb-woo-chatbot-admin-style'); wp_register_style('cwcb-woo-chatbot-font-awesome', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/font-awesome.min.css', basename(__FILE__)), '', CW_CHATBOT_WOO_VERSION, 'screen'); wp_enqueue_style('cwcb-woo-chatbot-font-awesome'); wp_register_style('cwcb-woo-chatbot-tabs-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/woo-chatbot-tabs.css', basename(__FILE__)), '', CW_CHATBOT_WOO_VERSION, 'screen'); wp_enqueue_style('cwcb-woo-chatbot-tabs-style'); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core'); array('ajax_url' => admin_url('admin-ajax.php'))); } } public function cw_chatbot_wo_frontend_scripts(){ global $woocommerce, $wp_scripts; $woo_chatbot_obj = array( 'woo_chatbot_position_x' => get_option('woo_chatbot_position_x'), 'woo_chatbot_position_y' => get_option('woo_chatbot_position_y'), 'ajax_url' => admin_url('admin-ajax.php'), 'image_path'=>CW_CHATBOT_WOO_IMG_URL, 'host'=> get_option('cw_woo_chatbot_host'), 'agent'=> get_option('cw_woo_chatbot_agent'), 'agent_join'=> get_option('cw_woo_chatbot_agent_join'), 'welcome'=> get_option('cw_woo_chatbot_welcome'), 'asking_name'=> get_option('cw_woo_chatbot_asking_name'), 'i_am'=> get_option('cw_woo_chatbot_i_am'), 'name_greeting'=> get_option('cw_woo_chatbot_name_greeting'), 'product_asking'=> get_option('cw_woo_chatbot_product_asking'), 'product_suggest'=> get_option('cw_woo_chatbot_product_suggest'), 'product_infinite'=> get_option('cw_woo_chatbot_product_infinite'), 'product_success'=> get_option('cw_woo_chatbot_product_success'), 'product_fail'=> get_option('cw_woo_chatbot_product_fail'), 'currency_symbol' => get_woocommerce_currency_symbol(), ); wp_register_script('qcld-woo-chatbot-slimscroll-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/jquery.slimscroll.min.js', basename(__FILE__)), array('jquery'), CW_CHATBOT_WOO_VERSION, true); wp_enqueue_script('qcld-woo-chatbot-slimscroll-js'); wp_register_script('qcld-woo-chatbot-frontend', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/qcld-woo-chatbot-frontend.js', basename(__FILE__)), array('jquery'), CW_CHATBOT_WOO_VERSION, true); wp_enqueue_script('qcld-woo-chatbot-frontend'); wp_localize_script('qcld-woo-chatbot-frontend', 'woo_chatbot_obj', $woo_chatbot_obj); wp_register_style('qcld-woo-chatbot-frontend-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/frontend-style.css', basename(__FILE__)), '', CW_CHATBOT_WOO_VERSION, 'screen'); wp_enqueue_style('qcld-woo-chatbot-frontend-style'); } public function cw_chatbot_wo_admin_page() { global $woocommerce; $action = 'admin.php?page=cwbotwoo'; ?> <div class="woo-chatbot-wrap wrap"> <div class="icon32"><br></div> <form action="<?php echo esc_attr($action); ?>" method="POST" enctype="multipart/form-data"> <div class="container form-container"> <h2><?php echo __('Woowbot Control Panel', 'woochatbot'); ?></h2> <section class="woo-chatbot-tab-container-inner"> <div class="woo-chatbot-tabs woo-chatbot-tabs-style-flip"> <nav> <ul> <li><a href="#section-flip-1"><i class="fa fa-toggle-on"></i><span> <strong>GENERAL SETTINGS</strong></span></a> </li> <li><a href="#section-flip-3"><i class="fa fa-gear faa-spin"></i><span> Woowbot ICONS</span></a></li> <li><a href="#section-flip-7"><i class="fa fa-language"></i><span> LANGUAGE CENTER</span></a></li> <li><a href="#section-flip-8"><i class="fa fa-code"></i><span> Custom CSS</span></a></li> </ul> </nav> <div class="content-wrap"> <section id="section-flip-1"> <div class="top-section"> <div class="row"> <div class="col-xs-12"> <p class="qc-opt-title-font"> Disable Woowbot </p> <div class="cxsc-settings-blocks"> <input value="1" id="disable_woo_chatbot" type="checkbox" name="disable_woo_chatbot" <?php echo(get_option('disable_woo_chatbot') == 1 ? 'checked' : ''); ?>> <label for="disable_woo_chatbot">Disable Woowbot to load </label> </div> </div> </div> <div class="row"> <div class="col-xs-12"> <p class="qc-opt-title-font"> Override Woowbot Icon's Position </p> <div class="cxsc-settings-blocks"> <?php $cw_chatbot_wo_position_x = get_option('woo_chatbot_position_x'); if ((!isset($cw_chatbot_wo_position_x)) || ($cw_chatbot_wo_position_x == "")) { $cw_chatbot_wo_position_x = __("120", "woo_chatbot"); } $cw_chatbot_wo_position_y = get_option('woo_chatbot_position_y'); if ((!isset($cw_chatbot_wo_position_y)) || ($cw_chatbot_wo_position_y == "")) { $cw_chatbot_wo_position_y = __("50", "woo_chatbot"); } ?> <input type="number" class="qc-opt-dcs-font" name="woo_chatbot_position_x" id="" value="<?php echo($cw_chatbot_wo_position_x); ?>" placeholder="From Right In px"> <span class="qc-opt-dcs-font">From Right In px</span> <input type="number" class="qc-opt-dcs-font" name="woo_chatbot_position_y" id="" value="<?php echo($cw_chatbot_wo_position_y); ?>" placeholder="From Bottom In Px"> <span class="qc-opt-dcs-font">From Bottom In px</span> </div> </div> <div class="col-xs-12"> <div class="form-group"> <p class="qc-opt-title-font">Number of products to show in search results. ( '-1' for all products ).</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_ppp" value="<?php echo(get_option('cw_woo_chatbot_ppp')!=''? get_option('cw_woo_chatbot_ppp') :10);?>"> </div> </div> </div> </div> </section> <section id="section-flip-3"> <div class="top-section"> <div class="row"> <div class="col-xs-12"> <ul class="radio-list"> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-0.png" alt=""> <input type="radio" name="woo_chatbot_icon" <?php echo(get_option('woo_chatbot_icon') == 'icon-0.png' ? 'checked' : ''); ?> value="icon-0.png"> <span class="qc-opt-dcs-font">Icon - 0</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-1.png" alt=""> <input type="radio" name="woo_chatbot_icon" <?php echo(get_option('woo_chatbot_icon') == 'icon-1.png' ? 'checked' : ''); ?> value="icon-1.png"> <span class="qc-opt-dcs-font">Icon - 1</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-2.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-2.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-2.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 2</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-3.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-3.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-3.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 3</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-4.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-4.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-4.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 4</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-5.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-5.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-5.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 5</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-6.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-6.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-6.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 6</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-7.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-7.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-7.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 7</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-8.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-8.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-8.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 8</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-9.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-9.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-9.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon -9</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-10.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-10.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-10.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 10</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-11.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-11.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-11.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 11</span> </li> <li><img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/icon-12.png" alt=""> <input type="radio" name="woo_chatbot_icon" value="icon-12.png" <?php echo(get_option('woo_chatbot_icon') == 'icon-12.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Icon - 12</span> </li> <li> <img src="<?php echo CW_CHATBOT_WOO_IMG_URL; ?>/custom.png?<?php echo time(); ?>" alt=""> <input type="radio" name="woo_chatbot_icon" value="custom.png" <?php echo(get_option('woo_chatbot_icon') == 'custom.png' ? 'checked' : ''); ?>> <span class="qc-opt-dcs-font">Custom Icon</span> </li> </ul> </div> </div> <div class="row"> <div class="col-xs-12"> <p class="qc-opt-title-font"> Upload custom Icon </p> <div class="cxsc-settings-blocks"> <p class="qc-opt-dcs-font"><?php echo __('Select file to upload') ?><input type="file" name="custom_icon" id="custom_icon" size="35" class=""/> <label class="qc-opt-dcs-font" for="pepperoni">Upload Custom Icon</label> </div> </div> </div> </div> </section> <section id="section-flip-7"> <div class="top-section"> <div class="row"> <div class="col-xs-12" id="woo-chatbot-language-section"> <p class="qc-opt-title-font"> Message setting for <strong>Identity </strong ></p> <div class="form-group"> <p class="qc-opt-title-font">Your Company or Website Name</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_host" value="<?php echo(get_option('cw_woo_chatbot_host')!=''? get_option('cw_woo_chatbot_host') :'');?>"> </div> <div class="form-group"> <p class="qc-opt-title-font">Agent name</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_agent" value="<?php echo(get_option('cw_woo_chatbot_agent')!=''? get_option('cw_woo_chatbot_agent') :'John');?>"> </div> <div class="form-group"> <p class="qc-opt-title-font">has joined the conversation</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_agent_join" value="<?php echo(get_option('cw_woo_chatbot_agent_join')!=''? get_option('cw_woo_chatbot_agent_join') :'has joined the conversation');?>"> </div> </div> <div class="col-xs-12" id="woo-chatbot-language-section"> <p class="qc-opt-title-font"> Message setting for <strong>Greetings: </strong ></p> <div class="form-group"> <p class="qc-opt-title-font">Welcome</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_welcome" value="<?php echo(get_option('cw_woo_chatbot_welcome')!=''? get_option('cw_woo_chatbot_welcome') :'Welcome');?>"> </div> <div class="form-group"> <p class="qc-opt-title-font">Hi There! ! Your name please?</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_asking_name" value="<?php echo(get_option('cw_woo_chatbot_asking_name')!=''? get_option('cw_woo_chatbot_asking_name') :'Hi There! ! Your name please?');?>"> </div> <div class="form-group"> <p class="qc-opt-title-font">I am </p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_i_am" value="<?php echo(get_option('cw_woo_chatbot_i_am')!=''? get_option('cw_woo_chatbot_i_am') :'I am ');?>"> </div> <div class="form-group"> <p class="qc-opt-title-font">Nice to meet you</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_name_greeting" value="<?php echo(get_option('cw_woo_chatbot_name_greeting')!=''? get_option('cw_woo_chatbot_name_greeting') :'Nice to meet you');?>"> </div> </div> </div> </div> <div class="top-section"> <div class="row"> <div class="col-xs-12" id="woo-chatbot-language-section"> <p class="qc-opt-title-font">Message settings for <strong> Products Search:</strong ></p> <div class="form-group"> <p class="qc-opt-dcs-font">I am here to find you the product you need. What are you shopping for </p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_product_asking" value="<?php echo(get_option('cw_woo_chatbot_product_asking')!=''? get_option('cw_woo_chatbot_product_asking') :'I am here to find you the product you need. What are you shopping for');?>"> </div> <div class="form-group"> <p class="qc-opt-dcs-font">if products found: </p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_product_success" value="<?php echo(get_option('cw_woo_chatbot_product_success')!=''? get_option('cw_woo_chatbot_product_success') :'Great! We have these products.');?>"> </div> <div class="form-group"> <p class="qc-opt-dcs-font">If no matching products is found: </p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_product_fail" value="<?php echo(get_option('cw_woo_chatbot_product_fail')!=''? get_option('cw_woo_chatbot_product_fail') :'Oops! Nothing matches your criteria ');?>"> </div> <div class="form-group"> <p class="qc-opt-dcs-font">You can browse our extensive catalog. Just pick a category from below:</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_product_suggest" value="<?php echo(get_option('cw_woo_chatbot_product_suggest')!=''? get_option('cw_woo_chatbot_product_suggest') :'You can browse our extensive catalog. Just pick a category from below:');?>"> </div> <div class="form-group"> <p class="qc-opt-dcs-font">Too many choices? Let's try another search term</p> <input type="text" class="form-control qc-opt-dcs-font" name="cw_woo_chatbot_product_infinite" value="<?php echo(get_option('cw_woo_chatbot_product_infinite')!=''? get_option('cw_woo_chatbot_product_infinite') :'Too many choices? Let\'s try another search term');?>"> </div> </div> </div> </div> </section> <section id="section-flip-8"> <div class="top-section"> <div class="row"> <div class="col-xs-12"> <p class="qc-opt-dcs-font">You can paste or write your custom css here.</p> <textarea name="woo_chatbot_custom_css" class="form-control woo-chatbot-custom-css" cols="10" rows="8"><?php echo get_option('woo_chatbot_custom_css'); ?></textarea> </div> </div> </div> </section> </div><!-- /content --> </div><!-- /woo-chatbot-tabs --> <hr> <div class="text-right"> <input type="submit" class="btn btn-primary submit-button" name="submit" id="submit" value="<?php _e('Save Settings', 'woo_chatbot'); ?>"/> </div> </section> </div> <?php wp_nonce_field('woo_chatbot'); ?> </form> </div> <?php } function cw_chatbot_wo_save_options() { global $woocommerce; if (isset($_POST['_wpnonce']) && $_POST['_wpnonce']) { wp_verify_nonce($_POST['_wpnonce'], 'woo_chatbot'); // Check if the form is submitted or not if (isset($_POST['submit'])) { if (isset($_POST["woo_chatbot_position_x"])) { $woo_chatbot_position_x = stripslashes(($_POST["woo_chatbot_position_x"])); update_option('woo_chatbot_position_x', $woo_chatbot_position_x); } if (isset($_POST["woo_chatbot_position_y"])) { $woo_chatbot_position_y = stripslashes(($_POST["woo_chatbot_position_y"])); update_option('woo_chatbot_position_y', $woo_chatbot_position_y); } $disable_woo_chatbot = $_POST["disable_woo_chatbot"]; update_option('disable_woo_chatbot', stripslashes($disable_woo_chatbot)); if (isset($_POST["cw_woo_chatbot_ppp"])) { $cw_woo_chatbot_ppp = $_POST["cw_woo_chatbot_ppp"]; update_option('cw_woo_chatbot_ppp', intval($cw_woo_chatbot_ppp)); } $woo_chatbot_icon = $_POST['woo_chatbot_icon'] ? $_POST['woo_chatbot_icon'] : 'icon-1.png'; update_option('woo_chatbot_icon', sanitize_text_field($woo_chatbot_icon)); if ($_FILES['custom_icon']['tmp_name'] != "") { $pic = 'custom.png'; $img_path = CW_CHATBOT_WOO_IMG_ABSOLUTE_PATH . '/' . $pic; $pic_loc = $_FILES['custom_icon']['tmp_name']; if (move_uploaded_file($pic_loc, $img_path)) { update_option('woo_chatbot_icon', $pic); ?> <script> alert('successfully uploaded');</script><?php } else { ?> <script> alert('error while uploading file');</script><?php } } $woo_chatbot_custom_css = $_POST["woo_chatbot_custom_css"]; update_option('woo_chatbot_custom_css', stripslashes($woo_chatbot_custom_css)); $cw_woo_chatbot_host = $_POST["cw_woo_chatbot_host"]; update_option('cw_woo_chatbot_host', sanitize_text_field($cw_woo_chatbot_host)); $cw_woo_chatbot_agent = $_POST["cw_woo_chatbot_agent"]; update_option('cw_woo_chatbot_agent', sanitize_text_field($cw_woo_chatbot_agent)); $cw_woo_chatbot_agent_join = $_POST["cw_woo_chatbot_agent_join"]; update_option('cw_woo_chatbot_agent_join', sanitize_text_field($cw_woo_chatbot_agent_join)); $cw_woo_chatbot_welcome = $_POST["cw_woo_chatbot_welcome"]; update_option('cw_woo_chatbot_welcome', sanitize_text_field($cw_woo_chatbot_welcome)); $cw_woo_chatbot_asking_name = $_POST["cw_woo_chatbot_asking_name"]; update_option('cw_woo_chatbot_asking_name', sanitize_text_field($cw_woo_chatbot_asking_name)); $cw_woo_chatbot_name_greeting = $_POST["cw_woo_chatbot_name_greeting"]; update_option('cw_woo_chatbot_name_greeting', sanitize_text_field($cw_woo_chatbot_name_greeting)); $cw_woo_chatbot_i_am = $_POST["cw_woo_chatbot_i_am"]; update_option('cw_woo_chatbot_i_am', sanitize_text_field($cw_woo_chatbot_i_am)); if (isset($_POST["cw_woo_chatbot_product_success"])) { $cw_woo_chatbot_product_success = $_POST["cw_woo_chatbot_product_success"]; update_option('cw_woo_chatbot_product_success', sanitize_text_field($cw_woo_chatbot_product_success)); } if (isset($_POST["cw_woo_chatbot_product_fail"])) { $cw_woo_chatbot_product_fail = $_POST["cw_woo_chatbot_product_fail"]; update_option('cw_woo_chatbot_product_fail', sanitize_text_field($cw_woo_chatbot_product_fail)); } $cw_woo_chatbot_product_asking = $_POST["cw_woo_chatbot_product_asking"]; update_option('cw_woo_chatbot_product_asking', sanitize_text_field($cw_woo_chatbot_product_asking)); $cw_woo_chatbot_product_suggest = $_POST["cw_woo_chatbot_product_suggest"]; update_option('cw_woo_chatbot_product_suggest', sanitize_text_field($cw_woo_chatbot_product_suggest)); $cw_woo_chatbot_product_infinite = $_POST["cw_woo_chatbot_product_infinite"]; update_option('cw_woo_chatbot_product_infinite', sanitize_text_field($cw_woo_chatbot_product_infinite)); } } } public static function woocommerce_inactive_notice_for_woo_chatbot() { if (current_user_can('activate_plugins')) : if (!class_exists('WooCommerce')) : deactivate_plugins(plugin_basename(__FILE__)); ?> <div id="message" class="error"> <p> <?php printf( __('%s WoowBot for WooCommerce REQUIRES WooCommerce%s %sWooCommerce%s must be active for WoowBot to work. Please install & activate WooCommerce.', 'woo_chatbot'), '<strong>', '</strong><br>', '</a>' ); ?> </p> </div> <?php elseif (version_compare(get_option('woocommerce_db_version'), CW_CHATBOT_WOO_REQUIRED_WOOCOMMERCE_VERSION, '<')) : ?> <div id="message" class="error"> <div style="clear:both;"></div> </div> <?php endif; endif; } }
Wrapping Up
In this article, I presented the code for implementing a custom chatbot at your WooCommerce store. If you need help with the code, post your questions in the comments and I will get back to you ASAP.
Owais Khan
Owais works as a Marketing Manager at Cloudways (managed hosting platform) where he focuses on growth, demand generation, and strategic partnerships. With more than a decade of experience in digital marketing and B2B, Owais prefers to build systems that help teams achieve their full potential.