Commit 44fe43c4 authored by Artem's avatar Artem

imporove add to cart method

parent 30b2976e
......@@ -25,6 +25,8 @@ class CartController extends Controller
public function addToCart(Product $product)
{
$product->addItemToCart();
$cart = Session::get('cart');
return $cart->total_qty;
}
public function updateQtyInCart(Request $request)
......
......@@ -7,7 +7,7 @@ function setAddToCardEventListener() {
axios.post(actionUrl)
.then(function (response) {
const cartAmountElem = document.querySelector('.amount-in-cart');
cartAmountElem.textContent++;
cartAmountElem.textContent = response.data;
})
.catch(function (error) {
console.log(error);
......
......@@ -61,7 +61,7 @@
>Update quantity</button>
</td>
<td class="hidden-xs text-center"><strong>Total € {{ $cart->total_price }}</strong></td>
<td><button class="btn btn-success btn-block">Send order</button></td>
<td><button class="btn btn-success btn-block">Checkout</button></td>
</tr>
</tfoot>
</table>
......@@ -75,5 +75,5 @@
@endsection
@section('script')
<script src="js/cart.js"></script>
<script src="js/cart.js" defer></script>
@endsection
......@@ -32,5 +32,5 @@
@endsection
@section('script')
<script src="js/welcome.js"></script>
<script src="js/welcome.js" defer></script>
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment