/** * Adds product information to a Segment_Cookie when item is removed from cart. * * @param string $key Key name for item in cart. A hash. * * @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(). */ public function remove_from_cart($key) { if (!is_object(WC()->cart)) { return; } $items = WC()->cart->get_cart(); $cart_item = $items[$key]; Segment_Cookie::set_cookie('removed_from_cart', json_encode(array('ID' => $cart_item->product_id, 'quantity' => 0, 'name' => $cart_item['data']->post->post_title, 'price' => $cart_item['data']->get_price(), 'key' => $key))); }
/** * Uses Segment_Cookie::set_cookie() to notify Segment that a user has signed up. * * @since 1.0.0 * * @param int $user_id Username of new user. * */ public function user_register($user_id) { Segment_Cookie::set_cookie('signed_up', json_encode($user_id)); }
/** * Adds product information to a Segment_Cookie when item is removed from cart. * * @param string $key Key name for item in cart. A hash. * * @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(). */ public function remove_from_cart($cart_item) { if (0 == $cart_item->quantity) { Segment_Cookie::set_cookie('removed_from_cart', json_encode(array('ID' => $cart_item->product_id, 'quantity' => 0, 'name' => $cart_item->product_title, 'price' => $cart_item->unit_price))); } }