Пример #1
0
 /**
  * Adds product properties to analytics.track() when product is removed from cart.
  *
  * @since  1.0.0
  * @access public
  *
  * @uses  func_get_args() Because our abstract class doesn't know how many parameters are passed to each hook
  *                        for each different platform, we use func_get_args().
  *
  * @return array Filtered array of name and properties for analytics.track().
  */
 public function removed_from_cart()
 {
     $args = func_get_args();
     $track = $args[0];
     if (false !== ($cookie = Segment_Cookie::get_cookie('removed_from_cart'))) {
         if (!is_object(WC()->cart)) {
             return $track;
         }
         $_product = json_decode($cookie);
         if (is_object($_product)) {
             $product = get_product($_product->ID);
             if ($product) {
                 $item = array('id' => $product->ID, 'sku' => $product->get_sku(), 'name' => $product->get_title(), 'price' => $product->get_price(), 'quantity' => 0, 'category' => implode(', ', wp_list_pluck(wc_get_product_terms($product->ID, 'product_cat'), 'name')));
                 $track = array('event' => __('Removed Product', 'segment'), 'properties' => $item, 'http_event' => 'removed_from_cart');
             }
         }
     }
     return $track;
 }
 /**
  * Filters the .identify() call with the newly signed up user.
  * This is helpful, as the user will often times not be authenticated after signing up.
  *
  * @since  1.0.0
  *
  * @param  mixed $identify   False if no user is found, array of traits and ID if a user is found.
  * @return array $identify   Array of traits for newly signed up user.
  */
 public function new_user_identify($identify)
 {
     if (Segment_Cookie::get_cookie('signed_up')) {
         $user_id = json_decode(Segment_Cookie::get_cookie('signed_up'));
         $user = get_user_by('id', $user_id);
         $identify = array('user_id' => $user->user_email, 'traits' => array('username' => $user->user_login, 'email' => $user->user_email, 'firstName' => $user->user_firstname, 'lastName' => $user->user_lastname, 'url' => $user->user_url));
     }
     return $identify;
 }
Пример #3
0
 /**
  * Adds product properties to analytics.track() when product is removed from cart.
  *
  * @since  1.0.0
  * @access public
  *
  * @uses  func_get_args() Because our abstract class doesn't know how many parameters are passed to each hook
  *                        for each different platform, we use func_get_args().
  *
  * @return array Filtered array of name and properties for analytics.track().
  */
 public function removed_from_cart()
 {
     $args = func_get_args();
     $track = $args[0];
     if (false !== ($product = Segment_Cookie::get_cookie('removed_from_cart'))) {
         $product = json_decode($product);
         $item = array('id' => $product->ID, 'sku' => wpsc_product_sku($product->ID), 'name' => $product->name, 'price' => $product->price, 'quantity' => 0, 'category' => implode(', ', wp_list_pluck(wpsc_get_product_terms($product->ID, 'wpsc_product_category'), 'name')));
         $track = array('event' => __('Removed Product', 'segment'), 'properties' => $item, 'http_event' => 'removed_from_cart');
     }
     return $track;
 }