static function put($product, $qty = 1) { if (!$product instanceof Product) { $product = Product::find(static::idFrom($product)); } if (!$product) { $product = func_get_arg(0); Log::warn_Cart("Unknown product [{$product}] to place in cart."); } elseif (!$product->available) { Log::warn_Cart("Attempting to place unavailable product [{$product->title}]."); } else { $oldQty = static::qty($product) ?: null; $qty = max(0, round(S::toFloat($qty), 2)); $key = 'cart_goods.' . $product->id; if ($qty == 0) { if ($oldQty) { Session::forget($key); Event::fire('cart.removed', array($product, &$oldQty)); } } else { $qty = max($product->min, $qty); $product->fractable or $qty = ceil($qty); if ($qty != $oldQty) { Session::put($key, $qty); Event::fire('cart.added', array($product, &$oldQty)); } } return $product; } }