Changeset 3221608
- Timestamp:
- 01/13/2025 01:26:37 PM (15 months ago)
- Location:
- usermaven
- Files:
-
- 6 added
- 8 edited
- 1 copied
-
tags/1.1.1 (copied) (copied from usermaven/trunk)
-
tags/1.1.1/README.txt (modified) (1 diff)
-
tags/1.1.1/assets/screenshot-3.png (added)
-
tags/1.1.1/assets/screenshot-4.png (added)
-
tags/1.1.1/assets/screenshot-5.png (added)
-
tags/1.1.1/includes/class-usermaven-woocommerce.php (modified) (30 diffs)
-
tags/1.1.1/includes/class-usermaven.php (modified) (1 diff)
-
tags/1.1.1/usermaven.php (modified) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/assets/screenshot-3.png (added)
-
trunk/assets/screenshot-4.png (added)
-
trunk/assets/screenshot-5.png (added)
-
trunk/includes/class-usermaven-woocommerce.php (modified) (30 diffs)
-
trunk/includes/class-usermaven.php (modified) (1 diff)
-
trunk/usermaven.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
usermaven/tags/1.1.1/README.txt
r3217626 r3221608 6 6 Tested up to: 6.7.1 7 7 Requires PHP: 5.6 8 Stable tag: 1.1. 08 Stable tag: 1.1.1 9 9 License: Massachusetts Institute of Technology (MIT) license 10 10 License URI: https://opensource.org/licenses/MIT -
usermaven/tags/1.1.1/includes/class-usermaven-woocommerce.php
r3217559 r3221608 60 60 // Reset the tracking flag when the cart is updated or order completes/fails 61 61 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); 63 63 add_action('woocommerce_order_status_completed', array($this, 'reset_initiate_checkout_tracking')); 64 64 add_action('woocommerce_order_status_failed', array($this, 'reset_initiate_checkout_tracking')); … … 101 101 return; 102 102 } 103 103 104 104 // Get the product ID 105 105 $product_id = get_the_ID(); … … 107 107 return; 108 108 } 109 109 110 110 // Get the product 111 111 global $product; … … 113 113 $product = wc_get_product($product_id); 114 114 } 115 115 116 116 // Silently return if no valid product 117 117 if (!$product instanceof WC_Product) { 118 118 return; 119 119 } 120 120 121 121 // Get product categories 122 122 $categories = array(); … … 125 125 $categories = wp_list_pluck($terms, 'name'); 126 126 } 127 128 // Prepare event attributes129 $ event_attributes =array(127 128 // Create items array with single product 129 $items = array(array( 130 130 'product_id' => (int) $product->get_id(), 131 131 'product_name' => (string) $product->get_name(), … … 135 135 'categories' => array_map('strval', $categories), 136 136 '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, 138 145 ); 139 146 140 147 // Send the event 141 148 $this->send_event('viewed_product', $event_attributes); 142 149 143 150 } catch (Exception $e) { 144 151 // Log the error but don't halt execution … … 146 153 } 147 154 } 148 155 149 156 150 157 /** … … 176 183 $unit_price = $unit_price === '' ? 0.0 : (float) $unit_price; 177 184 $price_total = (float) ($quantity * $unit_price); 178 179 $event_attributes = array( 185 186 // Create items array with single product 187 $items = array(array( 180 188 // Product Information 181 189 'product_id' => (int) $product_id, … … 192 200 'sale_price' => (float) $product->get_sale_price(), 193 201 'price_total' => $price_total, 202 'is_on_sale' => (bool) $product->is_on_sale(), 194 203 'currency' => (string) get_woocommerce_currency(), 195 'is_on_sale' => (bool) $product->is_on_sale(), 196 204 197 205 // Stock Information 198 206 'stock_status' => (string) $product->get_stock_status(), … … 201 209 null, 202 210 'is_in_stock' => (bool) $product->is_in_stock(), 203 211 204 212 // Variation Details 205 213 '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], 209 219 'cart_total' => (float) WC()->cart->get_cart_contents_total(), 210 220 'cart_subtotal' => (float) WC()->cart->get_subtotal(), … … 213 223 'cart_unique_items' => (int) count(WC()->cart->get_cart()), 214 224 'applied_coupons' => array_map('strval', WC()->cart->get_applied_coupons()), 215 225 226 // Items Array 227 'items' => $items, 228 216 229 // Additional Context 217 230 'added_from' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), … … 259 272 $price_per_unit = $price_per_unit === '' ? 0.0 : (float) $price_per_unit; 260 273 261 $event_attributes = array(262 // Product Information274 // Create items array with single product 275 $items = array(array( 263 276 'product_id' => (int) $product_id, 264 277 'product_name' => (string) $product->get_name(), … … 267 280 'categories' => array_map('strval', $categories), 268 281 'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))), 269 282 270 283 // Removed Item Details 271 284 'quantity_removed' => (int) $cart_item['quantity'], … … 274 287 'price_per_unit' => $price_per_unit, 275 288 'currency' => (string) get_woocommerce_currency(), 276 289 277 290 // Variation Details 278 291 '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], 282 297 'cart_total' => (float) $cart->get_cart_contents_total(), 283 298 'cart_subtotal' => (float) $cart->get_subtotal(), … … 286 301 'remaining_unique_items' => (int) count($cart->get_cart()), 287 302 'applied_coupons' => array_map('strval', $cart->get_applied_coupons()), 288 303 304 // Items Array 305 'items' => $items, 306 289 307 // Additional Context 290 308 'removed_from_page' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), … … 305 323 return; 306 324 } 307 325 308 326 $product_id = $cart_item['product_id']; 309 327 $product = wc_get_product($product_id); … … 311 329 return; 312 330 } 313 331 314 332 // Get product categories 315 333 $categories = array(); … … 318 336 $categories = wp_list_pluck($terms, 'name'); 319 337 } 320 338 321 339 // Process variation attributes 322 340 $variation_attributes = array(); … … 326 344 } 327 345 } 328 346 329 347 // Calculate line totals 330 348 $unit_price = $product->get_price(); … … 332 350 $old_line_total = (float) ($old_quantity * $unit_price); 333 351 $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( 336 355 // Product Information 356 'product_id' => (int) $product_id, 337 357 'product_name' => (string) $product->get_name(), 338 'product_id' => (int) $product_id,339 358 'product_type' => (string) $product->get_type(), 340 359 'categories' => array_map('strval', $categories), 341 360 'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))), 342 361 343 362 // Quantity Change Details 344 363 'old_quantity' => (int) $old_quantity, … … 349 368 'new_line_total' => (float) $new_line_total, 350 369 '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 352 388 // Cart State 353 389 'cart_total' => (float) $cart->get_total('numeric'), … … 357 393 'cart_unique_items' => (int) count($cart->get_cart()), 358 394 '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 366 397 // Additional Context 367 398 'update_source' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), … … 369 400 'timestamp' => current_time('mysql'), 370 401 '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 381 405 $this->send_event('updated_cart_item', $event_attributes); 382 406 } … … 574 598 return; 575 599 } 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 577 605 $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 589 626 $this->send_event('order_status_changed', $event_attributes); 590 627 } … … 796 833 // Customer Information 797 834 'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null, 835 'customer_note' => (string) $order->get_customer_note(), 798 836 'customer_type' => (string) ($order->get_customer_id() ? 'registered' : 'guest'), 799 837 'is_registered_customer' => (bool) $order->get_customer_id(), … … 1233 1271 return; 1234 1272 } 1235 1273 1274 // Get items in consistent format 1275 $items = $this->get_formatted_order_items($order); 1276 1236 1277 $event_attributes = array( 1237 1278 'order_id' => (int) $order_id, … … 1241 1282 'status' => (string) $order->get_status(), 1242 1283 'items_count' => (int) $order->get_item_count(), 1284 'items' => $items, // Added items array 1243 1285 'billing_email' => (string) $order->get_billing_email(), 1244 1286 'timestamp' => (string) current_time('mysql') 1245 1287 ); 1246 1247 $this->send_event('order_thankyou_page_view ', $event_attributes);1288 1289 $this->send_event('order_thankyou_page_viewed', $event_attributes); 1248 1290 } 1249 1291 … … 1615 1657 $wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_id); 1616 1658 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 1617 1672 $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); 1634 1682 } 1635 1683 … … 1649 1697 $user_id = get_current_user_id(); 1650 1698 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 1651 1712 $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); 1665 1723 } 1666 1724 … … 1682 1740 $to_wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_to_id); 1683 1741 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 1684 1755 $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); 1697 1768 } 1698 1769 -
usermaven/tags/1.1.1/includes/class-usermaven.php
r3217626 r3221608 81 81 $this->version = USERMAVEN_VERSION; 82 82 } else { 83 $this->version = '1.1. 0';83 $this->version = '1.1.1'; 84 84 } 85 85 $this->plugin_name = 'usermaven'; -
usermaven/tags/1.1.1/usermaven.php
r3217626 r3221608 19 19 * Description: The Easiest Website and Product Analytics Platform 20 20 21 * Version: 1.1. 021 * Version: 1.1.1 22 22 * Author: Usermaven 23 23 * Author URI: https://usermaven.com/ … … 38 38 * Rename this for your plugin and update it as you release new versions. 39 39 */ 40 define( 'USERMAVEN_VERSION', '1.1. 0' );40 define( 'USERMAVEN_VERSION', '1.1.1' ); 41 41 42 42 /** -
usermaven/trunk/README.txt
r3217626 r3221608 6 6 Tested up to: 6.7.1 7 7 Requires PHP: 5.6 8 Stable tag: 1.1. 08 Stable tag: 1.1.1 9 9 License: Massachusetts Institute of Technology (MIT) license 10 10 License URI: https://opensource.org/licenses/MIT -
usermaven/trunk/includes/class-usermaven-woocommerce.php
r3217559 r3221608 60 60 // Reset the tracking flag when the cart is updated or order completes/fails 61 61 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); 63 63 add_action('woocommerce_order_status_completed', array($this, 'reset_initiate_checkout_tracking')); 64 64 add_action('woocommerce_order_status_failed', array($this, 'reset_initiate_checkout_tracking')); … … 101 101 return; 102 102 } 103 103 104 104 // Get the product ID 105 105 $product_id = get_the_ID(); … … 107 107 return; 108 108 } 109 109 110 110 // Get the product 111 111 global $product; … … 113 113 $product = wc_get_product($product_id); 114 114 } 115 115 116 116 // Silently return if no valid product 117 117 if (!$product instanceof WC_Product) { 118 118 return; 119 119 } 120 120 121 121 // Get product categories 122 122 $categories = array(); … … 125 125 $categories = wp_list_pluck($terms, 'name'); 126 126 } 127 128 // Prepare event attributes129 $ event_attributes =array(127 128 // Create items array with single product 129 $items = array(array( 130 130 'product_id' => (int) $product->get_id(), 131 131 'product_name' => (string) $product->get_name(), … … 135 135 'categories' => array_map('strval', $categories), 136 136 '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, 138 145 ); 139 146 140 147 // Send the event 141 148 $this->send_event('viewed_product', $event_attributes); 142 149 143 150 } catch (Exception $e) { 144 151 // Log the error but don't halt execution … … 146 153 } 147 154 } 148 155 149 156 150 157 /** … … 176 183 $unit_price = $unit_price === '' ? 0.0 : (float) $unit_price; 177 184 $price_total = (float) ($quantity * $unit_price); 178 179 $event_attributes = array( 185 186 // Create items array with single product 187 $items = array(array( 180 188 // Product Information 181 189 'product_id' => (int) $product_id, … … 192 200 'sale_price' => (float) $product->get_sale_price(), 193 201 'price_total' => $price_total, 202 'is_on_sale' => (bool) $product->is_on_sale(), 194 203 'currency' => (string) get_woocommerce_currency(), 195 'is_on_sale' => (bool) $product->is_on_sale(), 196 204 197 205 // Stock Information 198 206 'stock_status' => (string) $product->get_stock_status(), … … 201 209 null, 202 210 'is_in_stock' => (bool) $product->is_in_stock(), 203 211 204 212 // Variation Details 205 213 '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], 209 219 'cart_total' => (float) WC()->cart->get_cart_contents_total(), 210 220 'cart_subtotal' => (float) WC()->cart->get_subtotal(), … … 213 223 'cart_unique_items' => (int) count(WC()->cart->get_cart()), 214 224 'applied_coupons' => array_map('strval', WC()->cart->get_applied_coupons()), 215 225 226 // Items Array 227 'items' => $items, 228 216 229 // Additional Context 217 230 'added_from' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), … … 259 272 $price_per_unit = $price_per_unit === '' ? 0.0 : (float) $price_per_unit; 260 273 261 $event_attributes = array(262 // Product Information274 // Create items array with single product 275 $items = array(array( 263 276 'product_id' => (int) $product_id, 264 277 'product_name' => (string) $product->get_name(), … … 267 280 'categories' => array_map('strval', $categories), 268 281 'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))), 269 282 270 283 // Removed Item Details 271 284 'quantity_removed' => (int) $cart_item['quantity'], … … 274 287 'price_per_unit' => $price_per_unit, 275 288 'currency' => (string) get_woocommerce_currency(), 276 289 277 290 // Variation Details 278 291 '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], 282 297 'cart_total' => (float) $cart->get_cart_contents_total(), 283 298 'cart_subtotal' => (float) $cart->get_subtotal(), … … 286 301 'remaining_unique_items' => (int) count($cart->get_cart()), 287 302 'applied_coupons' => array_map('strval', $cart->get_applied_coupons()), 288 303 304 // Items Array 305 'items' => $items, 306 289 307 // Additional Context 290 308 'removed_from_page' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), … … 305 323 return; 306 324 } 307 325 308 326 $product_id = $cart_item['product_id']; 309 327 $product = wc_get_product($product_id); … … 311 329 return; 312 330 } 313 331 314 332 // Get product categories 315 333 $categories = array(); … … 318 336 $categories = wp_list_pluck($terms, 'name'); 319 337 } 320 338 321 339 // Process variation attributes 322 340 $variation_attributes = array(); … … 326 344 } 327 345 } 328 346 329 347 // Calculate line totals 330 348 $unit_price = $product->get_price(); … … 332 350 $old_line_total = (float) ($old_quantity * $unit_price); 333 351 $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( 336 355 // Product Information 356 'product_id' => (int) $product_id, 337 357 'product_name' => (string) $product->get_name(), 338 'product_id' => (int) $product_id,339 358 'product_type' => (string) $product->get_type(), 340 359 'categories' => array_map('strval', $categories), 341 360 'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))), 342 361 343 362 // Quantity Change Details 344 363 'old_quantity' => (int) $old_quantity, … … 349 368 'new_line_total' => (float) $new_line_total, 350 369 '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 352 388 // Cart State 353 389 'cart_total' => (float) $cart->get_total('numeric'), … … 357 393 'cart_unique_items' => (int) count($cart->get_cart()), 358 394 '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 366 397 // Additional Context 367 398 'update_source' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), … … 369 400 'timestamp' => current_time('mysql'), 370 401 '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 381 405 $this->send_event('updated_cart_item', $event_attributes); 382 406 } … … 574 598 return; 575 599 } 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 577 605 $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 589 626 $this->send_event('order_status_changed', $event_attributes); 590 627 } … … 796 833 // Customer Information 797 834 'customer_id' => $order->get_customer_id() ? (int) $order->get_customer_id() : null, 835 'customer_note' => (string) $order->get_customer_note(), 798 836 'customer_type' => (string) ($order->get_customer_id() ? 'registered' : 'guest'), 799 837 'is_registered_customer' => (bool) $order->get_customer_id(), … … 1233 1271 return; 1234 1272 } 1235 1273 1274 // Get items in consistent format 1275 $items = $this->get_formatted_order_items($order); 1276 1236 1277 $event_attributes = array( 1237 1278 'order_id' => (int) $order_id, … … 1241 1282 'status' => (string) $order->get_status(), 1242 1283 'items_count' => (int) $order->get_item_count(), 1284 'items' => $items, // Added items array 1243 1285 'billing_email' => (string) $order->get_billing_email(), 1244 1286 'timestamp' => (string) current_time('mysql') 1245 1287 ); 1246 1247 $this->send_event('order_thankyou_page_view ', $event_attributes);1288 1289 $this->send_event('order_thankyou_page_viewed', $event_attributes); 1248 1290 } 1249 1291 … … 1615 1657 $wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_id); 1616 1658 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 1617 1672 $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); 1634 1682 } 1635 1683 … … 1649 1697 $user_id = get_current_user_id(); 1650 1698 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 1651 1712 $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); 1665 1723 } 1666 1724 … … 1682 1740 $to_wishlist = YITH_WCWL()->get_wishlist_detail($wishlist_to_id); 1683 1741 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 1684 1755 $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); 1697 1768 } 1698 1769 -
usermaven/trunk/includes/class-usermaven.php
r3217626 r3221608 81 81 $this->version = USERMAVEN_VERSION; 82 82 } else { 83 $this->version = '1.1. 0';83 $this->version = '1.1.1'; 84 84 } 85 85 $this->plugin_name = 'usermaven'; -
usermaven/trunk/usermaven.php
r3217626 r3221608 19 19 * Description: The Easiest Website and Product Analytics Platform 20 20 21 * Version: 1.1. 021 * Version: 1.1.1 22 22 * Author: Usermaven 23 23 * Author URI: https://usermaven.com/ … … 38 38 * Rename this for your plugin and update it as you release new versions. 39 39 */ 40 define( 'USERMAVEN_VERSION', '1.1. 0' );40 define( 'USERMAVEN_VERSION', '1.1.1' ); 41 41 42 42 /**
Note: See TracChangeset
for help on using the changeset viewer.