Changeset 2089166
- Timestamp:
- 05/16/2019 01:49:26 PM (7 years ago)
- Location:
- activechat-ai/trunk
- Files:
-
- 3 edited
-
include/track.php (modified) (3 diffs)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
activechat-ai/trunk/include/track.php
r2079795 r2089166 24 24 this['agentID'] = h; 25 25 this['anonymousID'] = c('anonymousID') || f() + f(); 26 document['cookie'] = 'anonymousID=' + this['anonymousID'] ;26 document['cookie'] = 'anonymousID=' + this['anonymousID'] + '; path=/ '; 27 27 }, 28 28 'track': function track(i) { … … 61 61 } 62 62 63 function AdminAcVV_add_action_woocommerce_add_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data){ 63 function AdminAcVV_add_action_woocommerce_add_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data) 64 { 64 65 if (!empty($_POST) && sanitize_text_field(get_option('woocommerce_cart_redirect_after_add')) == 'no') { 65 66 ?> … … 85 86 86 87 87 function accw_add_action_woocommerce_new_order() { 88 89 if ( is_order_received_page() == 1 ) { 90 global $wp; 91 $order_id = $wp->query_vars['order-received']; 92 $customer_id = get_post_meta($order_id, '_customer_user', true); 93 $agent_id = sanitize_key(get_option('acvv_save_bot_id')); 94 $user_id = '12' 95 ?> 88 function accw_add_action_woocommerce_new_order() 89 { 90 91 if (is_order_received_page() == 1) { 92 global $wp; 93 $order_id = $wp->query_vars['order-received']; 94 $customer_id = get_post_meta($order_id, '_customer_user', true); 95 $agent_id = sanitize_key(get_option('acvv_save_bot_id')); 96 $user_id = '12' 97 ?> 96 98 <script> 97 99 window.addEventListener('load', function() { 98 100 99 activechat.track('order_create', {_woo_order_id: '<?php esc_attr_e($order_id); ?>'}); 100 101 102 103 const setBind = (agentID, userID, orderID, customerID) => { 104 return new Promise((resolve, reject) => { 105 const BINDS_SERVER_URL = 'https://components-ecommerce.herokuapp.com' 106 107 let url = new URL(`${BINDS_SERVER_URL}/webhook/bind`) 108 109 fetch(url, { 110 mode: 'cors', 111 method: 'post', 112 headers: { 113 'Content-Type': 'application/json' 114 }, 115 body: JSON.stringify({ agentID, userID, orderID, customerID }), 116 }) 117 .then((response) => { 118 return response.json() 119 }).then(data => { 120 if (!data.ok) throw new Error(data.result) 121 resolve(data.result) 122 }).catch((e) => { 123 reject({ message: e.message }) 124 }); 125 }) 126 } 127 128 const getUserByAnonymousID = (agentID, anonymousID) => { 129 return new Promise((resolve, reject) => { 130 const ARCHITECTOR_SERVER_URL = 'https://architector-dot-activechat-200215.appspot.com' 131 132 let url = new URL(`${ARCHITECTOR_SERVER_URL}/anonymous/user`) 133 134 fetch(url, { 135 mode: 'cors', 136 method: 'post', 137 headers: { 138 'Content-Type': 'application/json' 139 }, 140 body: JSON.stringify({ agentID, anonymousID }), 141 }) 142 .then((response) => { 143 return response.json() 144 }).then(data => { 145 if (!data.ok) throw new Error(data.result) 146 resolve(data.result) 147 }).catch((e) => { 148 reject({ message: e.message }) 149 }); 150 }) 151 } 152 153 154 getUserByAnonymousID('<?php esc_attr_e($agent_id); ?>', activechat.anonymousID) 155 .then((user) => { 156 157 return setBind('<?php esc_attr_e($agent_id); ?>', `${user.user.id}`, '<?php esc_attr_e($order_id); ?>', '<?php esc_attr_e($customer_id); ?>'); 158 159 }) 160 .then(() => { 161 162 }) 163 .catch(error => { 164 console.error('[ERROR]:', error.message) 165 }) 166 167 168 169 170 171 101 activechat.track('order_create', { 102 _woo_order_id: '<?php esc_attr_e($order_id); ?>' 103 }); 104 105 106 107 const setBind = (agentID, userID, orderID, customerID) => { 108 return new Promise((resolve, reject) => { 109 const BINDS_SERVER_URL = 'https://components-ecommerce.herokuapp.com' 110 111 let url = new URL(`${BINDS_SERVER_URL}/webhook/bind`) 112 113 fetch(url, { 114 mode: 'cors', 115 method: 'post', 116 headers: { 117 'Content-Type': 'application/json' 118 }, 119 body: JSON.stringify({ 120 agentID, 121 userID, 122 orderID, 123 customerID 124 }), 125 }) 126 .then((response) => { 127 return response.json() 128 }).then(data => { 129 if (!data.ok) throw new Error(data.result) 130 resolve(data.result) 131 }).catch((e) => { 132 reject({ 133 message: e.message 134 }) 135 }); 136 }) 137 } 138 139 const getUserByAnonymousID = (agentID, anonymousID) => { 140 return new Promise((resolve, reject) => { 141 const ARCHITECTOR_SERVER_URL = 'https://architector-dot-activechat-200215.appspot.com' 142 143 let url = new URL(`${ARCHITECTOR_SERVER_URL}/anonymous/user`) 144 145 fetch(url, { 146 mode: 'cors', 147 method: 'post', 148 headers: { 149 'Content-Type': 'application/json' 150 }, 151 body: JSON.stringify({ 152 agentID, 153 anonymousID 154 }), 155 }) 156 .then((response) => { 157 return response.json() 158 }).then(data => { 159 if (!data.ok) throw new Error(data.result) 160 resolve(data.result) 161 }).catch((e) => { 162 reject({ 163 message: e.message 164 }) 165 }); 166 }) 167 } 168 169 170 getUserByAnonymousID('<?php esc_attr_e($agent_id); ?>', activechat.anonymousID) 171 .then((user) => { 172 173 return setBind('<?php esc_attr_e($agent_id); ?>', `${user.user.id}`, '<?php esc_attr_e($order_id); ?>', '<?php esc_attr_e($customer_id); ?>'); 174 175 }) 176 .then(() => { 177 178 }) 179 .catch(error => { 180 console.error('[ERROR]:', error.message) 181 }) 182 183 184 185 186 187 172 188 173 189 }); 174 190 </script> 175 191 <?php 176 } 177 }; 178 192 } 193 }; 194 179 195 180 196 add_action('wp_footer', 'accw_add_action_woocommerce_new_order'); 181 197 182 198 183 function accw_add_action_woocommerce_add_to_cart_ajax() { 184 ?> 185 <script> 186 window.addEventListener('load', function() { 187 188 let ajaxButton = document.querySelectorAll('.ajax_add_to_cart'); 189 for(var i = 0; i < ajaxButton.length; i++){ 190 ajaxButton[i].addEventListener('click', function(event) { 191 activechat.track('add_to_cart', { 192 _woo_cart_cart_item_key: 'null', 193 _woo_cart_product_id: event.target.getAttribute('data-product_id'), 194 _woo_cart_quantity: event.target.getAttribute('data-quantity'), 195 _woo_cart_variation_id: 'null', 196 _woo_cart_variation: 'nuu', 197 _woo_cart_cart_item_data: 'null' 198 199 }) 200 }) 201 } 202 }); 203 </script> 204 <?php 205 }; 199 function accw_add_action_woocommerce_add_to_cart_ajax() 200 { 201 ?> 202 <script> 203 window.addEventListener('load', function() { 204 205 let ajaxButton = document.querySelectorAll('.ajax_add_to_cart'); 206 for (var i = 0; i < ajaxButton.length; i++) { 207 ajaxButton[i].addEventListener('click', function(event) { 208 activechat.track('add_to_cart', { 209 _woo_cart_cart_item_key: 'null', 210 _woo_cart_product_id: event.target.getAttribute('data-product_id'), 211 _woo_cart_quantity: event.target.getAttribute('data-quantity'), 212 _woo_cart_variation_id: 'null', 213 _woo_cart_variation: 'nuu', 214 _woo_cart_cart_item_data: 'null' 215 216 }) 217 }) 218 } 219 }); 220 </script> 221 <?php 222 }; 206 223 207 224 add_action('wp_footer', 'accw_add_action_woocommerce_add_to_cart_ajax'); -
activechat-ai/trunk/index.php
r2087471 r2089166 4 4 Plugin URI: https://activechat.ai/manuals/e-commerce-chatbots/wordpress-plugin/ 5 5 Description: Activechat.ai - smart multichannel chatbots and live chat - is a free plugin for WordPress which allows users to easily integrate their Activechat bots to any WordPress website with zero bot training or code knowledge required. Pure plug’n’play experience. 6 Version: 1.0. 36 Version: 1.0.4 7 7 Author: ActiveChat 8 8 Author URI: https://activechat.ai/ -
activechat-ai/trunk/readme.txt
r2087480 r2089166 4 4 Requires at least: 2.3 5 5 Tested up to: 5.1.1 6 Stable tag: 1.0. 37 Version: 1.0. 36 Stable tag: 1.0.4 7 Version: 1.0.4 8 8 Requires PHP: 5.2.4 9 9 … … 107 107 = 1.0.3 = 108 108 Minor bugs were fixed 109 109 = 1.0.4 = 110 Tracking code were updated 111 110 112 == Upgrade Notice == 111 = 1.0. 3=112 Minor bugs were fixed113 = 1.0.4 = 114 Tracking code were updated 113 115 114 116 117
Note: See TracChangeset
for help on using the changeset viewer.