Plugin Directory

Changeset 3221608


Ignore:
Timestamp:
01/13/2025 01:26:37 PM (15 months ago)
Author:
usermaven
Message:

tagging version 1.1.1

Location:
usermaven
Files:
6 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • usermaven/tags/1.1.1/README.txt

    r3217626 r3221608  
    66Tested up to: 6.7.1
    77Requires PHP: 5.6
    8 Stable tag: 1.1.0
     8Stable tag: 1.1.1
    99License: Massachusetts Institute of Technology (MIT) license
    1010License URI: https://opensource.org/licenses/MIT
  • usermaven/tags/1.1.1/includes/class-usermaven-woocommerce.php

    r3217559 r3221608  
    6060        // Reset the tracking flag when the cart is updated or order completes/fails
    6161        add_action('woocommerce_cart_updated', array($this, 'reset_initiate_checkout_tracking'));
    62         add_action('woocommerce_thankyou', array($this, 'reset_initiate_checkout_tracking'));
     62        add_action('woocommerce_thankyou', array($this, 'track_order_thankyou'), 10);
    6363        add_action('woocommerce_order_status_completed', array($this, 'reset_initiate_checkout_tracking'));
    6464        add_action('woocommerce_order_status_failed', array($this, 'reset_initiate_checkout_tracking'));
     
    101101                return;
    102102            }
    103    
     103
    104104            // Get the product ID
    105105            $product_id = get_the_ID();
     
    107107                return;
    108108            }
    109    
     109
    110110            // Get the product
    111111            global $product;
     
    113113                $product = wc_get_product($product_id);
    114114            }
    115    
     115
    116116            // Silently return if no valid product
    117117            if (!$product instanceof WC_Product) {
    118118                return;
    119119            }
    120    
     120
    121121            // Get product categories
    122122            $categories = array();
     
    125125                $categories = wp_list_pluck($terms, 'name');
    126126            }
    127    
    128             // Prepare event attributes
    129             $event_attributes = array(
     127
     128            // Create items array with single product
     129            $items = array(array(
    130130                'product_id' => (int) $product->get_id(),
    131131                'product_name' => (string) $product->get_name(),
     
    135135                'categories' => array_map('strval', $categories),
    136136                'sku' => (string) $product->get_sku(),
    137                 'stock_status' => (string) $product->get_stock_status(),
     137                'stock_status' => (string) $product->get_stock_status()
     138            ));
     139
     140            $event_attributes = array(
     141                ...$items[0],
     142
     143                // Items Array
     144                'items' => $items,
    138145            );
    139    
     146
    140147            // Send the event
    141148            $this->send_event('viewed_product', $event_attributes);
    142    
     149
    143150        } catch (Exception $e) {
    144151            // Log the error but don't halt execution
     
    146153        }
    147154    }
    148    
     155
    149156
    150157    /**
     
    176183        $unit_price = $unit_price === '' ? 0.0 : (float) $unit_price;
    177184        $price_total = (float) ($quantity * $unit_price);
    178        
    179         $event_attributes = array(
     185
     186        // Create items array with single product
     187        $items = array(array(
    180188            // Product Information
    181189            'product_id' => (int) $product_id,
     
    192200            'sale_price' => (float) $product->get_sale_price(),
    193201            'price_total' => $price_total,
     202            'is_on_sale' => (bool) $product->is_on_sale(),
    194203            'currency' => (string) get_woocommerce_currency(),
    195             'is_on_sale' => (bool) $product->is_on_sale(),
    196 
     204           
    197205            // Stock Information
    198206            'stock_status' => (string) $product->get_stock_status(),
     
    201209                null,
    202210            'is_in_stock' => (bool) $product->is_in_stock(),
    203 
     211           
    204212            // Variation Details
    205213            'variation_id' => (int) $variation_id,
    206             'variation_attributes' => $variation_attributes,
    207 
    208             // Cart State
     214            'variation_attributes' => $variation_attributes
     215        ));
     216
     217        $event_attributes = array(
     218            ...$items[0],
    209219            'cart_total' => (float) WC()->cart->get_cart_contents_total(),
    210220            'cart_subtotal' => (float) WC()->cart->get_subtotal(),
     
    213223            'cart_unique_items' => (int) count(WC()->cart->get_cart()),
    214224            'applied_coupons' => array_map('strval', WC()->cart->get_applied_coupons()),
    215 
     225           
     226            // Items Array
     227            'items' => $items,
     228           
    216229            // Additional Context
    217230            'added_from' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     
    259272        $price_per_unit = $price_per_unit === '' ? 0.0 : (float) $price_per_unit;
    260273
    261         $event_attributes = array(
    262             // Product Information
     274        // Create items array with single product
     275        $items = array(array(
    263276            'product_id' => (int) $product_id,
    264277            'product_name' => (string) $product->get_name(),
     
    267280            'categories' => array_map('strval', $categories),
    268281            'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    269 
     282           
    270283            // Removed Item Details
    271284            'quantity_removed' => (int) $cart_item['quantity'],
     
    274287            'price_per_unit' => $price_per_unit,
    275288            'currency' => (string) get_woocommerce_currency(),
    276 
     289           
    277290            // Variation Details
    278291            'variation_id' => !empty($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : 0,
    279             'variation_attributes' => $variation_attributes,
    280 
    281             // Cart State After Removal
     292            'variation_attributes' => $variation_attributes
     293        ));
     294
     295        $event_attributes = array(
     296            ...$items[0],
    282297            'cart_total' => (float) $cart->get_cart_contents_total(),
    283298            'cart_subtotal' => (float) $cart->get_subtotal(),
     
    286301            'remaining_unique_items' => (int) count($cart->get_cart()),
    287302            'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
    288 
     303           
     304            // Items Array
     305            'items' => $items,
     306           
    289307            // Additional Context
    290308            'removed_from_page' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     
    305323            return;
    306324        }
    307    
     325
    308326        $product_id = $cart_item['product_id'];
    309327        $product = wc_get_product($product_id);
     
    311329            return;
    312330        }
    313    
     331
    314332        // Get product categories
    315333        $categories = array();
     
    318336            $categories = wp_list_pluck($terms, 'name');
    319337        }
    320    
     338
    321339        // Process variation attributes
    322340        $variation_attributes = array();
     
    326344            }
    327345        }
    328    
     346
    329347        // Calculate line totals
    330348        $unit_price = $product->get_price();
     
    332350        $old_line_total = (float) ($old_quantity * $unit_price);
    333351        $new_line_total = (float) ($quantity * $unit_price);
    334    
    335         $event_attributes = array(
     352
     353        // Create items array with the updated product
     354        $items = array(array(
    336355            // Product Information
     356            'product_id' => (int) $product_id,
    337357            'product_name' => (string) $product->get_name(),
    338             'product_id' => (int) $product_id,
    339358            'product_type' => (string) $product->get_type(),
    340359            'categories' => array_map('strval', $categories),
    341360            'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    342    
     361           
    343362            // Quantity Change Details
    344363            'old_quantity' => (int) $old_quantity,
     
    349368            'new_line_total' => (float) $new_line_total,
    350369            'currency' => (string) get_woocommerce_currency(),
    351    
     370           
     371            // Stock Information
     372            'stock_status' => (string) $product->get_stock_status(),
     373            'remaining_stock' => $product->get_stock_quantity() !== null ?
     374                (int) $product->get_stock_quantity() :
     375                null,
     376           
     377            // Variation Details
     378            'variation_id' => (int) ($cart_item['variation_id'] ?? 0),
     379            'variation_attributes' => $variation_attributes
     380        ));
     381
     382        $event_attributes = array(
     383            ...$items[0],
     384
     385            // Items Array
     386            'items' => $items,
     387           
    352388            // Cart State
    353389            'cart_total' => (float) $cart->get_total('numeric'),
     
    357393            'cart_unique_items' => (int) count($cart->get_cart()),
    358394            'cart_discount' => (float) $cart->get_discount_total(),
    359    
    360             // Stock Information
    361             'stock_status' => (string) $product->get_stock_status(),
    362             'remaining_stock' => $product->get_stock_quantity() !== null ?
    363                 (int) $product->get_stock_quantity() :
    364                 null,
    365    
     395            'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
     396           
    366397            // Additional Context
    367398            'update_source' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     
    369400            'timestamp' => current_time('mysql'),
    370401            'session_id' => (string) WC()->session->get_customer_id(),
    371             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''),
    372    
    373             // Variation Details
    374             'variation_id' => (int) ($cart_item['variation_id'] ?? 0),
    375             'variation_attributes' => $variation_attributes,
    376    
    377             // Applied Coupons
    378             'applied_coupons' => array_map('strval', $cart->get_applied_coupons())
    379         );
    380    
     402            'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     403        );
     404
    381405        $this->send_event('updated_cart_item', $event_attributes);
    382406    }
     
    574598            return;
    575599        }
    576    
     600
     601        // Get items in consistent format
     602        $items = $this->get_formatted_order_items($order);
     603        $location_details = $this->get_location_details($order);
     604
    577605        $event_attributes = array(
    578             'order_id' => (int) $order_id,
    579             'old_status' => (string) $old_status,
    580             'new_status' => (string) $new_status,
    581             'total' => (float) $order->get_total(),
    582             'currency' => (string) $order->get_currency(),
    583             'payment_method' => (string) $order->get_payment_method(),
    584             'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null,
    585             'billing_email' => (string) $order->get_billing_email(),
    586             'timestamp' => (string) current_time('mysql')
    587         );
    588    
     606           
     607                'order_id' => (int) $order_id,
     608                'old_status' => (string) $old_status,
     609                'new_status' => (string) $new_status,
     610                'total' => (float) $order->get_total(),
     611                'currency' => (string) $order->get_currency(),
     612                'payment_method' => (string) $order->get_payment_method(),
     613           
     614                // Items Information
     615                'items' => $items,
     616                'items_count' => (int) $order->get_item_count(),
     617               
     618                'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null,
     619                'billing_email' => (string) $order->get_billing_email(),
     620                'customer_note' => (string) $order->get_customer_note(),               
     621                // Additional Context
     622                'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     623                'timestamp' => (string) current_time('mysql')
     624        );
     625
    589626        $this->send_event('order_status_changed', $event_attributes);
    590627    }
     
    796833            // Customer Information
    797834            'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null,
     835            'customer_note' => (string) $order->get_customer_note(),
    798836            'customer_type' => (string) ($order->get_customer_id() ? 'registered' : 'guest'),
    799837            'is_registered_customer' => (bool) $order->get_customer_id(),
     
    12331271            return;
    12341272        }
    1235    
     1273
     1274        // Get items in consistent format
     1275        $items = $this->get_formatted_order_items($order);
     1276
    12361277        $event_attributes = array(
    12371278            'order_id' => (int) $order_id,
     
    12411282            'status' => (string) $order->get_status(),
    12421283            'items_count' => (int) $order->get_item_count(),
     1284            'items' => $items,  // Added items array
    12431285            'billing_email' => (string) $order->get_billing_email(),
    12441286            'timestamp' => (string) current_time('mysql')
    12451287        );
    1246    
    1247         $this->send_event('order_thankyou_page_view', $event_attributes);
     1288
     1289        $this->send_event('order_thankyou_page_viewed', $event_attributes);   
    12481290    }
    12491291
     
    16151657        $wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_id);
    16161658       
     1659        // Create items array with single product
     1660        $items = array(array(
     1661            'product_id' => (int) $product_id,
     1662            'product_name' => (string) $product->get_name(),
     1663            'product_price' => (float) $product->get_price(),
     1664            'product_type' => (string) $product->get_type(),
     1665            'product_sku' => (string) $product->get_sku(),
     1666            'categories' => array_map('strval', $this->get_product_categories($product)),
     1667            'is_in_stock' => (bool) $product->is_in_stock(),
     1668            'is_on_sale' => (bool) $product->is_on_sale(),
     1669            'currency' => (string) get_woocommerce_currency(),
     1670        ));
     1671       
    16171672        $event_attributes = array(
    1618             'product_id' => $product_id,
    1619             'product_name' => $product->get_name(),
    1620             'product_price' => $product->get_price(),
    1621             'currency' => get_woocommerce_currency(),
    1622             'wishlist_id' => $wishlist_id,
    1623             'wishlist_name' => $wishlist['wishlist_name'] ?? 'Default',
    1624             'user_id' => $user_id,
    1625             'total_items_in_wishlist' => YITH_WCWL()->count_products($wishlist_id),
    1626             'product_categories' => $this->get_product_categories($product),
    1627             'product_type' => $product->get_type(),
    1628             'product_sku' => $product->get_sku(),
    1629             'is_product_in_stock' => $product->is_in_stock(),
    1630             'is_product_on_sale' => $product->is_on_sale()
    1631         );
    1632 
    1633         $this->send_event('add_to_wishlist', $event_attributes);
     1673            ...$items[0],
     1674            'items' => $items,
     1675            'wishlist_id' => (int) $wishlist_id,
     1676            'wishlist_name' => (string) ($wishlist['wishlist_name'] ?? 'Default'),
     1677            'user_id' => (int) $user_id,
     1678            'total_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
     1679        );
     1680
     1681        $this->send_event('added_to_wishlist', $event_attributes);
    16341682    }
    16351683
     
    16491697        $user_id = get_current_user_id();
    16501698
     1699        // Create items array with single product
     1700        $items = array(array(
     1701            'product_id' => (int) $product_id,
     1702            'product_name' => (string) $product->get_name(),
     1703            'product_price' => (float) $product->get_price(),
     1704            'product_type' => (string) $product->get_type(),
     1705            'product_sku' => (string) $product->get_sku(),
     1706            'categories' => array_map('strval', $this->get_product_categories($product)),
     1707            'is_in_stock' => (bool) $product->is_in_stock(),
     1708            'is_on_sale' => (bool) $product->is_on_sale(),
     1709            'currency' => (string) get_woocommerce_currency(),
     1710        ));
     1711
    16511712        $event_attributes = array(
    1652             'product_id' => $product_id,
    1653             'product_name' => $product->get_name(),
    1654             'product_price' => $product->get_price(),
    1655             'currency' => get_woocommerce_currency(),
    1656             'wishlist_id' => $wishlist_id,
    1657             'wishlist_name' => $wishlist['wishlist_name'] ?? 'Default',
    1658             'wishlist_token' => $wishlist['wishlist_token'] ?? '',
    1659             'user_id' => $user_id,
    1660             'remaining_items_in_wishlist' => YITH_WCWL()->count_products($wishlist_id),
    1661             'product_categories' => $this->get_product_categories($product)
    1662         );
    1663 
    1664         $this->send_event('remove_from_wishlist', $event_attributes);
     1713            ...$items[0],
     1714            'items' => $items,
     1715            'wishlist_id' => (int) $wishlist_id,
     1716            'wishlist_name' => (string) ($wishlist['wishlist_name'] ?? 'Default'),
     1717            'wishlist_token' => (string) ($wishlist['wishlist_token'] ?? ''),
     1718            'user_id' => (int) $user_id,
     1719            'remaining_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
     1720        );
     1721
     1722        $this->send_event('removed_from_wishlist', $event_attributes);
    16651723    }
    16661724
     
    16821740        $to_wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_to_id);
    16831741
     1742        // Create items array with single product
     1743        $items = array(array(
     1744            'product_id' => (int) $product_id,
     1745            'product_name' => (string) $product->get_name(),
     1746            'product_price' => (float) $product->get_price(),
     1747            'product_type' => (string) $product->get_type(),
     1748            'product_sku' => (string) $product->get_sku(),
     1749            'categories' => array_map('strval', $this->get_product_categories($product)),
     1750            'is_in_stock' => (bool) $product->is_in_stock(),
     1751            'is_on_sale' => (bool) $product->is_on_sale(),
     1752            'currency' => (string) get_woocommerce_currency(),
     1753        ));
     1754
    16841755        $event_attributes = array(
    1685             'product_id' => $product_id,
    1686             'product_name' => $product->get_name(),
    1687             'from_wishlist_id' => $wishlist_from_id,
    1688             'from_wishlist_name' => $from_wishlist['wishlist_name'] ?? 'Default',
    1689             'to_wishlist_id' => $wishlist_to_id,
    1690             'to_wishlist_name' => $to_wishlist['wishlist_name'] ?? 'Default',
    1691             'user_id' => $user_id,
    1692             'items_in_source_wishlist' => YITH_WCWL()->count_products($wishlist_from_id),
    1693             'items_in_destination_wishlist' => YITH_WCWL()->count_products($wishlist_to_id)
    1694         );
    1695 
    1696         $this->send_event('move_wishlist_item', $event_attributes);
     1756            ...$items[0],
     1757            'items' => $items,
     1758            'from_wishlist_id' => (int) $wishlist_from_id,
     1759            'from_wishlist_name' => (string) ($from_wishlist['wishlist_name'] ?? 'Default'),
     1760            'to_wishlist_id' => (int) $wishlist_to_id,
     1761            'to_wishlist_name' => (string) ($to_wishlist['wishlist_name'] ?? 'Default'),
     1762            'user_id' => (int) $user_id,
     1763            'items_in_source_wishlist' => (int) YITH_WCWL()->count_products($wishlist_from_id),
     1764            'items_in_destination_wishlist' => (int) YITH_WCWL()->count_products($wishlist_to_id)
     1765        );
     1766
     1767        $this->send_event('moved_wishlist_item', $event_attributes);
    16971768    }
    16981769
  • usermaven/tags/1.1.1/includes/class-usermaven.php

    r3217626 r3221608  
    8181            $this->version = USERMAVEN_VERSION;
    8282        } else {
    83             $this->version = '1.1.0';
     83            $this->version = '1.1.1';
    8484        }
    8585        $this->plugin_name = 'usermaven';
  • usermaven/tags/1.1.1/usermaven.php

    r3217626 r3221608  
    1919 * Description:       The Easiest Website and Product Analytics Platform
    2020
    21  * Version:           1.1.0
     21 * Version:           1.1.1
    2222 * Author:            Usermaven
    2323 * Author URI:        https://usermaven.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'USERMAVEN_VERSION', '1.1.0' );
     40define( 'USERMAVEN_VERSION', '1.1.1' );
    4141
    4242/**
  • usermaven/trunk/README.txt

    r3217626 r3221608  
    66Tested up to: 6.7.1
    77Requires PHP: 5.6
    8 Stable tag: 1.1.0
     8Stable tag: 1.1.1
    99License: Massachusetts Institute of Technology (MIT) license
    1010License URI: https://opensource.org/licenses/MIT
  • usermaven/trunk/includes/class-usermaven-woocommerce.php

    r3217559 r3221608  
    6060        // Reset the tracking flag when the cart is updated or order completes/fails
    6161        add_action('woocommerce_cart_updated', array($this, 'reset_initiate_checkout_tracking'));
    62         add_action('woocommerce_thankyou', array($this, 'reset_initiate_checkout_tracking'));
     62        add_action('woocommerce_thankyou', array($this, 'track_order_thankyou'), 10);
    6363        add_action('woocommerce_order_status_completed', array($this, 'reset_initiate_checkout_tracking'));
    6464        add_action('woocommerce_order_status_failed', array($this, 'reset_initiate_checkout_tracking'));
     
    101101                return;
    102102            }
    103    
     103
    104104            // Get the product ID
    105105            $product_id = get_the_ID();
     
    107107                return;
    108108            }
    109    
     109
    110110            // Get the product
    111111            global $product;
     
    113113                $product = wc_get_product($product_id);
    114114            }
    115    
     115
    116116            // Silently return if no valid product
    117117            if (!$product instanceof WC_Product) {
    118118                return;
    119119            }
    120    
     120
    121121            // Get product categories
    122122            $categories = array();
     
    125125                $categories = wp_list_pluck($terms, 'name');
    126126            }
    127    
    128             // Prepare event attributes
    129             $event_attributes = array(
     127
     128            // Create items array with single product
     129            $items = array(array(
    130130                'product_id' => (int) $product->get_id(),
    131131                'product_name' => (string) $product->get_name(),
     
    135135                'categories' => array_map('strval', $categories),
    136136                'sku' => (string) $product->get_sku(),
    137                 'stock_status' => (string) $product->get_stock_status(),
     137                'stock_status' => (string) $product->get_stock_status()
     138            ));
     139
     140            $event_attributes = array(
     141                ...$items[0],
     142
     143                // Items Array
     144                'items' => $items,
    138145            );
    139    
     146
    140147            // Send the event
    141148            $this->send_event('viewed_product', $event_attributes);
    142    
     149
    143150        } catch (Exception $e) {
    144151            // Log the error but don't halt execution
     
    146153        }
    147154    }
    148    
     155
    149156
    150157    /**
     
    176183        $unit_price = $unit_price === '' ? 0.0 : (float) $unit_price;
    177184        $price_total = (float) ($quantity * $unit_price);
    178        
    179         $event_attributes = array(
     185
     186        // Create items array with single product
     187        $items = array(array(
    180188            // Product Information
    181189            'product_id' => (int) $product_id,
     
    192200            'sale_price' => (float) $product->get_sale_price(),
    193201            'price_total' => $price_total,
     202            'is_on_sale' => (bool) $product->is_on_sale(),
    194203            'currency' => (string) get_woocommerce_currency(),
    195             'is_on_sale' => (bool) $product->is_on_sale(),
    196 
     204           
    197205            // Stock Information
    198206            'stock_status' => (string) $product->get_stock_status(),
     
    201209                null,
    202210            'is_in_stock' => (bool) $product->is_in_stock(),
    203 
     211           
    204212            // Variation Details
    205213            'variation_id' => (int) $variation_id,
    206             'variation_attributes' => $variation_attributes,
    207 
    208             // Cart State
     214            'variation_attributes' => $variation_attributes
     215        ));
     216
     217        $event_attributes = array(
     218            ...$items[0],
    209219            'cart_total' => (float) WC()->cart->get_cart_contents_total(),
    210220            'cart_subtotal' => (float) WC()->cart->get_subtotal(),
     
    213223            'cart_unique_items' => (int) count(WC()->cart->get_cart()),
    214224            'applied_coupons' => array_map('strval', WC()->cart->get_applied_coupons()),
    215 
     225           
     226            // Items Array
     227            'items' => $items,
     228           
    216229            // Additional Context
    217230            'added_from' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     
    259272        $price_per_unit = $price_per_unit === '' ? 0.0 : (float) $price_per_unit;
    260273
    261         $event_attributes = array(
    262             // Product Information
     274        // Create items array with single product
     275        $items = array(array(
    263276            'product_id' => (int) $product_id,
    264277            'product_name' => (string) $product->get_name(),
     
    267280            'categories' => array_map('strval', $categories),
    268281            'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    269 
     282           
    270283            // Removed Item Details
    271284            'quantity_removed' => (int) $cart_item['quantity'],
     
    274287            'price_per_unit' => $price_per_unit,
    275288            'currency' => (string) get_woocommerce_currency(),
    276 
     289           
    277290            // Variation Details
    278291            'variation_id' => !empty($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : 0,
    279             'variation_attributes' => $variation_attributes,
    280 
    281             // Cart State After Removal
     292            'variation_attributes' => $variation_attributes
     293        ));
     294
     295        $event_attributes = array(
     296            ...$items[0],
    282297            'cart_total' => (float) $cart->get_cart_contents_total(),
    283298            'cart_subtotal' => (float) $cart->get_subtotal(),
     
    286301            'remaining_unique_items' => (int) count($cart->get_cart()),
    287302            'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
    288 
     303           
     304            // Items Array
     305            'items' => $items,
     306           
    289307            // Additional Context
    290308            'removed_from_page' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     
    305323            return;
    306324        }
    307    
     325
    308326        $product_id = $cart_item['product_id'];
    309327        $product = wc_get_product($product_id);
     
    311329            return;
    312330        }
    313    
     331
    314332        // Get product categories
    315333        $categories = array();
     
    318336            $categories = wp_list_pluck($terms, 'name');
    319337        }
    320    
     338
    321339        // Process variation attributes
    322340        $variation_attributes = array();
     
    326344            }
    327345        }
    328    
     346
    329347        // Calculate line totals
    330348        $unit_price = $product->get_price();
     
    332350        $old_line_total = (float) ($old_quantity * $unit_price);
    333351        $new_line_total = (float) ($quantity * $unit_price);
    334    
    335         $event_attributes = array(
     352
     353        // Create items array with the updated product
     354        $items = array(array(
    336355            // Product Information
     356            'product_id' => (int) $product_id,
    337357            'product_name' => (string) $product->get_name(),
    338             'product_id' => (int) $product_id,
    339358            'product_type' => (string) $product->get_type(),
    340359            'categories' => array_map('strval', $categories),
    341360            'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    342    
     361           
    343362            // Quantity Change Details
    344363            'old_quantity' => (int) $old_quantity,
     
    349368            'new_line_total' => (float) $new_line_total,
    350369            'currency' => (string) get_woocommerce_currency(),
    351    
     370           
     371            // Stock Information
     372            'stock_status' => (string) $product->get_stock_status(),
     373            'remaining_stock' => $product->get_stock_quantity() !== null ?
     374                (int) $product->get_stock_quantity() :
     375                null,
     376           
     377            // Variation Details
     378            'variation_id' => (int) ($cart_item['variation_id'] ?? 0),
     379            'variation_attributes' => $variation_attributes
     380        ));
     381
     382        $event_attributes = array(
     383            ...$items[0],
     384
     385            // Items Array
     386            'items' => $items,
     387           
    352388            // Cart State
    353389            'cart_total' => (float) $cart->get_total('numeric'),
     
    357393            'cart_unique_items' => (int) count($cart->get_cart()),
    358394            'cart_discount' => (float) $cart->get_discount_total(),
    359    
    360             // Stock Information
    361             'stock_status' => (string) $product->get_stock_status(),
    362             'remaining_stock' => $product->get_stock_quantity() !== null ?
    363                 (int) $product->get_stock_quantity() :
    364                 null,
    365    
     395            'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
     396           
    366397            // Additional Context
    367398            'update_source' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     
    369400            'timestamp' => current_time('mysql'),
    370401            'session_id' => (string) WC()->session->get_customer_id(),
    371             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''),
    372    
    373             // Variation Details
    374             'variation_id' => (int) ($cart_item['variation_id'] ?? 0),
    375             'variation_attributes' => $variation_attributes,
    376    
    377             // Applied Coupons
    378             'applied_coupons' => array_map('strval', $cart->get_applied_coupons())
    379         );
    380    
     402            'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     403        );
     404
    381405        $this->send_event('updated_cart_item', $event_attributes);
    382406    }
     
    574598            return;
    575599        }
    576    
     600
     601        // Get items in consistent format
     602        $items = $this->get_formatted_order_items($order);
     603        $location_details = $this->get_location_details($order);
     604
    577605        $event_attributes = array(
    578             'order_id' => (int) $order_id,
    579             'old_status' => (string) $old_status,
    580             'new_status' => (string) $new_status,
    581             'total' => (float) $order->get_total(),
    582             'currency' => (string) $order->get_currency(),
    583             'payment_method' => (string) $order->get_payment_method(),
    584             'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null,
    585             'billing_email' => (string) $order->get_billing_email(),
    586             'timestamp' => (string) current_time('mysql')
    587         );
    588    
     606           
     607                'order_id' => (int) $order_id,
     608                'old_status' => (string) $old_status,
     609                'new_status' => (string) $new_status,
     610                'total' => (float) $order->get_total(),
     611                'currency' => (string) $order->get_currency(),
     612                'payment_method' => (string) $order->get_payment_method(),
     613           
     614                // Items Information
     615                'items' => $items,
     616                'items_count' => (int) $order->get_item_count(),
     617               
     618                'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null,
     619                'billing_email' => (string) $order->get_billing_email(),
     620                'customer_note' => (string) $order->get_customer_note(),               
     621                // Additional Context
     622                'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     623                'timestamp' => (string) current_time('mysql')
     624        );
     625
    589626        $this->send_event('order_status_changed', $event_attributes);
    590627    }
     
    796833            // Customer Information
    797834            'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null,
     835            'customer_note' => (string) $order->get_customer_note(),
    798836            'customer_type' => (string) ($order->get_customer_id() ? 'registered' : 'guest'),
    799837            'is_registered_customer' => (bool) $order->get_customer_id(),
     
    12331271            return;
    12341272        }
    1235    
     1273
     1274        // Get items in consistent format
     1275        $items = $this->get_formatted_order_items($order);
     1276
    12361277        $event_attributes = array(
    12371278            'order_id' => (int) $order_id,
     
    12411282            'status' => (string) $order->get_status(),
    12421283            'items_count' => (int) $order->get_item_count(),
     1284            'items' => $items,  // Added items array
    12431285            'billing_email' => (string) $order->get_billing_email(),
    12441286            'timestamp' => (string) current_time('mysql')
    12451287        );
    1246    
    1247         $this->send_event('order_thankyou_page_view', $event_attributes);
     1288
     1289        $this->send_event('order_thankyou_page_viewed', $event_attributes);   
    12481290    }
    12491291
     
    16151657        $wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_id);
    16161658       
     1659        // Create items array with single product
     1660        $items = array(array(
     1661            'product_id' => (int) $product_id,
     1662            'product_name' => (string) $product->get_name(),
     1663            'product_price' => (float) $product->get_price(),
     1664            'product_type' => (string) $product->get_type(),
     1665            'product_sku' => (string) $product->get_sku(),
     1666            'categories' => array_map('strval', $this->get_product_categories($product)),
     1667            'is_in_stock' => (bool) $product->is_in_stock(),
     1668            'is_on_sale' => (bool) $product->is_on_sale(),
     1669            'currency' => (string) get_woocommerce_currency(),
     1670        ));
     1671       
    16171672        $event_attributes = array(
    1618             'product_id' => $product_id,
    1619             'product_name' => $product->get_name(),
    1620             'product_price' => $product->get_price(),
    1621             'currency' => get_woocommerce_currency(),
    1622             'wishlist_id' => $wishlist_id,
    1623             'wishlist_name' => $wishlist['wishlist_name'] ?? 'Default',
    1624             'user_id' => $user_id,
    1625             'total_items_in_wishlist' => YITH_WCWL()->count_products($wishlist_id),
    1626             'product_categories' => $this->get_product_categories($product),
    1627             'product_type' => $product->get_type(),
    1628             'product_sku' => $product->get_sku(),
    1629             'is_product_in_stock' => $product->is_in_stock(),
    1630             'is_product_on_sale' => $product->is_on_sale()
    1631         );
    1632 
    1633         $this->send_event('add_to_wishlist', $event_attributes);
     1673            ...$items[0],
     1674            'items' => $items,
     1675            'wishlist_id' => (int) $wishlist_id,
     1676            'wishlist_name' => (string) ($wishlist['wishlist_name'] ?? 'Default'),
     1677            'user_id' => (int) $user_id,
     1678            'total_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
     1679        );
     1680
     1681        $this->send_event('added_to_wishlist', $event_attributes);
    16341682    }
    16351683
     
    16491697        $user_id = get_current_user_id();
    16501698
     1699        // Create items array with single product
     1700        $items = array(array(
     1701            'product_id' => (int) $product_id,
     1702            'product_name' => (string) $product->get_name(),
     1703            'product_price' => (float) $product->get_price(),
     1704            'product_type' => (string) $product->get_type(),
     1705            'product_sku' => (string) $product->get_sku(),
     1706            'categories' => array_map('strval', $this->get_product_categories($product)),
     1707            'is_in_stock' => (bool) $product->is_in_stock(),
     1708            'is_on_sale' => (bool) $product->is_on_sale(),
     1709            'currency' => (string) get_woocommerce_currency(),
     1710        ));
     1711
    16511712        $event_attributes = array(
    1652             'product_id' => $product_id,
    1653             'product_name' => $product->get_name(),
    1654             'product_price' => $product->get_price(),
    1655             'currency' => get_woocommerce_currency(),
    1656             'wishlist_id' => $wishlist_id,
    1657             'wishlist_name' => $wishlist['wishlist_name'] ?? 'Default',
    1658             'wishlist_token' => $wishlist['wishlist_token'] ?? '',
    1659             'user_id' => $user_id,
    1660             'remaining_items_in_wishlist' => YITH_WCWL()->count_products($wishlist_id),
    1661             'product_categories' => $this->get_product_categories($product)
    1662         );
    1663 
    1664         $this->send_event('remove_from_wishlist', $event_attributes);
     1713            ...$items[0],
     1714            'items' => $items,
     1715            'wishlist_id' => (int) $wishlist_id,
     1716            'wishlist_name' => (string) ($wishlist['wishlist_name'] ?? 'Default'),
     1717            'wishlist_token' => (string) ($wishlist['wishlist_token'] ?? ''),
     1718            'user_id' => (int) $user_id,
     1719            'remaining_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
     1720        );
     1721
     1722        $this->send_event('removed_from_wishlist', $event_attributes);
    16651723    }
    16661724
     
    16821740        $to_wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_to_id);
    16831741
     1742        // Create items array with single product
     1743        $items = array(array(
     1744            'product_id' => (int) $product_id,
     1745            'product_name' => (string) $product->get_name(),
     1746            'product_price' => (float) $product->get_price(),
     1747            'product_type' => (string) $product->get_type(),
     1748            'product_sku' => (string) $product->get_sku(),
     1749            'categories' => array_map('strval', $this->get_product_categories($product)),
     1750            'is_in_stock' => (bool) $product->is_in_stock(),
     1751            'is_on_sale' => (bool) $product->is_on_sale(),
     1752            'currency' => (string) get_woocommerce_currency(),
     1753        ));
     1754
    16841755        $event_attributes = array(
    1685             'product_id' => $product_id,
    1686             'product_name' => $product->get_name(),
    1687             'from_wishlist_id' => $wishlist_from_id,
    1688             'from_wishlist_name' => $from_wishlist['wishlist_name'] ?? 'Default',
    1689             'to_wishlist_id' => $wishlist_to_id,
    1690             'to_wishlist_name' => $to_wishlist['wishlist_name'] ?? 'Default',
    1691             'user_id' => $user_id,
    1692             'items_in_source_wishlist' => YITH_WCWL()->count_products($wishlist_from_id),
    1693             'items_in_destination_wishlist' => YITH_WCWL()->count_products($wishlist_to_id)
    1694         );
    1695 
    1696         $this->send_event('move_wishlist_item', $event_attributes);
     1756            ...$items[0],
     1757            'items' => $items,
     1758            'from_wishlist_id' => (int) $wishlist_from_id,
     1759            'from_wishlist_name' => (string) ($from_wishlist['wishlist_name'] ?? 'Default'),
     1760            'to_wishlist_id' => (int) $wishlist_to_id,
     1761            'to_wishlist_name' => (string) ($to_wishlist['wishlist_name'] ?? 'Default'),
     1762            'user_id' => (int) $user_id,
     1763            'items_in_source_wishlist' => (int) YITH_WCWL()->count_products($wishlist_from_id),
     1764            'items_in_destination_wishlist' => (int) YITH_WCWL()->count_products($wishlist_to_id)
     1765        );
     1766
     1767        $this->send_event('moved_wishlist_item', $event_attributes);
    16971768    }
    16981769
  • usermaven/trunk/includes/class-usermaven.php

    r3217626 r3221608  
    8181            $this->version = USERMAVEN_VERSION;
    8282        } else {
    83             $this->version = '1.1.0';
     83            $this->version = '1.1.1';
    8484        }
    8585        $this->plugin_name = 'usermaven';
  • usermaven/trunk/usermaven.php

    r3217626 r3221608  
    1919 * Description:       The Easiest Website and Product Analytics Platform
    2020
    21  * Version:           1.1.0
     21 * Version:           1.1.1
    2222 * Author:            Usermaven
    2323 * Author URI:        https://usermaven.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'USERMAVEN_VERSION', '1.1.0' );
     40define( 'USERMAVEN_VERSION', '1.1.1' );
    4141
    4242/**
Note: See TracChangeset for help on using the changeset viewer.