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.6 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4
woowbot-woocommerce-chatbot / functions.php
woowbot-woocommerce-chatbot Last commit date
css 8 years ago fonts 8 years ago images 8 years ago js 8 years ago functions.php 8 years ago qcld-woowbot.php 8 years ago readme.txt 8 years ago
functions.php
199 lines
1 <?php
2
3 /**
4 * @param $type
5 * Display recently viewed products
6 */
7 if (!defined('ABSPATH')) exit; // Exit if accessed directly
8
9
10 add_action('wp_footer', 'woo_chatbot_load_footer_html');
11 function woo_chatbot_load_footer_html()
12 { ?>
13 <?php if (get_option('disable_woo_chatbot') != 1): ?>
14 <style>
15 <?php if(get_option('woo_chatbot_custom_css')!=""){echo get_option('woo_chatbot_custom_css'); } ?>
16 </style>
17 <div id="woo-chatbot-icon-container">
18 <div id="woo-chatbot-ball-wrapper" style="display:none">
19
20 <div id="woo-chatbot-ball-container" style="display:none" class="woo-chatbot-ball-container">
21 <div class="woo-chatbot-admin">
22 <h3>Conversations</h3>
23 <h4>with <?php if(get_option('qlcd_woo_chatbot_agent')!=''){echo get_option('qlcd_woo_chatbot_agent');} ?></h4>
24 </div>
25 <div class="woo-chatbot-ball-inner">
26 <div class="woo-chatbot-messages-wrapper">
27 <ul id="woo-chatbot-messages-container" class="woo-chatbot-messages-container">
28 </ul>
29 </div>
30 </div>
31 <div id="woo-chatbot-editor-container" class="woo-chatbot-editor-container">
32 <input id="woo-chatbot-editor" class="woo-chatbot-editor" required placeholder="Send a message."
33 maxlength="100">
34 <button type="button" id="woo-chatbot-send-message" class="woo-chatbot-button">send</button>
35 </div>
36 </div>
37 <!--woo-chatbot-ball-container-->
38 <div id="woo-chatbot-ball" class="woo-chatbot-ball">
39 <img src="<?php echo QCLD_WOOCHATBOT_IMG_URL . '/' . get_option('woo_chatbot_icon'); ?>"
40 alt="WooChatIcon">
41 </div>
42 <!--container-->
43 </div>
44 <!--woo-chatbot-ball-wrapper-->
45 </div>
46 <?php endif;
47
48 }
49
50 add_action('wp_ajax_qcld_woo_chatbot_keyword', 'qcld_woo_chatbot_keyword');
51 add_action('wp_ajax_nopriv_qcld_woo_chatbot_keyword', 'qcld_woo_chatbot_keyword');
52
53
54 function qcld_woo_chatbot_keyword()
55 {
56 $keyword = sanitize_text_field($_POST['keyword']);
57 $product_per_page=get_option('qlcd_woo_chatbot_ppp')!=''? get_option('qlcd_woo_chatbot_ppp') :10;
58 //Merging all query together.
59 $argu_params = array(
60 'post_type' => 'product',
61 'posts_per_page' => $product_per_page,
62 'order' => 'ASC',
63 's' => $keyword,
64 );
65 /******
66 *WP Query Operation to get products.*
67 *******/
68 $product_query = new WP_Query($argu_params);
69 $product_num = $product_query->post_count;
70 $html = '<div class="woo-chatbot-featured-products">';
71
72 $_pf = new WC_Product_Factory();
73 //repeating the products
74 if ($product_num > 0) {
75 //$html .= '<p>sdf sdfdsf : '.$asdfdf.'</p>';
76 $html .= '<ul class="woo-chatbot-products">';
77 while ($product_query->have_posts()) : $product_query->the_post();
78 $product = $_pf->get_product(get_the_ID());
79 //$qcld_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'shop_thumbnail' );
80 $html .= '<li class="woo-chatbot-product">';
81 $html .= '<a target="_blank" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '">';
82 $html .= get_the_post_thumbnail(get_the_ID(), 'shop_catalog') . '</a>
83 <div class="woo-chatbot-product-summary">
84 <div class="woo-chatbot-product-table">
85 <div class="woo-chatbot-product-table-cell">
86 <h3 class="woo-chatbot-product-title"><a target="_blank" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '">' . $product->post->post_title . '</a></h3>
87 <div class="price">' . $product->get_price_html() . '</div>';
88
89 // if ($product->is_type('simple')) {
90 // $html .= '<a target="_blank" href="' . get_site_url() . '?add-to-cart=' . get_the_ID() . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '" class="woo-chatbot-button woo-chatbot-button-cart add_to_cart_button ajax_add_to_cart" data-quantity="1" data-product_id="' . get_the_ID() . '" >Add to Cart</a>';
91 // } else {
92 // $html .= '<a target="_blank" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '" class="woo-chatbot-button woo-chatbot-button-cart" >View Detail</a>';
93 // }
94 $html .= ' </div>
95 </div>
96 </div>
97 </li>';
98 endwhile;
99 wp_reset_postdata();
100 $html .= '</ul>';
101 }
102 $html .= '</div>';
103 $response = array('html' => $html, 'product_num' => $product_num);
104 echo wp_send_json($response);
105 wp_die();
106 }
107
108 add_action('wp_ajax_qcld_woo_chatbot_category', 'qcld_woo_chatbot_category');
109 add_action('wp_ajax_nopriv_qcld_woo_chatbot_category', 'qcld_woo_chatbot_category');
110
111 function qcld_woo_chatbot_category()
112 {
113 $terms = get_terms(array(
114 'taxonomy' => 'product_cat',
115 'hide_empty' => false,
116 ));
117 $html = "";
118 foreach ($terms as $term) {
119
120 $html .= '<span class="qcld-chatbot-product-category" type="button" data-category-slug="' . $term->slug . '" data-category-id="' . $term->term_id . '">' . $term->name . '</span>';
121 }
122 echo wp_send_json($html);
123 wp_die();
124 }
125
126 add_action('wp_ajax_qcld_woo_chatbot_category_products', 'qcld_woo_chatbot_category_products');
127 add_action('wp_ajax_nopriv_qcld_woo_chatbot_category_products', 'qcld_woo_chatbot_category_products');
128 function qcld_woo_chatbot_category_products()
129 {
130 $category_id = stripslashes($_POST['category']);
131 $product_per_page=get_option('qlcd_woo_chatbot_ppp')!=''? get_option('qlcd_woo_chatbot_ppp') :10;
132 //Merging all query together.
133 $argu_params = array(
134 'post_type' => 'product',
135 'post_status' => 'publish',
136 'ignore_sticky_posts' => 1,
137 'posts_per_page' => $product_per_page,
138 'tax_query' => array(
139 array(
140 'taxonomy' => 'product_cat',
141 'field' => 'term_id',
142 'terms' => $category_id,
143 'operator' => 'IN'
144 )
145 )
146 );
147 /******
148 *WP Query Operation to get products.*
149 *******/
150 $product_query = new WP_Query($argu_params);
151 $product_num = $product_query->post_count;
152
153 $_pf = new WC_Product_Factory();
154 //repeating the products
155 $html="";
156 if ($product_num > 0) {
157
158 $html .= '<div class="woo-chatbot-featured-products">';
159 //$html .= '<p>sdf sdfdsf : '.$asdfdf.'</p>';
160 $html .= '<ul class="woo-chatbot-products">';
161 while ($product_query->have_posts()) : $product_query->the_post();
162 $product = $_pf->get_product(get_the_ID());
163 //$qcld_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'shop_thumbnail' );
164 $html .= '<li class="woo-chatbot-product">';
165 $html .= '<a target="_blank" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '">';
166 $html .= get_the_post_thumbnail(get_the_ID(), 'shop_catalog') . '</a>
167 <div class="woo-chatbot-product-summary">
168 <div class="woo-chatbot-product-table">
169 <div class="woo-chatbot-product-table-cell">
170 <h3 class="woo-chatbot-product-title"><a target="_blank" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '">' . $product->post->post_title . '</a></h3>
171 <div class="price">' . $product->get_price_html() . '</div>';
172
173 // if ($product->is_type('simple')) {
174 // $html .= '<a target="_blank" href="' . get_site_url() . '?add-to-cart=' . get_the_ID() . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '" class="woo-chatbot-button woo-chatbot-button-cart add_to_cart_button ajax_add_to_cart" data-quantity="1" data-product_id="' . get_the_ID() . '" >Add to Cart</a>';
175 // } else {
176 // $html .= '<a target="_blank" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr($product->post->post_title ? $product->post->post_title : get_the_ID()) . '" class="woo-chatbot-button woo-chatbot-button-cart" >View Detail</a>';
177 // }
178 $html .= ' </div>
179 </div>
180 </div>
181 </li>';
182 endwhile;
183 wp_reset_postdata();
184 $html .= '</ul>';
185
186 $html .= '</div>';
187 }else{
188 $html.="";
189 }
190 $response = array('html' => $html, 'product_num' => $product_num);
191 echo wp_send_json($response);
192 wp_die();
193
194 }
195
196
197
198
199