public function add($productId, $count, $attributesAndValues = null, $additionalProducts = [], $combinationId = null)
    {
        if (!empty($attributesAndValues)) {
            $attributesAndValues = Json::decode($attributesAndValues);
        }

        if ($this->saveSelectedCombination) {
            $combination = Combination::findOne($combinationId) ?? $this->getCombination($attributesAndValues, $productId);
            $this->saveSelectedCombinationToSession($combination);
        }

        if ($this->saveToDataBase && !\Yii::$app->user->isGuest) {
            $this->saveProductToDataBase($productId, $count, $attributesAndValues, $additionalProducts, $combinationId);
        } else {
            $this->saveProductToSession($productId, $count, $attributesAndValues, $additionalProducts, $combinationId);
        }
        $this->trigger(self::EVENT_AFTER_ADD_PRODUCT);
    }
public function add($productId, $count, $attributesAndValues = null, $additionalProducts = [], $combinationId = null)
    {
        if (!empty($attributesAndValues)) {
            $attributesAndValues = Json::decode($attributesAndValues);
        }

        if ($this->saveSelectedCombination) {
            $combination = Combination::findOne($combinationId) ?? $this->getCombination($attributesAndValues, $productId);
            $this->saveSelectedCombinationToSession($combination);
        }

        if ($this->saveToDataBase && !\Yii::$app->user->isGuest) {
            $this->saveProductToDataBase($productId, $count, $attributesAndValues, $additionalProducts, $combinationId);
        } else {
            $this->saveProductToSession($productId, $count, $attributesAndValues, $additionalProducts, $combinationId);
        }
        $this->trigger(self::EVENT_AFTER_ADD_PRODUCT);
    }
public function add ( $ productId , $ count , $ attributesAndValues = null , $ additionalProducts = [ ] , $ combinationId = null ) { if ( ! empty ( $ attributesAndValues ) ) { $ attributesAndValues = Json :: decode ( $ attributesAndValues ) ; } if ( $ this -> saveSelectedCombination ) { $ combination = Combination :: findOne ( $ combinationId ) ?? $ this -> getCombination ( $ attributesAndValues , $ productId ) ; $ this -> saveSelectedCombinationToSession ( $ combination ) ; } if ( $ this -> saveToDataBase && ! \ Yii :: $ app -> user -> isGuest ) { $ this -> saveProductToDataBase ( $ productId , $ count , $ attributesAndValues , $ additionalProducts , $ combinationId ) ; } else { $ this -> saveProductToSession ( $ productId , $ count , $ attributesAndValues , $ additionalProducts , $ combinationId ) ; } $ this -> trigger ( self :: EVENT_AFTER_ADD_PRODUCT ) ; }
Adds product to cart.

@param $productId
@param $count
@param null $attributesAndValues
@param array $additionalProducts
@param null $combinationId
Adds product to cart .