Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
test-webshop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Artem
test-webshop
Commits
44fe43c4
Commit
44fe43c4
authored
May 07, 2020
by
Artem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imporove add to cart method
parent
30b2976e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
4 deletions
+6
-4
CartController.php
app/Http/Controllers/CartController.php
+2
-0
welcome.js
public/js/welcome.js
+1
-1
cart.blade.php
resources/views/cart.blade.php
+2
-2
welcome.blade.php
resources/views/welcome.blade.php
+1
-1
No files found.
app/Http/Controllers/CartController.php
View file @
44fe43c4
...
@@ -25,6 +25,8 @@ class CartController extends Controller
...
@@ -25,6 +25,8 @@ class CartController extends Controller
public
function
addToCart
(
Product
$product
)
public
function
addToCart
(
Product
$product
)
{
{
$product
->
addItemToCart
();
$product
->
addItemToCart
();
$cart
=
Session
::
get
(
'cart'
);
return
$cart
->
total_qty
;
}
}
public
function
updateQtyInCart
(
Request
$request
)
public
function
updateQtyInCart
(
Request
$request
)
...
...
public/js/welcome.js
View file @
44fe43c4
...
@@ -7,7 +7,7 @@ function setAddToCardEventListener() {
...
@@ -7,7 +7,7 @@ function setAddToCardEventListener() {
axios
.
post
(
actionUrl
)
axios
.
post
(
actionUrl
)
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
const
cartAmountElem
=
document
.
querySelector
(
'.amount-in-cart'
);
const
cartAmountElem
=
document
.
querySelector
(
'.amount-in-cart'
);
cartAmountElem
.
textContent
++
;
cartAmountElem
.
textContent
=
response
.
data
;
})
})
.
catch
(
function
(
error
)
{
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
...
...
resources/views/cart.blade.php
View file @
44fe43c4
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
>Update quantity</button>
>Update quantity</button>
</td>
</td>
<td class="
hidden
-
xs
text
-
center
"><strong>Total € {{
$cart->total_price
}}</strong></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>
</tr>
</tfoot>
</tfoot>
</table>
</table>
...
@@ -75,5 +75,5 @@
...
@@ -75,5 +75,5 @@
@endsection
@endsection
@section('script')
@section('script')
<script src="
js
/
cart
.
js
"></script>
<script src="
js
/
cart
.
js
"
defer
></script>
@endsection
@endsection
resources/views/welcome.blade.php
View file @
44fe43c4
...
@@ -32,5 +32,5 @@
...
@@ -32,5 +32,5 @@
@endsection
@endsection
@section('script')
@section('script')
<script src="
js
/
welcome
.
js
"></script>
<script src="
js
/
welcome
.
js
"
defer
></script>
@endsection
@endsection
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment