Plugin Directory

Changeset 3258914


Ignore:
Timestamp:
03/20/2025 07:01:05 AM (13 months ago)
Author:
usermaven
Message:

tagging version 1.1.8

Location:
usermaven
Files:
8 edited
1 copied

Legend:

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

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

    r3241679 r3258914  
    235235            // Create items array with single product
    236236            $items = array(array(
    237                 'product_id' => (int) $product->get_id(),
     237                'product_id'   => (int) $product->get_id(),
    238238                'product_name' => (string) $product->get_name(),
    239                 'price' => (float) $product->get_price(),
    240                 'currency' => (string) get_woocommerce_currency(),
    241                 'type' => (string) $product->get_type(),
    242                 'categories' => array_map('strval', $categories),
    243                 'sku' => (string) $product->get_sku(),
     239                'price'        => (float) $product->get_price(),
     240                'currency'     => (string) get_woocommerce_currency(),
     241                'type'         => (string) $product->get_type(),
     242                'categories'   => array_map('strval', $categories),
     243                'sku'          => (string) $product->get_sku(),
    244244                'stock_status' => (string) $product->get_stock_status()
    245245            ));
    246246
    247             $event_attributes = array(
    248                 ...$items[0],
    249 
     247            $event_attributes = array_merge($items[0], array(
    250248                // Items Array
    251249                'items' => $items,
    252             );
     250            ));
    253251
    254252            // Send the event
     
    294292        $items = array(array(
    295293            // Product Information
    296             'product_id' => (int) $product_id,
    297             'product_name' => (string) $product->get_name(),
    298             'product_sku' => (string) $product->get_sku(),
    299             'product_type' => (string) $product->get_type(),
    300             'categories' => array_map('strval', $categories),
    301             'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    302 
     294            'product_id'         => (int) $product_id,
     295            'product_name'       => (string) $product->get_name(),
     296            'product_sku'        => (string) $product->get_sku(),
     297            'product_type'       => (string) $product->get_type(),
     298            'categories'         => array_map('strval', $categories),
     299            'tags'               => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    303300            // Quantity and Price Details
    304             'quantity' => (int) $quantity,
    305             'unit_price' => $unit_price,
    306             'regular_price' => (float) $product->get_regular_price(),
    307             'sale_price' => (float) $product->get_sale_price(),
    308             'price_total' => $price_total,
    309             'is_on_sale' => (bool) $product->is_on_sale(),
    310             'currency' => (string) get_woocommerce_currency(),
    311            
     301            'quantity'           => (int) $quantity,
     302            'unit_price'         => $unit_price,
     303            'regular_price'      => (float) $product->get_regular_price(),
     304            'sale_price'         => (float) $product->get_sale_price(),
     305            'price_total'        => $price_total,
     306            'is_on_sale'         => (bool) $product->is_on_sale(),
     307            'currency'           => (string) get_woocommerce_currency(),
    312308            // Stock Information
    313             'stock_status' => (string) $product->get_stock_status(),
    314             'stock_quantity' => $product->get_stock_quantity() !== null ?
    315                 (int) $product->get_stock_quantity() :
    316                 null,
    317             'is_in_stock' => (bool) $product->is_in_stock(),
    318            
     309            'stock_status'       => (string) $product->get_stock_status(),
     310            'stock_quantity'     => $product->get_stock_quantity() !== null ? (int) $product->get_stock_quantity() : null,
     311            'is_in_stock'        => (bool) $product->is_in_stock(),
    319312            // Variation Details
    320             'variation_id' => (int) $variation_id,
    321             'variation_attributes' => $variation_attributes
     313            'variation_id'       => (int) $variation_id,
     314            'variation_attributes'=> $variation_attributes
    322315        ));
    323316
    324         $event_attributes = array(
    325             ...$items[0],
    326             'cart_total' => (float) WC()->cart->get_cart_contents_total(),
    327             'cart_subtotal' => (float) WC()->cart->get_subtotal(),
    328             'cart_tax' => (float) WC()->cart->get_cart_tax(),
    329             'cart_items_count' => (int) WC()->cart->get_cart_contents_count(),
     317        $event_attributes = array_merge($items[0], array(
     318            'cart_total'        => (float) WC()->cart->get_cart_contents_total(),
     319            'cart_subtotal'     => (float) WC()->cart->get_subtotal(),
     320            'cart_tax'          => (float) WC()->cart->get_cart_tax(),
     321            'cart_items_count'  => (int) WC()->cart->get_cart_contents_count(),
    330322            'cart_unique_items' => (int) count(WC()->cart->get_cart()),
    331             'applied_coupons' => array_map('strval', WC()->cart->get_applied_coupons()),
    332            
     323            'applied_coupons'   => array_map('strval', WC()->cart->get_applied_coupons()),
    333324            // Items Array
    334             'items' => $items,
    335            
     325            'items'             => $items,
    336326            // Additional Context
    337             'added_from' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
    338             'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
    339             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
    340         );
     327            'added_from'        => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     328            'device_type'       => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     329            'user_agent'        => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     330        ));
    341331
    342332        $this->send_event('added_to_cart', $event_attributes);
     
    375365        // Get line totals and ensure they're properly typed
    376366        $line_total = !empty($cart_item['line_total']) ? (float) $cart_item['line_total'] : 0.0;
    377         $line_tax = !empty($cart_item['line_tax']) ? (float) $cart_item['line_tax'] : 0.0;
     367        $line_tax   = !empty($cart_item['line_tax']) ? (float) $cart_item['line_tax'] : 0.0;
    378368        $price_per_unit = $product->get_price();
    379369        $price_per_unit = $price_per_unit === '' ? 0.0 : (float) $price_per_unit;
     
    381371        // Create items array with single product
    382372        $items = array(array(
    383             'product_id' => (int) $product_id,
    384             'product_name' => (string) $product->get_name(),
    385             'product_sku' => (string) $product->get_sku(),
    386             'product_type' => (string) $product->get_type(),
    387             'categories' => array_map('strval', $categories),
    388             'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    389            
     373            'product_id'         => (int) $product_id,
     374            'product_name'       => (string) $product->get_name(),
     375            'product_sku'        => (string) $product->get_sku(),
     376            'product_type'       => (string) $product->get_type(),
     377            'categories'         => array_map('strval', $categories),
     378            'tags'               => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    390379            // Removed Item Details
    391             'quantity_removed' => (int) $cart_item['quantity'],
    392             'line_total' => $line_total,
    393             'line_tax' => $line_tax,
    394             'price_per_unit' => $price_per_unit,
    395             'currency' => (string) get_woocommerce_currency(),
    396            
     380            'quantity_removed'   => (int) $cart_item['quantity'],
     381            'line_total'         => $line_total,
     382            'line_tax'           => $line_tax,
     383            'price_per_unit'     => $price_per_unit,
     384            'currency'           => (string) get_woocommerce_currency(),
    397385            // Variation Details
    398             'variation_id' => !empty($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : 0,
    399             'variation_attributes' => $variation_attributes
     386            'variation_id'       => !empty($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : 0,
     387            'variation_attributes'=> $variation_attributes
    400388        ));
    401389
    402         $event_attributes = array(
    403             ...$items[0],
    404             'cart_total' => (float) $cart->get_cart_contents_total(),
    405             'cart_subtotal' => (float) $cart->get_subtotal(),
    406             'cart_tax' => (float) $cart->get_cart_tax(),
    407             'remaining_items' => (int) $cart->get_cart_contents_count(),
     390        $event_attributes = array_merge($items[0], array(
     391            'cart_total'             => (float) $cart->get_cart_contents_total(),
     392            'cart_subtotal'          => (float) $cart->get_subtotal(),
     393            'cart_tax'               => (float) $cart->get_cart_tax(),
     394            'remaining_items'        => (int) $cart->get_cart_contents_count(),
    408395            'remaining_unique_items' => (int) count($cart->get_cart()),
    409             'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
    410            
     396            'applied_coupons'        => array_map('strval', $cart->get_applied_coupons()),
    411397            // Items Array
    412             'items' => $items,
    413            
     398            'items'                  => $items,
    414399            // Additional Context
    415             'removed_from_page' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
    416             'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
    417             'session_id' => (string) WC()->session->get_customer_id(),
    418             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
    419         );
     400            'removed_from_page'      => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     401            'device_type'            => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     402            'session_id'             => (string) WC()->session->get_customer_id(),
     403            'user_agent'             => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     404        ));
    420405
    421406        $this->send_event('removed_from_cart', $event_attributes);
     
    461446        $items = array(array(
    462447            // Product Information
    463             'product_id' => (int) $product_id,
    464             'product_name' => (string) $product->get_name(),
    465             'product_type' => (string) $product->get_type(),
    466             'categories' => array_map('strval', $categories),
    467             'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    468            
     448            'product_id'         => (int) $product_id,
     449            'product_name'       => (string) $product->get_name(),
     450            'product_type'       => (string) $product->get_type(),
     451            'categories'         => array_map('strval', $categories),
     452            'tags'               => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    469453            // Quantity Change Details
    470             'old_quantity' => (int) $old_quantity,
    471             'new_quantity' => (int) $quantity,
    472             'quantity_change' => (int) ($quantity - $old_quantity),
    473             'price' => (float) $unit_price,
    474             'old_line_total' => (float) $old_line_total,
    475             'new_line_total' => (float) $new_line_total,
    476             'currency' => (string) get_woocommerce_currency(),
    477            
     454            'old_quantity'       => (int) $old_quantity,
     455            'new_quantity'       => (int) $quantity,
     456            'quantity_change'    => (int) ($quantity - $old_quantity),
     457            'price'              => (float) $unit_price,
     458            'old_line_total'     => (float) $old_line_total,
     459            'new_line_total'     => (float) $new_line_total,
     460            'currency'           => (string) get_woocommerce_currency(),
    478461            // Stock Information
    479             'stock_status' => (string) $product->get_stock_status(),
    480             'remaining_stock' => $product->get_stock_quantity() !== null ?
    481                 (int) $product->get_stock_quantity() :
    482                 null,
    483            
     462            'stock_status'       => (string) $product->get_stock_status(),
     463            'remaining_stock'    => $product->get_stock_quantity() !== null ? (int) $product->get_stock_quantity() : null,
    484464            // Variation Details
    485             'variation_id' => (int) ($cart_item['variation_id'] ?? 0),
    486             'variation_attributes' => $variation_attributes
     465            'variation_id'       => (int) ($cart_item['variation_id'] ?? 0),
     466            'variation_attributes'=> $variation_attributes
    487467        ));
    488468
    489         $event_attributes = array(
    490             ...$items[0],
    491 
     469        $event_attributes = array_merge($items[0], array(
    492470            // Items Array
    493471            'items' => $items,
    494            
    495472            // Cart State
    496             'cart_total' => (float) $cart->get_total('numeric'),
    497             'cart_subtotal' => (float) $cart->get_subtotal(),
    498             'cart_tax' => (float) $cart->get_cart_tax(),
    499             'cart_items_count' => (int) $cart->get_cart_contents_count(),
     473            'cart_total'        => (float) $cart->get_total('numeric'),
     474            'cart_subtotal'     => (float) $cart->get_subtotal(),
     475            'cart_tax'          => (float) $cart->get_cart_tax(),
     476            'cart_items_count'  => (int) $cart->get_cart_contents_count(),
    500477            'cart_unique_items' => (int) count($cart->get_cart()),
    501             'cart_discount' => (float) $cart->get_discount_total(),
    502             'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
    503            
     478            'cart_discount'     => (float) $cart->get_discount_total(),
     479            'applied_coupons'   => array_map('strval', $cart->get_applied_coupons()),
    504480            // Additional Context
    505             'update_source' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
    506             'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
    507             'timestamp' => current_time('mysql'),
    508             'session_id' => (string) WC()->session->get_customer_id(),
    509             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
    510         );
     481            'update_source'     => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     482            'device_type'       => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     483            'timestamp'         => current_time('mysql'),
     484            'session_id'        => (string) WC()->session->get_customer_id(),
     485            'user_agent'        => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     486        ));
    511487
    512488        $this->send_event('updated_cart_item', $event_attributes);
     
    612588
    613589            $items[] = array(
    614                 'product_id' => (int) $parent_product->get_id(),
    615                 'product_name' => (string) $parent_product->get_name(),
    616                 'product_sku' => (string) $product->get_sku(),
    617                 'quantity' => (int) $cart_item['quantity'],
    618                 'unit_price' => $unit_price,
    619                 'line_total' => (float) $cart_item['line_total'],
    620                 'line_tax' => (float) $cart_item['line_tax'],
    621                 'categories' => array_map('strval', $categories),
    622                 'variation_id' => isset($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : null,
    623                 'variation_attributes' => $variation_attributes,
    624                 'is_on_sale' => (bool) $product->is_on_sale(),
    625                 'stock_status' => (string) $product->get_stock_status()
     590                'product_id'         => (int) $parent_product->get_id(),
     591                'product_name'       => (string) $parent_product->get_name(),
     592                'product_sku'        => (string) $product->get_sku(),
     593                'quantity'           => (int) $cart_item['quantity'],
     594                'unit_price'         => $unit_price,
     595                'line_total'         => (float) $cart_item['line_total'],
     596                'line_tax'           => (float) $cart_item['line_tax'],
     597                'categories'         => array_map('strval', $categories),
     598                'variation_id'       => isset($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : null,
     599                'variation_attributes'=> $variation_attributes,
     600                'is_on_sale'         => (bool) $product->is_on_sale(),
     601                'stock_status'       => (string) $product->get_stock_status()
    626602            );
    627603        }
     
    675651        );
    676652
    677         // Send the event
    678653        $this->send_event('initiated_checkout', $event_attributes);
    679654
     
    920895
    921896            $item_data = array(
    922                 'product_id' => (int) $parent_product->get_id(),
    923                 'product_name' => (string) $parent_product->get_name(),
    924                 'quantity' => (int) ($is_refund ? abs($item->get_quantity()) : $item->get_quantity()),
    925                 'price' => (float) $product->get_price(),
    926                 'subtotal' => (float) ($is_refund ? abs($item->get_subtotal()) : $item->get_subtotal()),
    927                 'total' => (float) ($is_refund ? abs($item->get_total()) : $item->get_total()),
    928                 'sku' => (string) $product->get_sku(),
    929                 'categories' => array_map('strval', $categories),
    930                 'variation_id' => $variation_id ? (int) $variation_id : null,
    931                 'variation_attributes' => $variation_attributes,
    932                 'tax' => (float) ($is_refund ? abs($item->get_total_tax()) : $item->get_total_tax())
     897                'product_id'         => (int) $parent_product->get_id(),
     898                'product_name'       => (string) $parent_product->get_name(),
     899                'quantity'           => (int) ($is_refund ? abs($item->get_quantity()) : $item->get_quantity()),
     900                'price'              => (float) $product->get_price(),
     901                'subtotal'           => (float) ($is_refund ? abs($item->get_subtotal()) : $item->get_subtotal()),
     902                'total'              => (float) ($is_refund ? abs($item->get_total()) : $item->get_total()),
     903                'sku'                => (string) $product->get_sku(),
     904                'categories'         => array_map('strval', $categories),
     905                'variation_id'       => $variation_id ? (int) $variation_id : null,
     906                'variation_attributes'=> $variation_attributes,
     907                'tax'                => (float) ($is_refund ? abs($item->get_total_tax()) : $item->get_total_tax())
    933908            );
    934909
     
    18661841        ));
    18671842       
    1868         $event_attributes = array(
    1869             ...$items[0],
     1843        $event_attributes = array_merge($items[0], array(
    18701844            'items' => $items,
    18711845            'wishlist_id' => (int) $wishlist_id,
     
    18731847            'user_id' => (int) $user_id,
    18741848            'total_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
    1875         );
     1849        ));
    18761850
    18771851        $this->send_event('added_to_wishlist', $event_attributes);
     
    19061880        ));
    19071881
    1908         $event_attributes = array(
    1909             ...$items[0],
     1882        $event_attributes = array_merge($items[0], array(
    19101883            'items' => $items,
    19111884            'wishlist_id' => (int) $wishlist_id,
     
    19141887            'user_id' => (int) $user_id,
    19151888            'remaining_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
    1916         );
     1889        ));
    19171890
    19181891        $this->send_event('removed_from_wishlist', $event_attributes);
     
    19491922        ));
    19501923
    1951         $event_attributes = array(
    1952             ...$items[0],
     1924        $event_attributes = array_merge($items[0], array(
    19531925            'items' => $items,
    19541926            'from_wishlist_id' => (int) $wishlist_from_id,
     
    19591931            'items_in_source_wishlist' => (int) YITH_WCWL()->count_products($wishlist_from_id),
    19601932            'items_in_destination_wishlist' => (int) YITH_WCWL()->count_products($wishlist_to_id)
    1961         );
     1933        ));
    19621934
    19631935        $this->send_event('moved_wishlist_item', $event_attributes);
  • usermaven/tags/1.1.8/includes/class-usermaven.php

    r3258904 r3258914  
    8181            $this->version = USERMAVEN_VERSION;
    8282        } else {
    83             $this->version = '1.1.7';
     83            $this->version = '1.1.8';
    8484        }
    8585        $this->plugin_name = 'usermaven';
  • usermaven/tags/1.1.8/usermaven.php

    r3241679 r3258914  
    1919 * Description:       The Easiest Website and Product Analytics Platform
    2020
    21  * Version:           1.1.6
     21 * Version:           1.1.8
    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.6' );
     40define( 'USERMAVEN_VERSION', '1.1.8' );
    4141
    4242/**
  • usermaven/trunk/README.txt

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

    r3241679 r3258914  
    235235            // Create items array with single product
    236236            $items = array(array(
    237                 'product_id' => (int) $product->get_id(),
     237                'product_id'   => (int) $product->get_id(),
    238238                'product_name' => (string) $product->get_name(),
    239                 'price' => (float) $product->get_price(),
    240                 'currency' => (string) get_woocommerce_currency(),
    241                 'type' => (string) $product->get_type(),
    242                 'categories' => array_map('strval', $categories),
    243                 'sku' => (string) $product->get_sku(),
     239                'price'        => (float) $product->get_price(),
     240                'currency'     => (string) get_woocommerce_currency(),
     241                'type'         => (string) $product->get_type(),
     242                'categories'   => array_map('strval', $categories),
     243                'sku'          => (string) $product->get_sku(),
    244244                'stock_status' => (string) $product->get_stock_status()
    245245            ));
    246246
    247             $event_attributes = array(
    248                 ...$items[0],
    249 
     247            $event_attributes = array_merge($items[0], array(
    250248                // Items Array
    251249                'items' => $items,
    252             );
     250            ));
    253251
    254252            // Send the event
     
    294292        $items = array(array(
    295293            // Product Information
    296             'product_id' => (int) $product_id,
    297             'product_name' => (string) $product->get_name(),
    298             'product_sku' => (string) $product->get_sku(),
    299             'product_type' => (string) $product->get_type(),
    300             'categories' => array_map('strval', $categories),
    301             'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    302 
     294            'product_id'         => (int) $product_id,
     295            'product_name'       => (string) $product->get_name(),
     296            'product_sku'        => (string) $product->get_sku(),
     297            'product_type'       => (string) $product->get_type(),
     298            'categories'         => array_map('strval', $categories),
     299            'tags'               => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    303300            // Quantity and Price Details
    304             'quantity' => (int) $quantity,
    305             'unit_price' => $unit_price,
    306             'regular_price' => (float) $product->get_regular_price(),
    307             'sale_price' => (float) $product->get_sale_price(),
    308             'price_total' => $price_total,
    309             'is_on_sale' => (bool) $product->is_on_sale(),
    310             'currency' => (string) get_woocommerce_currency(),
    311            
     301            'quantity'           => (int) $quantity,
     302            'unit_price'         => $unit_price,
     303            'regular_price'      => (float) $product->get_regular_price(),
     304            'sale_price'         => (float) $product->get_sale_price(),
     305            'price_total'        => $price_total,
     306            'is_on_sale'         => (bool) $product->is_on_sale(),
     307            'currency'           => (string) get_woocommerce_currency(),
    312308            // Stock Information
    313             'stock_status' => (string) $product->get_stock_status(),
    314             'stock_quantity' => $product->get_stock_quantity() !== null ?
    315                 (int) $product->get_stock_quantity() :
    316                 null,
    317             'is_in_stock' => (bool) $product->is_in_stock(),
    318            
     309            'stock_status'       => (string) $product->get_stock_status(),
     310            'stock_quantity'     => $product->get_stock_quantity() !== null ? (int) $product->get_stock_quantity() : null,
     311            'is_in_stock'        => (bool) $product->is_in_stock(),
    319312            // Variation Details
    320             'variation_id' => (int) $variation_id,
    321             'variation_attributes' => $variation_attributes
     313            'variation_id'       => (int) $variation_id,
     314            'variation_attributes'=> $variation_attributes
    322315        ));
    323316
    324         $event_attributes = array(
    325             ...$items[0],
    326             'cart_total' => (float) WC()->cart->get_cart_contents_total(),
    327             'cart_subtotal' => (float) WC()->cart->get_subtotal(),
    328             'cart_tax' => (float) WC()->cart->get_cart_tax(),
    329             'cart_items_count' => (int) WC()->cart->get_cart_contents_count(),
     317        $event_attributes = array_merge($items[0], array(
     318            'cart_total'        => (float) WC()->cart->get_cart_contents_total(),
     319            'cart_subtotal'     => (float) WC()->cart->get_subtotal(),
     320            'cart_tax'          => (float) WC()->cart->get_cart_tax(),
     321            'cart_items_count'  => (int) WC()->cart->get_cart_contents_count(),
    330322            'cart_unique_items' => (int) count(WC()->cart->get_cart()),
    331             'applied_coupons' => array_map('strval', WC()->cart->get_applied_coupons()),
    332            
     323            'applied_coupons'   => array_map('strval', WC()->cart->get_applied_coupons()),
    333324            // Items Array
    334             'items' => $items,
    335            
     325            'items'             => $items,
    336326            // Additional Context
    337             'added_from' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
    338             'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
    339             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
    340         );
     327            'added_from'        => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     328            'device_type'       => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     329            'user_agent'        => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     330        ));
    341331
    342332        $this->send_event('added_to_cart', $event_attributes);
     
    375365        // Get line totals and ensure they're properly typed
    376366        $line_total = !empty($cart_item['line_total']) ? (float) $cart_item['line_total'] : 0.0;
    377         $line_tax = !empty($cart_item['line_tax']) ? (float) $cart_item['line_tax'] : 0.0;
     367        $line_tax   = !empty($cart_item['line_tax']) ? (float) $cart_item['line_tax'] : 0.0;
    378368        $price_per_unit = $product->get_price();
    379369        $price_per_unit = $price_per_unit === '' ? 0.0 : (float) $price_per_unit;
     
    381371        // Create items array with single product
    382372        $items = array(array(
    383             'product_id' => (int) $product_id,
    384             'product_name' => (string) $product->get_name(),
    385             'product_sku' => (string) $product->get_sku(),
    386             'product_type' => (string) $product->get_type(),
    387             'categories' => array_map('strval', $categories),
    388             'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    389            
     373            'product_id'         => (int) $product_id,
     374            'product_name'       => (string) $product->get_name(),
     375            'product_sku'        => (string) $product->get_sku(),
     376            'product_type'       => (string) $product->get_type(),
     377            'categories'         => array_map('strval', $categories),
     378            'tags'               => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    390379            // Removed Item Details
    391             'quantity_removed' => (int) $cart_item['quantity'],
    392             'line_total' => $line_total,
    393             'line_tax' => $line_tax,
    394             'price_per_unit' => $price_per_unit,
    395             'currency' => (string) get_woocommerce_currency(),
    396            
     380            'quantity_removed'   => (int) $cart_item['quantity'],
     381            'line_total'         => $line_total,
     382            'line_tax'           => $line_tax,
     383            'price_per_unit'     => $price_per_unit,
     384            'currency'           => (string) get_woocommerce_currency(),
    397385            // Variation Details
    398             'variation_id' => !empty($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : 0,
    399             'variation_attributes' => $variation_attributes
     386            'variation_id'       => !empty($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : 0,
     387            'variation_attributes'=> $variation_attributes
    400388        ));
    401389
    402         $event_attributes = array(
    403             ...$items[0],
    404             'cart_total' => (float) $cart->get_cart_contents_total(),
    405             'cart_subtotal' => (float) $cart->get_subtotal(),
    406             'cart_tax' => (float) $cart->get_cart_tax(),
    407             'remaining_items' => (int) $cart->get_cart_contents_count(),
     390        $event_attributes = array_merge($items[0], array(
     391            'cart_total'             => (float) $cart->get_cart_contents_total(),
     392            'cart_subtotal'          => (float) $cart->get_subtotal(),
     393            'cart_tax'               => (float) $cart->get_cart_tax(),
     394            'remaining_items'        => (int) $cart->get_cart_contents_count(),
    408395            'remaining_unique_items' => (int) count($cart->get_cart()),
    409             'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
    410            
     396            'applied_coupons'        => array_map('strval', $cart->get_applied_coupons()),
    411397            // Items Array
    412             'items' => $items,
    413            
     398            'items'                  => $items,
    414399            // Additional Context
    415             'removed_from_page' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
    416             'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
    417             'session_id' => (string) WC()->session->get_customer_id(),
    418             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
    419         );
     400            'removed_from_page'      => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     401            'device_type'            => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     402            'session_id'             => (string) WC()->session->get_customer_id(),
     403            'user_agent'             => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     404        ));
    420405
    421406        $this->send_event('removed_from_cart', $event_attributes);
     
    461446        $items = array(array(
    462447            // Product Information
    463             'product_id' => (int) $product_id,
    464             'product_name' => (string) $product->get_name(),
    465             'product_type' => (string) $product->get_type(),
    466             'categories' => array_map('strval', $categories),
    467             'tags' => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    468            
     448            'product_id'         => (int) $product_id,
     449            'product_name'       => (string) $product->get_name(),
     450            'product_type'       => (string) $product->get_type(),
     451            'categories'         => array_map('strval', $categories),
     452            'tags'               => array_map('strval', wp_get_post_terms($product_id, 'product_tag', array('fields' => 'names'))),
    469453            // Quantity Change Details
    470             'old_quantity' => (int) $old_quantity,
    471             'new_quantity' => (int) $quantity,
    472             'quantity_change' => (int) ($quantity - $old_quantity),
    473             'price' => (float) $unit_price,
    474             'old_line_total' => (float) $old_line_total,
    475             'new_line_total' => (float) $new_line_total,
    476             'currency' => (string) get_woocommerce_currency(),
    477            
     454            'old_quantity'       => (int) $old_quantity,
     455            'new_quantity'       => (int) $quantity,
     456            'quantity_change'    => (int) ($quantity - $old_quantity),
     457            'price'              => (float) $unit_price,
     458            'old_line_total'     => (float) $old_line_total,
     459            'new_line_total'     => (float) $new_line_total,
     460            'currency'           => (string) get_woocommerce_currency(),
    478461            // Stock Information
    479             'stock_status' => (string) $product->get_stock_status(),
    480             'remaining_stock' => $product->get_stock_quantity() !== null ?
    481                 (int) $product->get_stock_quantity() :
    482                 null,
    483            
     462            'stock_status'       => (string) $product->get_stock_status(),
     463            'remaining_stock'    => $product->get_stock_quantity() !== null ? (int) $product->get_stock_quantity() : null,
    484464            // Variation Details
    485             'variation_id' => (int) ($cart_item['variation_id'] ?? 0),
    486             'variation_attributes' => $variation_attributes
     465            'variation_id'       => (int) ($cart_item['variation_id'] ?? 0),
     466            'variation_attributes'=> $variation_attributes
    487467        ));
    488468
    489         $event_attributes = array(
    490             ...$items[0],
    491 
     469        $event_attributes = array_merge($items[0], array(
    492470            // Items Array
    493471            'items' => $items,
    494            
    495472            // Cart State
    496             'cart_total' => (float) $cart->get_total('numeric'),
    497             'cart_subtotal' => (float) $cart->get_subtotal(),
    498             'cart_tax' => (float) $cart->get_cart_tax(),
    499             'cart_items_count' => (int) $cart->get_cart_contents_count(),
     473            'cart_total'        => (float) $cart->get_total('numeric'),
     474            'cart_subtotal'     => (float) $cart->get_subtotal(),
     475            'cart_tax'          => (float) $cart->get_cart_tax(),
     476            'cart_items_count'  => (int) $cart->get_cart_contents_count(),
    500477            'cart_unique_items' => (int) count($cart->get_cart()),
    501             'cart_discount' => (float) $cart->get_discount_total(),
    502             'applied_coupons' => array_map('strval', $cart->get_applied_coupons()),
    503            
     478            'cart_discount'     => (float) $cart->get_discount_total(),
     479            'applied_coupons'   => array_map('strval', $cart->get_applied_coupons()),
    504480            // Additional Context
    505             'update_source' => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
    506             'device_type' => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
    507             'timestamp' => current_time('mysql'),
    508             'session_id' => (string) WC()->session->get_customer_id(),
    509             'user_agent' => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
    510         );
     481            'update_source'     => (string) (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
     482            'device_type'       => (string) (wp_is_mobile() ? 'mobile' : 'desktop'),
     483            'timestamp'         => current_time('mysql'),
     484            'session_id'        => (string) WC()->session->get_customer_id(),
     485            'user_agent'        => (string) (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')
     486        ));
    511487
    512488        $this->send_event('updated_cart_item', $event_attributes);
     
    612588
    613589            $items[] = array(
    614                 'product_id' => (int) $parent_product->get_id(),
    615                 'product_name' => (string) $parent_product->get_name(),
    616                 'product_sku' => (string) $product->get_sku(),
    617                 'quantity' => (int) $cart_item['quantity'],
    618                 'unit_price' => $unit_price,
    619                 'line_total' => (float) $cart_item['line_total'],
    620                 'line_tax' => (float) $cart_item['line_tax'],
    621                 'categories' => array_map('strval', $categories),
    622                 'variation_id' => isset($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : null,
    623                 'variation_attributes' => $variation_attributes,
    624                 'is_on_sale' => (bool) $product->is_on_sale(),
    625                 'stock_status' => (string) $product->get_stock_status()
     590                'product_id'         => (int) $parent_product->get_id(),
     591                'product_name'       => (string) $parent_product->get_name(),
     592                'product_sku'        => (string) $product->get_sku(),
     593                'quantity'           => (int) $cart_item['quantity'],
     594                'unit_price'         => $unit_price,
     595                'line_total'         => (float) $cart_item['line_total'],
     596                'line_tax'           => (float) $cart_item['line_tax'],
     597                'categories'         => array_map('strval', $categories),
     598                'variation_id'       => isset($cart_item['variation_id']) ? (int) $cart_item['variation_id'] : null,
     599                'variation_attributes'=> $variation_attributes,
     600                'is_on_sale'         => (bool) $product->is_on_sale(),
     601                'stock_status'       => (string) $product->get_stock_status()
    626602            );
    627603        }
     
    675651        );
    676652
    677         // Send the event
    678653        $this->send_event('initiated_checkout', $event_attributes);
    679654
     
    920895
    921896            $item_data = array(
    922                 'product_id' => (int) $parent_product->get_id(),
    923                 'product_name' => (string) $parent_product->get_name(),
    924                 'quantity' => (int) ($is_refund ? abs($item->get_quantity()) : $item->get_quantity()),
    925                 'price' => (float) $product->get_price(),
    926                 'subtotal' => (float) ($is_refund ? abs($item->get_subtotal()) : $item->get_subtotal()),
    927                 'total' => (float) ($is_refund ? abs($item->get_total()) : $item->get_total()),
    928                 'sku' => (string) $product->get_sku(),
    929                 'categories' => array_map('strval', $categories),
    930                 'variation_id' => $variation_id ? (int) $variation_id : null,
    931                 'variation_attributes' => $variation_attributes,
    932                 'tax' => (float) ($is_refund ? abs($item->get_total_tax()) : $item->get_total_tax())
     897                'product_id'         => (int) $parent_product->get_id(),
     898                'product_name'       => (string) $parent_product->get_name(),
     899                'quantity'           => (int) ($is_refund ? abs($item->get_quantity()) : $item->get_quantity()),
     900                'price'              => (float) $product->get_price(),
     901                'subtotal'           => (float) ($is_refund ? abs($item->get_subtotal()) : $item->get_subtotal()),
     902                'total'              => (float) ($is_refund ? abs($item->get_total()) : $item->get_total()),
     903                'sku'                => (string) $product->get_sku(),
     904                'categories'         => array_map('strval', $categories),
     905                'variation_id'       => $variation_id ? (int) $variation_id : null,
     906                'variation_attributes'=> $variation_attributes,
     907                'tax'                => (float) ($is_refund ? abs($item->get_total_tax()) : $item->get_total_tax())
    933908            );
    934909
     
    18661841        ));
    18671842       
    1868         $event_attributes = array(
    1869             ...$items[0],
     1843        $event_attributes = array_merge($items[0], array(
    18701844            'items' => $items,
    18711845            'wishlist_id' => (int) $wishlist_id,
     
    18731847            'user_id' => (int) $user_id,
    18741848            'total_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
    1875         );
     1849        ));
    18761850
    18771851        $this->send_event('added_to_wishlist', $event_attributes);
     
    19061880        ));
    19071881
    1908         $event_attributes = array(
    1909             ...$items[0],
     1882        $event_attributes = array_merge($items[0], array(
    19101883            'items' => $items,
    19111884            'wishlist_id' => (int) $wishlist_id,
     
    19141887            'user_id' => (int) $user_id,
    19151888            'remaining_items_in_wishlist' => (int) YITH_WCWL()->count_products($wishlist_id)
    1916         );
     1889        ));
    19171890
    19181891        $this->send_event('removed_from_wishlist', $event_attributes);
     
    19491922        ));
    19501923
    1951         $event_attributes = array(
    1952             ...$items[0],
     1924        $event_attributes = array_merge($items[0], array(
    19531925            'items' => $items,
    19541926            'from_wishlist_id' => (int) $wishlist_from_id,
     
    19591931            'items_in_source_wishlist' => (int) YITH_WCWL()->count_products($wishlist_from_id),
    19601932            'items_in_destination_wishlist' => (int) YITH_WCWL()->count_products($wishlist_to_id)
    1961         );
     1933        ));
    19621934
    19631935        $this->send_event('moved_wishlist_item', $event_attributes);
  • usermaven/trunk/includes/class-usermaven.php

    r3258904 r3258914  
    8181            $this->version = USERMAVEN_VERSION;
    8282        } else {
    83             $this->version = '1.1.7';
     83            $this->version = '1.1.8';
    8484        }
    8585        $this->plugin_name = 'usermaven';
  • usermaven/trunk/usermaven.php

    r3241679 r3258914  
    1919 * Description:       The Easiest Website and Product Analytics Platform
    2020
    21  * Version:           1.1.6
     21 * Version:           1.1.8
    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.6' );
     40define( 'USERMAVEN_VERSION', '1.1.8' );
    4141
    4242/**
Note: See TracChangeset for help on using the changeset viewer.