Plugin Directory

Changeset 2148364


Ignore:
Timestamp:
08/30/2019 10:52:15 AM (7 years ago)
Author:
activechat
Message:

Delay before loading scripts was deleted

Location:
activechat-ai/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • activechat-ai/trunk/include/track.php

    r2147319 r2148364  
    88    ?>
    99    <script>
    10         "use strict";
    11         window.addEventListener("load", function() {
     10        (function() {
    1211            var script = document.createElement('script');
    1312            script.src = 'https://app.activechat.ai/script/<?php esc_attr_e($bot_id); ?>';
    1413            script.id = 'ACCW_EMBED';
    1514            script.onload = () => {
    16                 try{
    17                     loadedACCWScript();
    18                 } catch{}
    19             }
     15                try {
     16                    loadedACCWScript();
     17                } catch {}
     18            }
    2019            document.getElementsByTagName('head')[0].appendChild(script);
    21         }, false);
     20        })();
    2221    </script>
    23 <?php
     22    <?php
    2423
    25 }
     24    }
    2625
    27 function AdminAcVV_add_action_woocommerce_add_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data)
    28 {
    29     if (!empty($_POST)  && sanitize_text_field(get_option('woocommerce_cart_redirect_after_add')) == 'no') {
    30         ?>
     26    function AdminAcVV_add_action_woocommerce_add_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data)
     27    {
     28        if (!empty($_POST)  && sanitize_text_field(get_option('woocommerce_cart_redirect_after_add')) == 'no') {
     29            ?>
    3130        <script>
    32             function loadedACCWScript(){
    33                 document.querySelector('#AC_TRACK').addEventListener('load', function() {
    34                     activechat.track('add_to_cart', {
     31            function loadedACCWScript() {
     32                document.querySelector('#AC_TRACK').addEventListener('load', function() {
     33                    activechat.track('add_to_cart', {
    3534                        _woo_cart_cart_item_key: '<?php esc_attr_e($cart_item_key); ?>',
    3635                        _woo_cart_product_id: '<?php esc_attr_e($product_id); ?>',
     
    3938                        _woo_cart_variation: '<?php esc_attr_e($variation); ?>',
    4039                        _woo_cart_cart_item_data: '<?php esc_attr_e($cart_item_data); ?>',
    41                      });
    4240                    });
    43              }
     41                });
     42            }
    4443        </script>
    45     <?php
    46     }
    47 }
    48 add_action('woocommerce_add_to_cart', 'AdminAcVV_add_action_woocommerce_add_to_cart', 10, 6);
     44        <?php
     45            }
     46        }
     47        add_action('woocommerce_add_to_cart', 'AdminAcVV_add_action_woocommerce_add_to_cart', 10, 6);
    4948
    5049
    51 function accw_add_action_woocommerce_new_order()
    52 {
    53     if (class_exists('WooCommerce')) {
    54         if (is_order_received_page() == 1) {
    55             global $wp;
    56             $order_id = $wp->query_vars['order-received'];
    57             $customer_id = get_post_meta($order_id, '_customer_user', true);
    58             $agent_id = sanitize_key(get_option('acvv_save_bot_id'));
    59             $user_id = '12'
    60             ?>
     50        function accw_add_action_woocommerce_new_order()
     51        {
     52            if (class_exists('WooCommerce')) {
     53                if (is_order_received_page() == 1) {
     54                    global $wp;
     55                    $order_id = $wp->query_vars['order-received'];
     56                    $customer_id = get_post_meta($order_id, '_customer_user', true);
     57                    $agent_id = sanitize_key(get_option('acvv_save_bot_id'));
     58                    $user_id = '12'
     59                    ?>
    6160            <script>
    62              
    63 
    64                     function loadedACCWScript() {
     61                function loadedACCWScript() {
    6562                    document.querySelector('#AC_TRACK').addEventListener('load', function() {
    66                         activechat.track('order_create', {
    67                              _woo_order_id: '<?php esc_attr_e($order_id); ?>'
    68                           });
    69                    });
     63                        activechat.track('order_create', {
     64                            _woo_order_id: '<?php esc_attr_e($order_id); ?>'
     65                        });
     66                    });
    7067
    7168
     
    155152                };
    156153            </script>
    157         <?php
     154    <?php
     155            }
    158156        }
    159     }
    160 };
     157    };
    161158
    162159
    163 add_action('wp_footer', 'accw_add_action_woocommerce_new_order');
     160    add_action('wp_footer', 'accw_add_action_woocommerce_new_order');
    164161
    165162
    166 function accw_add_action_woocommerce_add_to_cart_ajax()
    167 {
    168     ?>
     163    function accw_add_action_woocommerce_add_to_cart_ajax()
     164    {
     165        ?>
    169166    <script>
    170167        window.addEventListener('load', function() {
  • activechat-ai/trunk/index.php

    r2147310 r2148364  
    44  Plugin URI:  https://activechat.ai/manuals/e-commerce-chatbots/wordpress-plugin/
    55  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.9
     6  Version:     1.0.10
    77  Author:      ActiveChat
    88  Author URI:  https://activechat.ai/
  • activechat-ai/trunk/readme.txt

    r2147310 r2148364  
    121121 = 1.0.9 =
    122122Fixed bug with "add_to_cart" event
     123 = 1.0.10 =
     124Delay before loading scripts was deleted
    123125
    124126== Upgrade Notice ==
    125 = 1.0.9 =
    126 Fixed bug with "add_to_cart" event
     127= 1.0.10 =
     128Delay before loading scripts was deleted
    127129
    128130
Note: See TracChangeset for help on using the changeset viewer.