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
76388bfd
Commit
76388bfd
authored
May 18, 2020
by
Artem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
very last commit, fix products links in cart and success notifications
parent
15453a4d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
10 deletions
+11
-10
CartController.php
app/Http/Controllers/CartController.php
+2
-1
env.example
env.example
+0
-0
cart.js
public/js/cart.js
+8
-7
cart.blade.php
resources/views/cart.blade.php
+0
-1
web.php
routes/web.php
+1
-1
No files found.
app/Http/Controllers/CartController.php
View file @
76388bfd
...
...
@@ -74,7 +74,8 @@ class CartController extends Controller
// make array of products in order to get correct order of items in js
$cart_products
=
[];
foreach
(
$cart
->
items
as
$item
)
{
foreach
(
$cart
->
items
as
$id
=>
$item
)
{
$item
[
'productLink'
]
=
route
(
'product.show'
,
$id
);
$cart_products
[]
=
$item
;
}
...
...
.
env.example
→
env.example
View file @
76388bfd
File moved
public/js/cart.js
View file @
76388bfd
...
...
@@ -11,7 +11,6 @@ class Cart {
this
.
totalPrice
;
this
.
updateItemUrl
=
cartElem
.
dataset
.
updateItemUrl
;
this
.
removeItemUrl
=
cartElem
.
dataset
.
removeItemUrl
;
this
.
itemUrl
=
cartElem
.
dataset
.
itemUrl
;
this
.
hasEvents
;
this
.
updateItemQty
=
this
.
updateItemQty
.
bind
(
this
);
this
.
removeItemFromCart
=
this
.
removeItemFromCart
.
bind
(
this
);
...
...
@@ -23,7 +22,7 @@ class Cart {
<div class="row">
<div class="col-sm-3 hidden-xs"><img src="/img/
${
product
.
item
.
type
}
.jpg" width="100" height="100" alt="
${
product
.
item
.
reference
}
" class="img-responsive"/></div>
<div class="col-sm-9">
<h4 class="nomargin"><a href="
${
this
.
itemUrl
+
product
.
item
.
id
}
">
${
product
.
item
.
reference
}
</a></h4>
<h4 class="nomargin"><a href="
${
product
.
productLink
}
">
${
product
.
item
.
reference
}
</a></h4>
<p>
${
product
.
item
.
description_short
}
</p>
</div>
</div>
...
...
@@ -75,8 +74,7 @@ class Cart {
this
.
sendUpdateItemQtyRequest
({
productId
,
changedQty
})
.
then
(
(
response
)
=>
{
this
.
show
();
toastr
.
success
(
'Quantity updated'
);
this
.
show
(
'Quantity updated'
);
})
.
catch
(
(
error
)
=>
{
console
.
log
(
error
);
...
...
@@ -100,8 +98,7 @@ class Cart {
this
.
sendRemoveItemRequest
({
productId
})
.
then
(
(
response
)
=>
{
this
.
show
();
toastr
.
success
(
'Product deleted'
);
this
.
show
(
'Product deleted'
);
})
.
catch
(
(
error
)
=>
{
console
.
log
(
error
);
...
...
@@ -121,7 +118,7 @@ class Cart {
}
show
()
{
show
(
successMessage
)
{
if
(
!
this
.
loaderElem
.
classList
.
contains
(
'loader-show'
))
{
this
.
loaderElem
.
classList
.
toggle
(
'loader-show'
);
}
...
...
@@ -141,6 +138,10 @@ class Cart {
this
.
showProducts
();
this
.
toggleLoager
();
if
(
successMessage
)
{
toastr
.
success
(
successMessage
);
}
if
(
!
this
.
hasEvents
)
{
this
.
events
();
}
...
...
resources/views/cart.blade.php
View file @
76388bfd
...
...
@@ -65,7 +65,6 @@
data-get-items-url="
{{
route
(
'cart.getItems'
)
}}
"
data-update-item-url="
{{
route
(
'cart.updateQtyInCart'
)
}}
"
data-remove-item-url="
{{
route
(
'cart.removeFromCart'
)
}}
"
data-item-url="
{{
route
(
'productPath'
)
}}
"
>
{{-- @foreach(
$products
as
$product
)
<tr>
...
...
routes/web.php
View file @
76388bfd
...
...
@@ -18,7 +18,7 @@ Auth::routes();
Route
::
get
(
'/'
,
'ProductController@index'
)
->
name
(
'homepage'
);
Route
::
prefix
(
'product'
)
->
group
(
function
()
{
Route
::
post
(
'/'
,
'ProductController@store'
)
->
name
(
'productPath'
)
;
Route
::
post
(
'/'
,
'ProductController@store'
);
Route
::
get
(
'/create'
,
'ProductController@create'
);
Route
::
get
(
'/{product}'
,
'ProductController@show'
)
->
name
(
'product.show'
);
Route
::
get
(
'/{product}/edit'
,
'ProductController@edit'
)
->
name
(
'product.edit'
);
...
...
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