Plugin Directory

Changeset 2747697


Ignore:
Timestamp:
06/24/2022 04:33:50 PM (4 years ago)
Author:
shinystat
Message:

Added timestamp update when add-to-cart is done by page refresh.

Location:
shinystat-analytics/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • shinystat-analytics/trunk/README.txt

    r2719488 r2747697  
    55Requires at least: 3.1.0
    66Tested up to: 6.0
    7 Stable tag: 1.0.8
     7Stable tag: 1.0.9
    88Requires PHP: 5.6 or higher
    99License: GPLv2 or later
     
    5555== Changelog ==
    5656
     57= 1.0.9 =
     58* Update timestamp in shn_engage.cart_content when add-to-cart is done by entire page refresh (not by ajax request wc-add-to-cart).
     59
    5760= 1.0.8 =
    5861* Fix timestamp update when cart is empty in get_cart_content js function
     
    8992
    9093== Upgrade Notice ==
     94
     95= 1.0.9 =
     96* Update timestamp in shn_engage.cart_content when add-to-cart is done by page refresh.
    9197
    9298= 1.0.8 =
  • shinystat-analytics/trunk/includes/class-shinystat-analytics.php

    r2647715 r2747697  
    7070            $this->version = SHINYSTAT_ANALYTICS_VERSION;
    7171        } else {
    72             $this->version = '1.0.8';
     72            $this->version = '1.0.9';
    7373        }
    7474        $this->plugin_name = 'shinystat-analytics';
  • shinystat-analytics/trunk/public/class-shinystat-analytics-public.php

    r2647730 r2747697  
    204204    }
    205205
     206    /**
     207     * Check if the request contains POST attributes to add items in the cart.
     208     *
     209     * @since 1.0.9
     210     */
     211    private function is_post_add_to_cart( ) {
     212        global $_POST;
     213
     214        if ( isset($_POST["add-to-cart"]) && is_numeric($_POST["quantity"]) )
     215            return True;
     216
     217        return False;
     218    }
    206219
    207220    /**
     
    219232        $session_existing = WC()->cart && WC()->session && WC()->session->has_session();
    220233        $user_logged = is_user_logged_in() || is_admin();
     234        $update_cart_timestamp = $this->is_post_add_to_cart();
    221235
    222236        ?>
     
    229243
    230244                        cart_content: {},
    231 
    232245   
    233246                        /**
     
    260273                                typeof(shn_engage.cart_content.item_count) !== "undefined" &&
    261274                                shn_engage.cart_content.item_count != cart_content.item_count) {
    262                                
    263                                     var t  = Math.floor(new Date().getTime() / 1000);
    264275                                   
    265                                     cart_content.cart_update_ts = t + "";
    266                                     localStorage.setItem("cart_update_ts", t);
     276                                    cart_content.cart_update_ts = shn_engage.update_timestamp() + "";
    267277                            }
    268278
     
    270280
    271281                        },
     282
     283                                /**
     284                                 * Set local storage cart_update_ts with current timestamp
     285                                 */
     286                                update_timestamp: function() {
     287           
     288                                        var t  = Math.floor(new Date().getTime() / 1000);
     289                                        localStorage.setItem("cart_update_ts", t);
     290                                   
     291                            return t;
     292                                },
    272293
    273294                        /**
     
    404425
    405426                    }
     427               
     428<?php                   if ($update_cart_timestamp) {
     429?>                  shn_engage.update_timestamp();
     430<?php                   }
     431?>
    406432                   
    407433                    //set shn_engage object returning selected methods
     
    424450                        head[0].append(s);
    425451                    }
     452               
    426453                })();
    427454       
  • shinystat-analytics/trunk/shinystat-analytics.php

    r2647715 r2747697  
    1717 * Plugin URI:        https://wordpress.org/plugins/shinystat-analytics/
    1818 * Description:       Activate the plugin and start to use ShinyStat Web Analytics and On-site Marketing Automation tools.
    19  * Version:           1.0.8
     19 * Version:           1.0.9
    2020 * Author:            ShinyStat
    2121 * Author URI:        https://www.shinystat.com
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'SHINYSTAT_ANALYTICS_VERSION', '1.0.8' );
     38define( 'SHINYSTAT_ANALYTICS_VERSION', '1.0.9' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.