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
c52aeea3
Commit
c52aeea3
authored
May 12, 2020
by
Artem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Add to cart button on product page
parent
fe9f5e90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
product.js
public/js/product.js
+17
-0
product.blade.php
resources/views/product/product.blade.php
+16
-7
No files found.
public/js/product.js
0 → 100644
View file @
c52aeea3
function
setAddToCardEventListener
()
{
document
.
querySelector
(
'.js-btn-add-to-basket'
).
addEventListener
(
'click'
,
function
(
e
)
{
const
actionUrl
=
this
.
dataset
.
action
;
axios
.
post
(
actionUrl
)
.
then
(
function
(
response
)
{
const
cartAmountElem
=
document
.
querySelector
(
'.amount-in-cart'
);
cartAmountElem
.
textContent
=
response
.
data
;
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
alert
(
'Sorry, error, we are just learning how to code'
);
});
});
}
setAddToCardEventListener
();
resources/views/product/product.blade.php
View file @
c52aeea3
...
@@ -3,18 +3,23 @@
...
@@ -3,18 +3,23 @@
@
section
(
'content'
)
@
section
(
'content'
)
<
section
class
="
product
-
info
">
<
section
class
="
product
-
info
">
<div class="
container
">
<div class="
container
">
<div>
<img src="
/
img
/
{{
$product
->
type
}}
.
jpg
" alt="
{{
$product
->
reference
}}
">
</div>
<p>
{
{$product->reference}
}
</p>
<p>
{
{$product->description_long}
}
</p>
<p>Price
{
{$product->price}
}
EUR</p>
<div>
<div>
<a {{--href="
/
product
/
{{
$product
->
id
}}
/
edit
"
<a {{--href="
/
product
/
{{
$product
->
id
}}
/
edit
"
href="
{{
route
(
'product.edit'
,
$product
)
}}
--
}}
href="
{{
route
(
'product.edit'
,
$product
)
}}
--
}}
href
=
"{{
$product->editPath
() }}"
href
=
"{{
$product->editPath
() }}"
>
Edit
product
</
a
>
>
Edit
product
</
a
>
</
div
>
</
div
>
<
div
>
<
img
src
=
"/img/
{
{$product->type}
}
.jpg"
alt
=
"
{
{$product->reference}
}
"
>
</
div
>
<
h2
>
{{
$product
->
reference
}}
</
h2
>
<
p
>
{{
$product
->
description_long
}}
</
p
>
<
p
class
="
text
-
danger
font
-
weight
-
bold
">Price
{
{$product->price}
}
EUR</p>
<button class="
js
-
btn
-
add
-
to
-
basket
btn
btn
-
info
text
-
white
"
data-action="
{{
route
(
'cart.addToCart'
,
$product
)
}}
"
>Add to basket</button>
{{-- <form method="
POST
" action="
{{
$product
->
path
()
}}
">--}}
{{-- <form method="
POST
" action="
{{
$product
->
path
()
}}
">--}}
{{-- @csrf--}}
{{-- @csrf--}}
{{-- @method('DELETE')--}}
{{-- @method('DELETE')--}}
...
@@ -24,3 +29,7 @@
...
@@ -24,3 +29,7 @@
</div>
</div>
</section>
</section>
@endsection
@endsection
@section('script')
<script src="
/
js
/
product
.
js
" defer></script>
@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