From bb182972f8f0d3ed392deb32cecd5881f341541c Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Thu, 4 Jul 2019 18:20:49 +0530 Subject: [PATCH] Fixed issue #83 --- .../Controllers/BulkAddToCartController.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/Webkul/BulkAddToCart/src/Http/Controllers/BulkAddToCartController.php b/packages/Webkul/BulkAddToCart/src/Http/Controllers/BulkAddToCartController.php index cd40753d5..80fbe4a6b 100644 --- a/packages/Webkul/BulkAddToCart/src/Http/Controllers/BulkAddToCartController.php +++ b/packages/Webkul/BulkAddToCart/src/Http/Controllers/BulkAddToCartController.php @@ -100,23 +100,27 @@ class BulkAddToCartController extends Controller if ($super_attribute->type == 'select') { foreach ($product->attribute_values as $attribute_value) { if ($super_attribute->id == $attribute_value->attribute_id) { - $attributes[$super_attribute->id] = (string)$attribute_value->integer_value; + $attributes[$super_attribute->id] = (string) $attribute_value->integer_value; } } } } - $cart['product'] = (string)$parentProduct->id; - $cart['quantity'] = (string)$uploadData['quantity']; + $cart['product'] = (string) $parentProduct->id; + $cart['quantity'] = (string) $uploadData['quantity']; $cart['is_configurable'] = 'true'; - $cart['selected_configurable_option'] = (string)$product->id; + $cart['selected_configurable_option'] = (string) $product->id; $cart['super_attribute'] = $attributes; } else { - $cart['product'] = (string)$product->id; - $cart['quantity'] = (string)$uploadData['quantity']; + $cart['product'] = (string) $product->id; + $cart['quantity'] = (string) $uploadData['quantity']; $cart['is_configurable'] = 'false'; } + request()->merge([ + 'quantity' => $cart['quantity'] + ]); + Event::fire('checkout.cart.add.before', $cart['product']); $result = Cart::add($cart['product'], $cart); @@ -171,9 +175,7 @@ class BulkAddToCartController extends Controller return redirect()->route($this->_config['redirect']); } } catch (\Exception $e) { - $failure = new Failure(1, 'rows', [0 => trans('bulkaddtocart::app.products.enough-row-error')]); - - session()->flash('error', $failure->errors()[0]); + session()->flash('error', $e->getMessage()); return redirect()->back(); }