Craft\InstantAnalyticsService::addToCart PHP Method

addToCart() public method

Send analytics information for the item added to the cart
public addToCart ( Commerce_OrderModel $orderModel = null, Commerce_LineItemModel $lineItem = null )
$orderModel Commerce_OrderModel the Product or Variant
$lineItem Commerce_LineItemModel the line item that was added
    public function addToCart($orderModel = null, $lineItem = null)
    {
        if ($lineItem) {
            $title = $lineItem->purchasable->title;
            $quantity = $lineItem->qty;
            $analytics = $this->eventAnalytics("Commerce", "Add to Cart", $title, $quantity);
            if ($analytics) {
                $title = $this->addProductDataFromLineItem($analytics, $lineItem);
                $analytics->setEventLabel($title);
                // Don't forget to set the product action, in this case to ADD
                $analytics->setProductActionToAdd();
                $analytics->sendEvent();
                InstantAnalyticsPlugin::log("addToCart for `Commerce` - `Add to Cart` - `" . $title . "` - `" . $quantity . "`", LogLevel::Info, false);
            }
        }
    }