public function store(AddItemToCartRequest $request, Product $product, StockValidator $stockValidator)
 {
     $attributes = $request->input('attributes', []);
     // If product has variant but the selected attributes don't match one
     // use the first variant by default.
     $variant = $product->variants()->hasAttributeOptions($attributes)->first();
     if ($product->hasVariants() and !$variant) {
         $variant = $product->variants()->first();
     }
     $stockValidator->validate($product, $variant, $request->input('quantity'));
     $this->cartManager->addItemToCart($this->user(), $product, $variant, $request->all());
     Session::flash('added_to_cart', 1);
     return $this->success('add');
 }